From patchwork Wed Mar 1 20:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 63081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3847543wrd; Wed, 1 Mar 2023 12:18:58 -0800 (PST) X-Google-Smtp-Source: AK7set90XwcW8gVu3ko7w+jt6HqaHGUMaU3C+yil75UX9JrN9YHORsss1a2tfvrKV5rYHLN5r9Iw X-Received: by 2002:aa7:db4b:0:b0:4ac:89b:b605 with SMTP id n11-20020aa7db4b000000b004ac089bb605mr8165441edt.22.1677701937941; Wed, 01 Mar 2023 12:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677701937; cv=none; d=google.com; s=arc-20160816; b=kGAzVA/CIs1xh4svdyrXTnHnm1sJlszDWDiFvvixMPxLL3iIf/evWNXW6IfFyCFV0D Nx8947FZFhhNILRjNu4uN0MJjhy//06m4z3N7MGBjWiB7SUi9H7Ck8bjVr2F32AOKNGv 4ACVQo1N9slKW/wrkbcleNn0GT9Q0CJmexuP8DPRMWjSlTHPnQ8zrwcqqWlzbGvmMhFs 1VBwWWHrkBUcq9/+fiknyCBYZKYL+Cxw5sXsaPNXuGsQ6TPBTLhL3nbrAqO0XwrdvihW gCFusNl/Kv8Fkf8dRk+Sh0PTGSdoDZWGn89UqsiCzt9WTw1UbnpLVDsFXdt2AkruHI9q cb9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XAtw1U/BTDOrZHgBLIQAFfpKcmyk/l+MkBAEZzxdNlo=; b=H1se74gu3gwMq8DrLQDZwYFxBIfAoUVrO3+UHSMwfe3ZX9stgWKSwtPO9R8GDhCURF /w4rpvk/tUL6LcTWSGseZUEeSZtnK6/v8c7/tr90bGIdB004btxcJsmToAcllTMmMFYp rE5zAMNOyD149LZmZLxJGYv65nAKaUSd5/iiSBk28xoceUYo5kbl0rztP2Z796anng/+ HrPRmK9Do7cwHrF49YR25nFz1Ii1s6eIKMzcha+D9U1aJdRc9ydAJDyEqPhMVHvznE32 OHgeS0oqgueFkfRupWSvAe5V51/IEXPLpUp/hBPULXrGjYa34aiDmsb2ZeTghmOT+/QN mdkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LXar5EDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g19-20020a170906395300b008de42ddc5d8si5429830eje.977.2023.03.01.12.18.33; Wed, 01 Mar 2023 12:18:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LXar5EDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbjCAUP0 (ORCPT + 99 others); Wed, 1 Mar 2023 15:15:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjCAUPF (ORCPT ); Wed, 1 Mar 2023 15:15:05 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF8442BC9 for ; Wed, 1 Mar 2023 12:14:58 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id e13so2979953wro.10 for ; Wed, 01 Mar 2023 12:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677701697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XAtw1U/BTDOrZHgBLIQAFfpKcmyk/l+MkBAEZzxdNlo=; b=LXar5EDJMGIvYkIQBNmH4aYD+L1S+thPtq/sVBh9BMX6eutE7uXqTCBu5XWNA4rH9k bxhZfiJgmSOli8WjZh6fThTr8fEDgRQf9ZabmpDx7qyVagf2vb/2lL8Ej0CCWueeUD28 rigW+wI0aZ8p41nZ4QFkUIe5I37Ls0U/f1nLDIIWWgvq8Ni7D20IuORr96GbR6MuAIpA 6bTbQS+c6tzTyyCgnJkYCxHzuDQ4SAMOjuAzo3BqTH5nKf9y5o+9PvyY3WF2sh6quRCK JpI3CrVtiHzTKhXZn8Sz167S6oHzcF796mz3pUfZNIjQjKigyPhttWKhnaBTakNeIx3v NAQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677701697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XAtw1U/BTDOrZHgBLIQAFfpKcmyk/l+MkBAEZzxdNlo=; b=xNG8OqF/1rTtR7WYeH4GemZyirRz32yd1tuObwqgXR5rcYG6pBcJJThnJqCPrV8Qfb EUIuDRyd7+XRhc4vcPL1XpJBZ/Q+VfW+QtuoTanF4p4mCymzzLqQuV2p9tN8p1ao1KUF BxtsbkPGydMUmpg1IkY5mYtYYq2UPkzmQgf0WvwaF82BxlhGSyfQcH15hJPm4r7UZjo9 yLwHweA34C05olNo5AHqIkeYzaFYlMY6S6CT30PaU2jwPnultBGxKxDuVmNX4X2DHr+S +XEl2P8QUVfT9CwTJz61fLbY6lKkIiL81wQAqvhkG2mD4Ec/DYUeShCGVPsxRrpckVyp A6nQ== X-Gm-Message-State: AO0yUKWudkK8v4rvPVN+XcCrnxK2tw4ZKmWzj9nEnhK3bkm2ELZe5prS k6kwCtqTBiSC6MdL/y8Mp0igqGE1cUPC7UyZmOE= X-Received: by 2002:a5d:6607:0:b0:2bf:96ae:7cc8 with SMTP id n7-20020a5d6607000000b002bf96ae7cc8mr5920649wru.4.1677701696680; Wed, 01 Mar 2023 12:14:56 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:6ffe:ce4f:bd31:1e6d]) by smtp.gmail.com with ESMTPSA id x16-20020a1c7c10000000b003e70a7c1b73sm576546wmc.16.2023.03.01.12.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 12:14:56 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Mark Brown , Amit Kucheria , Zhang Rui Subject: [PATCH v5 01/18] thermal/core: Add a thermal zone 'devdata' accessor Date: Wed, 1 Mar 2023 21:14:29 +0100 Message-Id: <20230301201446.3713334-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301201446.3713334-1-daniel.lezcano@linaro.org> References: <20230301201446.3713334-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759197987198950153?= X-GMAIL-MSGID: =?utf-8?q?1759197987198950153?= The thermal zone device structure is exposed to the different drivers and obviously they access the internals while that should be restricted to the core thermal code. In order to self-encapsulate the thermal core code, we need to prevent the drivers accessing directly the thermal zone structure and provide accessor functions to deal with. Provide an accessor to the 'devdata' structure and make use of it in the different drivers. No functional changes intended. Signed-off-by: Daniel Lezcano Acked-by: Rafael J. Wysocki Acked-by: Mark Brown --- drivers/thermal/thermal_core.c | 6 ++++++ include/linux/thermal.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 0675df54c8e6..9fa12147fead 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1378,6 +1378,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, int n } EXPORT_SYMBOL_GPL(thermal_zone_device_register); +void *thermal_zone_device_priv(struct thermal_zone_device *tzd) +{ + return tzd->devdata; +} +EXPORT_SYMBOL_GPL(thermal_zone_device_priv); + /** * thermal_zone_device_unregister - removes the registered thermal zone device * @tz: the thermal zone device to remove diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 2bb4bf33f4f3..7dbb5712434c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -365,6 +365,8 @@ thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int void *, struct thermal_zone_device_ops *, struct thermal_zone_params *, int, int); +void *thermal_zone_device_priv(struct thermal_zone_device *tzd); + int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *, unsigned long, unsigned long, @@ -436,6 +438,11 @@ static inline int thermal_zone_get_offset( struct thermal_zone_device *tz) { return -ENODEV; } +static inline void *thermal_zone_device_priv(struct thermal_zone_device *tz) +{ + return NULL; +} + static inline int thermal_zone_device_enable(struct thermal_zone_device *tz) { return -ENODEV; }