From nobody Thu Nov 14 07:00:38 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29546C74A4B for ; Sun, 19 Feb 2023 14:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbjBSOij (ORCPT ); Sun, 19 Feb 2023 09:38:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbjBSOh6 (ORCPT ); Sun, 19 Feb 2023 09:37:58 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3806A1204F for ; Sun, 19 Feb 2023 06:37:46 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id f12so575418wrr.4 for ; Sun, 19 Feb 2023 06:37:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=+N523DtRIKKcMxEOWF7Xp597YFQu0I7H1QHTM+dJ87Y=; b=zoI4AczXwtkNEOIFMl2oWk0sfwHGUIOKbwJ7fxs9HBT1kYlKyNxDAVtcxnuPL7HZAp aeGd45T+A5eSgm/YMeoBgVNkP/wyvF9ZnW8/u4iMMy6TQWfbcvndVU5soyXr6OBCSR46 RZ59G74q82Ff/AaCnR3f28ZJMUZADKCyiR3FLYK+1RY6lqIDFyLs4YFEpGT5r3jRIjPQ Wf89lMkC148L6syx+bYrRScekQtrRo1JmsHppFSFNlTP5QMqmTm1o7LgLiK2uKzITeBZ OLe0+7/K2iWX2jNPx699wzunQnWJEAe0t4c6IJXueluq1Ft3ispSCeM+QdbXLgIW5mAf 9J1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+N523DtRIKKcMxEOWF7Xp597YFQu0I7H1QHTM+dJ87Y=; b=TH7FUtUN7t+wUPCpE0xyzwDka3NEkUMKWpm+YbTrH2yXxcCLUBfvz977NcE7qKsx3w qqK5cgzLDS1BJOZRcMHfg5aTgDBICimgM8pE9dndKrd18hxQlLjxkDZqvFP++/xH7KNw HlFmGfMaYoKu/lAL8ZFVfKqkaw0sCT6VcJfqb6Py+rKlZivSL0I5aoiiQ+JsL9AttG3j C+caxZNxFJwoAuqQvi6X5IYgIlnoG/pZLawpocKWcYh/u6/K0jz562dYCD2Z/m6nBfw2 Q4w/ipNQRsUfe9UotXZ6yGUELfiKwQKqrfuHqGCQb7mNtiGJpWG2qEi5Irys+PWLTZ9R vroQ== X-Gm-Message-State: AO0yUKW1tKMvt3sRvJFCA9+cXZ0zz9SvpZxlN5MhS37DECOST+35GvQ+ rDaFzxrKrXdZqSC+HKUaXqxCUA== X-Google-Smtp-Source: AK7set8/ARAo2mVqPni3Z48Cd9X8pVAhnwoeFMwIQIpYB8CWtiLwCY9ebYk8SLCeLLePa3xixPYaxw== X-Received: by 2002:adf:ea43:0:b0:2c5:6180:516e with SMTP id j3-20020adfea43000000b002c56180516emr147449wrn.39.1676817463812; Sun, 19 Feb 2023 06:37:43 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:6f43:b92:7670:463]) by smtp.gmail.com with ESMTPSA id a18-20020adfe5d2000000b002be505ab59asm86176wrn.97.2023.02.19.06.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 06:37:43 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Rui , Len Brown , Damien Le Moal , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Jean Delvare , Guenter Roeck , Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Dmitry Torokhov , Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Ido Schimmel , Petr Machata , Gregory Greenman , Kalle Valo , Sebastian Reichel , Liam Girdwood , Mark Brown , Miquel Raynal , Amit Kucheria , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Markus Mayer , Support Opensource , Andy Gross , Bjorn Andersson , Konrad Dybcio , Thara Gopinath , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Heiko Stuebner , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Orson Zhai , Baolin Wang , Chunyan Zhang , Vasily Khoruzhick , Yangtao Li , Thierry Reding , Jonathan Hunter , Talel Shenhar , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Matthias Brugger , AngeloGioacchino Del Regno , Stefan Wahren , Neil Armstrong , ye xingchen , Zheng Yongjun , Tim Zimmermann , Yang Li , Srinivas Pandruvada , Ricardo Neri , Jiang Jian , Daniel Golle , Balsam CHIHI , Randy Dunlap , Mikko Perttunen , linux-acpi@vger.kernel.org (open list:ACPI THERMAL DRIVER), linux-ide@vger.kernel.org (open list:LIBATA SUBSYSTEM (Serial and Parallel ATA drivers)), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-iio@vger.kernel.org (open list:IIO SUBSYSTEM AND DRIVERS), linux-sunxi@lists.linux.dev (open list:ARM/Allwinner sunXi SoC support), linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK , TOUCHSCREEN)...), netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)), linux-wireless@vger.kernel.org (open list:INTEL WIRELESS WIFI LINK (iwlwifi)), linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT), linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT), linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH v1 01/17] thermal/core: Add a thermal zone 'devdata' accessor Date: Sun, 19 Feb 2023 15:36:41 +0100 Message-Id: <20230219143657.241542-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230219143657.241542-1-daniel.lezcano@linaro.org> References: <20230219143657.241542-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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: Gregory Greenman Acked-by: Guenter Roeck Acked-by: Mark Brown Acked-by: Sebastian Reichel Reviewed-by: Adam Ward Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Balsam CHIHI Reviewed-by: Baolin Wang Reviewed-by: Ido Schimmel Reviewed-by: Niklas S=C3=B6derlund --- drivers/acpi/thermal.c | 16 ++++++++-------- drivers/ata/ahci_imx.c | 2 +- drivers/hwmon/hwmon.c | 4 ++-- drivers/hwmon/pmbus/pmbus_core.c | 2 +- drivers/hwmon/scmi-hwmon.c | 2 +- drivers/hwmon/scpi-hwmon.c | 2 +- drivers/iio/adc/sun4i-gpadc-iio.c | 2 +- drivers/input/touchscreen/sun4i-ts.c | 2 +- .../net/ethernet/chelsio/cxgb4/cxgb4_thermal.c | 2 +- .../net/ethernet/mellanox/mlxsw/core_thermal.c | 14 +++++++------- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 ++-- drivers/power/supply/power_supply_core.c | 2 +- drivers/regulator/max8973-regulator.c | 2 +- drivers/thermal/armada_thermal.c | 4 ++-- drivers/thermal/broadcom/bcm2711_thermal.c | 2 +- drivers/thermal/broadcom/bcm2835_thermal.c | 2 +- drivers/thermal/broadcom/brcmstb_thermal.c | 4 ++-- drivers/thermal/broadcom/ns-thermal.c | 2 +- drivers/thermal/broadcom/sr-thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/hisi_thermal.c | 2 +- drivers/thermal/imx8mm_thermal.c | 2 +- drivers/thermal/imx_sc_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 6 +++--- drivers/thermal/intel/intel_pch_thermal.c | 2 +- drivers/thermal/intel/intel_soc_dts_iosf.c | 13 +++++-------- drivers/thermal/intel/x86_pkg_temp_thermal.c | 4 ++-- drivers/thermal/k3_bandgap.c | 2 +- drivers/thermal/k3_j72xx_bandgap.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/max77620_thermal.c | 2 +- drivers/thermal/mediatek/auxadc_thermal.c | 2 +- drivers/thermal/mediatek/lvts_thermal.c | 4 ++-- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 4 ++-- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 4 ++-- drivers/thermal/qoriq_thermal.c | 2 +- drivers/thermal/rcar_gen3_thermal.c | 4 ++-- drivers/thermal/rcar_thermal.c | 3 +-- drivers/thermal/rockchip_thermal.c | 4 ++-- drivers/thermal/rzg2l_thermal.c | 2 +- drivers/thermal/samsung/exynos_tmu.c | 4 ++-- drivers/thermal/spear_thermal.c | 8 ++++---- drivers/thermal/sprd_thermal.c | 2 +- drivers/thermal/sun8i_thermal.c | 2 +- drivers/thermal/tegra/tegra-bpmp-thermal.c | 6 ++++-- drivers/thermal/tegra/tegra30-tsensor.c | 4 ++-- drivers/thermal/thermal-generic-adc.c | 2 +- drivers/thermal/thermal_core.c | 6 ++++++ drivers/thermal/thermal_mmio.c | 2 +- .../thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++-- drivers/thermal/uniphier_thermal.c | 2 +- include/linux/thermal.h | 2 ++ 53 files changed, 97 insertions(+), 91 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 0b4b844f9d4c..69d0da6456d5 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -498,7 +498,7 @@ static int acpi_thermal_get_trip_points(struct acpi_the= rmal *tz) =20 static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); int result; =20 if (!tz) @@ -516,7 +516,7 @@ static int thermal_get_temp(struct thermal_zone_device = *thermal, int *temp) static int thermal_get_trip_type(struct thermal_zone_device *thermal, int trip, enum thermal_trip_type *type) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); int i; =20 if (!tz || trip < 0) @@ -560,7 +560,7 @@ static int thermal_get_trip_type(struct thermal_zone_de= vice *thermal, static int thermal_get_trip_temp(struct thermal_zone_device *thermal, int trip, int *temp) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); int i; =20 if (!tz || trip < 0) @@ -613,7 +613,7 @@ static int thermal_get_trip_temp(struct thermal_zone_de= vice *thermal, static int thermal_get_crit_temp(struct thermal_zone_device *thermal, int *temperature) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); =20 if (tz->trips.critical.flags.valid) { *temperature =3D deci_kelvin_to_millicelsius_with_offset( @@ -628,7 +628,7 @@ static int thermal_get_crit_temp(struct thermal_zone_de= vice *thermal, static int thermal_get_trend(struct thermal_zone_device *thermal, int trip, enum thermal_trend *trend) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); enum thermal_trip_type type; int i; =20 @@ -670,7 +670,7 @@ static int thermal_get_trend(struct thermal_zone_device= *thermal, =20 static void acpi_thermal_zone_device_hot(struct thermal_zone_device *therm= al) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); =20 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, dev_name(&tz->device->dev), @@ -679,7 +679,7 @@ static void acpi_thermal_zone_device_hot(struct thermal= _zone_device *thermal) =20 static void acpi_thermal_zone_device_critical(struct thermal_zone_device *= thermal) { - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); =20 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, dev_name(&tz->device->dev), @@ -693,7 +693,7 @@ static int acpi_thermal_cooling_device_cb(struct therma= l_zone_device *thermal, bool bind) { struct acpi_device *device =3D cdev->devdata; - struct acpi_thermal *tz =3D thermal->devdata; + struct acpi_thermal *tz =3D thermal_zone_device_get_data(thermal); struct acpi_device *dev; acpi_handle handle; int i; diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index a950767f7948..0ef928528aec 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c @@ -418,7 +418,7 @@ static int __sata_ahci_read_temperature(void *dev, int = *temp) =20 static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int = *temp) { - return __sata_ahci_read_temperature(tz->devdata, temp); + return __sata_ahci_read_temperature(thermal_zone_device_get_data(tz), tem= p); } =20 static ssize_t sata_ahci_show_temp(struct device *dev, diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 33edb5c02f7d..b33477d04c2b 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -154,7 +154,7 @@ static DEFINE_IDA(hwmon_ida); #ifdef CONFIG_THERMAL_OF static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *tem= p) { - struct hwmon_thermal_data *tdata =3D tz->devdata; + struct hwmon_thermal_data *tdata =3D thermal_zone_device_get_data(tz); struct hwmon_device *hwdev =3D to_hwmon_device(tdata->dev); int ret; long t; @@ -171,7 +171,7 @@ static int hwmon_thermal_get_temp(struct thermal_zone_d= evice *tz, int *temp) =20 static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low= , int high) { - struct hwmon_thermal_data *tdata =3D tz->devdata; + struct hwmon_thermal_data *tdata =3D thermal_zone_device_get_data(tz); struct hwmon_device *hwdev =3D to_hwmon_device(tdata->dev); const struct hwmon_chip_info *chip =3D hwdev->chip; const struct hwmon_channel_info **info =3D chip->info; diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index 95e95783972a..159a88af6277 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1272,7 +1272,7 @@ struct pmbus_thermal_data { =20 static int pmbus_thermal_get_temp(struct thermal_zone_device *tz, int *tem= p) { - struct pmbus_thermal_data *tdata =3D tz->devdata; + struct pmbus_thermal_data *tdata =3D thermal_zone_device_get_data(tz); struct pmbus_sensor *sensor =3D tdata->sensor; struct pmbus_data *pmbus_data =3D tdata->pmbus_data; struct i2c_client *client =3D to_i2c_client(pmbus_data->dev); diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index e192f0c67146..7951b6026f48 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -141,7 +141,7 @@ static int scmi_hwmon_thermal_get_temp(struct thermal_z= one_device *tz, { int ret; long value; - struct scmi_thermal_sensor *th_sensor =3D tz->devdata; + struct scmi_thermal_sensor *th_sensor =3D thermal_zone_device_get_data(tz= ); =20 ret =3D scmi_hwmon_read_scaled_value(th_sensor->ph, th_sensor->info, &value); diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c index 4d75385f7d5e..efe0ddbc5293 100644 --- a/drivers/hwmon/scpi-hwmon.c +++ b/drivers/hwmon/scpi-hwmon.c @@ -64,7 +64,7 @@ static void scpi_scale_reading(u64 *value, struct sensor_= data *sensor) =20 static int scpi_read_temp(struct thermal_zone_device *tz, int *temp) { - struct scpi_thermal_zone *zone =3D tz->devdata; + struct scpi_thermal_zone *zone =3D thermal_zone_device_get_data(tz); struct scpi_sensors *scpi_sensors =3D zone->scpi_sensors; struct scpi_ops *scpi_ops =3D scpi_sensors->scpi_ops; struct sensor_data *sensor =3D &scpi_sensors->data[zone->sensor_id]; diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpad= c-iio.c index a6ade70dedf8..e24ac3ee8a35 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -414,7 +414,7 @@ static int sun4i_gpadc_runtime_resume(struct device *de= v) =20 static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp) { - struct sun4i_gpadc_iio *info =3D tz->devdata; + struct sun4i_gpadc_iio *info =3D thermal_zone_device_get_data(tz); int val, scale, offset; =20 if (sun4i_gpadc_temp_read(info->indio_dev, &val)) diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscre= en/sun4i-ts.c index 73eb8f80be6e..5e5434ffe397 100644 --- a/drivers/input/touchscreen/sun4i-ts.c +++ b/drivers/input/touchscreen/sun4i-ts.c @@ -194,7 +194,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *t= s, int *temp) =20 static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp) { - return sun4i_get_temp(tz->devdata, temp); + return sun4i_get_temp(thermal_zone_device_get_data(tz), temp); } =20 static const struct thermal_zone_device_ops sun4i_ts_tz_ops =3D { diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/n= et/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 95e1b415ba13..8b0d318feef4 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c @@ -12,7 +12,7 @@ static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev, int *temp) { - struct adapter *adap =3D tzdev->devdata; + struct adapter *adap =3D thermal_zone_device_get_data(tzdev); u32 param, val; int ret; =20 diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/n= et/ethernet/mellanox/mlxsw/core_thermal.c index c5240d38c9db..228b6ffaef98 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -201,7 +201,7 @@ mlxsw_thermal_module_trips_update(struct device *dev, s= truct mlxsw_core *core, static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev, struct thermal_cooling_device *cdev) { - struct mlxsw_thermal *thermal =3D tzdev->devdata; + struct mlxsw_thermal *thermal =3D thermal_zone_device_get_data(tzdev); struct device *dev =3D thermal->bus_info->dev; int i, err; =20 @@ -227,7 +227,7 @@ static int mlxsw_thermal_bind(struct thermal_zone_devic= e *tzdev, static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev, struct thermal_cooling_device *cdev) { - struct mlxsw_thermal *thermal =3D tzdev->devdata; + struct mlxsw_thermal *thermal =3D thermal_zone_device_get_data(tzdev); struct device *dev =3D thermal->bus_info->dev; int i; int err; @@ -249,7 +249,7 @@ static int mlxsw_thermal_unbind(struct thermal_zone_dev= ice *tzdev, static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, int *p_temp) { - struct mlxsw_thermal *thermal =3D tzdev->devdata; + struct mlxsw_thermal *thermal =3D thermal_zone_device_get_data(tzdev); struct device *dev =3D thermal->bus_info->dev; char mtmp_pl[MLXSW_REG_MTMP_LEN]; int temp; @@ -281,7 +281,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops= =3D { static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev, struct thermal_cooling_device *cdev) { - struct mlxsw_thermal_module *tz =3D tzdev->devdata; + struct mlxsw_thermal_module *tz =3D thermal_zone_device_get_data(tzdev); struct mlxsw_thermal *thermal =3D tz->parent; int i, j, err; =20 @@ -310,7 +310,7 @@ static int mlxsw_thermal_module_bind(struct thermal_zon= e_device *tzdev, static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev, struct thermal_cooling_device *cdev) { - struct mlxsw_thermal_module *tz =3D tzdev->devdata; + struct mlxsw_thermal_module *tz =3D thermal_zone_device_get_data(tzdev); struct mlxsw_thermal *thermal =3D tz->parent; int i; int err; @@ -356,7 +356,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlx= sw_core *core, static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, int *p_temp) { - struct mlxsw_thermal_module *tz =3D tzdev->devdata; + struct mlxsw_thermal_module *tz =3D thermal_zone_device_get_data(tzdev); struct mlxsw_thermal *thermal =3D tz->parent; int temp, crit_temp, emerg_temp; struct device *dev; @@ -391,7 +391,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_mod= ule_ops =3D { static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzde= v, int *p_temp) { - struct mlxsw_thermal_module *tz =3D tzdev->devdata; + struct mlxsw_thermal_module *tz =3D thermal_zone_device_get_data(tzdev); struct mlxsw_thermal *thermal =3D tz->parent; char mtmp_pl[MLXSW_REG_MTMP_LEN]; u16 index; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wire= less/intel/iwlwifi/mvm/tt.c index 232c200af38f..ee8fee29107f 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c @@ -615,7 +615,7 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mv= m) static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, int *temperature) { - struct iwl_mvm *mvm =3D (struct iwl_mvm *)device->devdata; + struct iwl_mvm *mvm =3D thermal_zone_device_get_data(device); int ret; int temp; =20 @@ -641,7 +641,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_d= evice *device, static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, int trip, int temp) { - struct iwl_mvm *mvm =3D (struct iwl_mvm *)device->devdata; + struct iwl_mvm *mvm =3D thermal_zone_device_get_data(device); struct iwl_mvm_thermal_device *tzone; int ret; =20 diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/suppl= y/power_supply_core.c index 7c790c41e2fe..166f0aacc797 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1142,7 +1142,7 @@ static int power_supply_read_temp(struct thermal_zone= _device *tzd, int ret; =20 WARN_ON(tzd =3D=3D NULL); - psy =3D tzd->devdata; + psy =3D thermal_zone_device_get_data(tzd); ret =3D power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); if (ret) return ret; diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8= 973-regulator.c index 7e00a45db26a..ccacba66d367 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -436,7 +436,7 @@ static int max8973_init_dcdc(struct max8973_chip *max, =20 static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *= temp) { - struct max8973_chip *mchip =3D tz->devdata; + struct max8973_chip *mchip =3D thermal_zone_device_get_data(tz); unsigned int val; int ret; =20 diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_ther= mal.c index 2efc222a379b..82d3e15d51f6 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -398,7 +398,7 @@ static int armada_read_sensor(struct armada_thermal_pri= v *priv, int *temp) static int armada_get_temp_legacy(struct thermal_zone_device *thermal, int *temp) { - struct armada_thermal_priv *priv =3D thermal->devdata; + struct armada_thermal_priv *priv =3D thermal_zone_device_get_data(thermal= ); int ret; =20 /* Valid check */ @@ -420,7 +420,7 @@ static struct thermal_zone_device_ops legacy_ops =3D { =20 static int armada_get_temp(struct thermal_zone_device *tz, int *temp) { - struct armada_thermal_sensor *sensor =3D tz->devdata; + struct armada_thermal_sensor *sensor =3D thermal_zone_device_get_data(tz); struct armada_thermal_priv *priv =3D sensor->priv; int ret; =20 diff --git a/drivers/thermal/broadcom/bcm2711_thermal.c b/drivers/thermal/b= roadcom/bcm2711_thermal.c index 1f8651d15160..18b1a4d9ecc7 100644 --- a/drivers/thermal/broadcom/bcm2711_thermal.c +++ b/drivers/thermal/broadcom/bcm2711_thermal.c @@ -33,7 +33,7 @@ struct bcm2711_thermal_priv { =20 static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp) { - struct bcm2711_thermal_priv *priv =3D tz->devdata; + struct bcm2711_thermal_priv *priv =3D thermal_zone_device_get_data(tz); int slope =3D thermal_zone_get_slope(tz); int offset =3D thermal_zone_get_offset(tz); u32 val; diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/b= roadcom/bcm2835_thermal.c index 23918bb76ae6..de2f573863da 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -90,7 +90,7 @@ static int bcm2835_thermal_temp2adc(int temp, int offset,= int slope) =20 static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *t= emp) { - struct bcm2835_thermal_data *data =3D tz->devdata; + struct bcm2835_thermal_data *data =3D thermal_zone_device_get_data(tz); u32 val =3D readl(data->regs + BCM2835_TS_TSENSSTAT); =20 if (!(val & BCM2835_TS_TSENSSTAT_VALID)) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/b= roadcom/brcmstb_thermal.c index 4d02c28331e3..668cdc16b108 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -152,7 +152,7 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_= thermal_priv *priv, =20 static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp) { - struct brcmstb_thermal_priv *priv =3D tz->devdata; + struct brcmstb_thermal_priv *priv =3D thermal_zone_device_get_data(tz); u32 val; long t; =20 @@ -262,7 +262,7 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, voi= d *data) =20 static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int = high) { - struct brcmstb_thermal_priv *priv =3D tz->devdata; + struct brcmstb_thermal_priv *priv =3D thermal_zone_device_get_data(tz); =20 dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high); =20 diff --git a/drivers/thermal/broadcom/ns-thermal.c b/drivers/thermal/broadc= om/ns-thermal.c index 07a8a3f49bd0..98296019ad4c 100644 --- a/drivers/thermal/broadcom/ns-thermal.c +++ b/drivers/thermal/broadcom/ns-thermal.c @@ -16,7 +16,7 @@ =20 static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { - void __iomem *pvtmon =3D tz->devdata; + void __iomem *pvtmon =3D thermal_zone_device_get_data(tz); int offset =3D thermal_zone_get_offset(tz); int slope =3D thermal_zone_get_slope(tz); u32 val; diff --git a/drivers/thermal/broadcom/sr-thermal.c b/drivers/thermal/broadc= om/sr-thermal.c index 2b93502543ff..42b46125f409 100644 --- a/drivers/thermal/broadcom/sr-thermal.c +++ b/drivers/thermal/broadcom/sr-thermal.c @@ -32,7 +32,7 @@ struct sr_thermal { =20 static int sr_get_temp(struct thermal_zone_device *tz, int *temp) { - struct sr_tmon *tmon =3D tz->devdata; + struct sr_tmon *tmon =3D thermal_zone_device_get_data(tz); struct sr_thermal *sr_thermal =3D tmon->priv; =20 *temp =3D readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id)); diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-ther= mal.c index a805a6666c44..3d937f701e0b 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -123,7 +123,7 @@ static irqreturn_t da9062_thermal_irq_handler(int irq, = void *data) static int da9062_thermal_get_temp(struct thermal_zone_device *z, int *temp) { - struct da9062_thermal *thermal =3D z->devdata; + struct da9062_thermal *thermal =3D thermal_zone_device_get_data(z); =20 mutex_lock(&thermal->lock); *temp =3D thermal->temperature; diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c index 056622a58d00..ed7d1173d9fd 100644 --- a/drivers/thermal/dove_thermal.c +++ b/drivers/thermal/dove_thermal.c @@ -87,7 +87,7 @@ static int dove_get_temp(struct thermal_zone_device *ther= mal, int *temp) { unsigned long reg; - struct dove_thermal_priv *priv =3D thermal->devdata; + struct dove_thermal_priv *priv =3D thermal_zone_device_get_data(thermal); =20 /* Valid check */ reg =3D readl_relaxed(priv->control + PMU_TEMP_DIOD_CTRL1_REG); diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 32a7c3cf073d..043751e6a31d 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -431,7 +431,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_dat= a *data) =20 static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { - struct hisi_thermal_sensor *sensor =3D tz->devdata; + struct hisi_thermal_sensor *sensor =3D thermal_zone_device_get_data(tz); struct hisi_thermal_data *data =3D sensor->data; =20 *temp =3D data->ops->get_temp(sensor); diff --git a/drivers/thermal/imx8mm_thermal.c b/drivers/thermal/imx8mm_ther= mal.c index 72b5d6f319c1..750240f4fa32 100644 --- a/drivers/thermal/imx8mm_thermal.c +++ b/drivers/thermal/imx8mm_thermal.c @@ -141,7 +141,7 @@ static int imx8mp_tmu_get_temp(void *data, int *temp) =20 static int tmu_get_temp(struct thermal_zone_device *tz, int *temp) { - struct tmu_sensor *sensor =3D tz->devdata; + struct tmu_sensor *sensor =3D thermal_zone_device_get_data(tz); struct imx8mm_tmu *tmu =3D sensor->priv; =20 return tmu->socdata->get_temp(sensor, temp); diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_ther= mal.c index f32e59e74623..ca10d6a68f0f 100644 --- a/drivers/thermal/imx_sc_thermal.c +++ b/drivers/thermal/imx_sc_thermal.c @@ -46,7 +46,7 @@ static int imx_sc_thermal_get_temp(struct thermal_zone_de= vice *tz, int *temp) { struct imx_sc_msg_misc_get_temp msg; struct imx_sc_rpc_msg *hdr =3D &msg.hdr; - struct imx_sc_sensor *sensor =3D tz->devdata; + struct imx_sc_sensor *sensor =3D thermal_zone_device_get_data(tz); int ret; =20 msg.data.req.resource_id =3D sensor->resource_id; diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index fb0d5cab70af..c3c14cd26aee 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -252,7 +252,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data = *data, =20 static int imx_get_temp(struct thermal_zone_device *tz, int *temp) { - struct imx_thermal_data *data =3D tz->devdata; + struct imx_thermal_data *data =3D thermal_zone_device_get_data(tz); const struct thermal_soc_data *soc_data =3D data->socdata; struct regmap *map =3D data->tempmon; unsigned int n_meas; @@ -311,7 +311,7 @@ static int imx_get_temp(struct thermal_zone_device *tz,= int *temp) static int imx_change_mode(struct thermal_zone_device *tz, enum thermal_device_mode mode) { - struct imx_thermal_data *data =3D tz->devdata; + struct imx_thermal_data *data =3D thermal_zone_device_get_data(tz); =20 if (mode =3D=3D THERMAL_DEVICE_ENABLED) { pm_runtime_get(data->dev); @@ -342,7 +342,7 @@ static int imx_get_crit_temp(struct thermal_zone_device= *tz, int *temp) static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) { - struct imx_thermal_data *data =3D tz->devdata; + struct imx_thermal_data *data =3D thermal_zone_device_get_data(tz); int ret; =20 ret =3D pm_runtime_resume_and_get(data->dev); diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/in= tel/intel_pch_thermal.c index b855d031a855..e53f8a8c06e5 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -119,7 +119,7 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal= _device *ptd, int trip) =20 static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp) { - struct pch_thermal_device *ptd =3D tzd->devdata; + struct pch_thermal_device *ptd =3D thermal_zone_device_get_data(tzd); =20 *temp =3D GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); return 0; diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/i= ntel/intel_soc_dts_iosf.c index 8c26f7b2316b..f7d995722e04 100644 --- a/drivers/thermal/intel/intel_soc_dts_iosf.c +++ b/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -54,7 +54,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *= tzd, int trip, struct intel_soc_dts_sensor_entry *dts; struct intel_soc_dts_sensors *sensors; =20 - dts =3D tzd->devdata; + dts =3D thermal_zone_device_get_data(tzd); sensors =3D dts->sensors; mutex_lock(&sensors->dts_update_lock); status =3D iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, @@ -168,7 +168,7 @@ static int update_trip_temp(struct intel_soc_dts_sensor= _entry *dts, static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { - struct intel_soc_dts_sensor_entry *dts =3D tzd->devdata; + struct intel_soc_dts_sensor_entry *dts =3D thermal_zone_device_get_data(t= zd); struct intel_soc_dts_sensors *sensors =3D dts->sensors; int status; =20 @@ -176,7 +176,7 @@ static int sys_set_trip_temp(struct thermal_zone_device= *tzd, int trip, return -EINVAL; =20 mutex_lock(&sensors->dts_update_lock); - status =3D update_trip_temp(tzd->devdata, trip, temp, + status =3D update_trip_temp(dts, trip, temp, dts->trip_types[trip]); mutex_unlock(&sensors->dts_update_lock); =20 @@ -186,9 +186,7 @@ static int sys_set_trip_temp(struct thermal_zone_device= *tzd, int trip, static int sys_get_trip_type(struct thermal_zone_device *tzd, int trip, enum thermal_trip_type *type) { - struct intel_soc_dts_sensor_entry *dts; - - dts =3D tzd->devdata; + struct intel_soc_dts_sensor_entry *dts =3D thermal_zone_device_get_data(t= zd); =20 *type =3D dts->trip_types[trip]; =20 @@ -200,11 +198,10 @@ static int sys_get_curr_temp(struct thermal_zone_devi= ce *tzd, { int status; u32 out; - struct intel_soc_dts_sensor_entry *dts; + struct intel_soc_dts_sensor_entry *dts =3D thermal_zone_device_get_data(t= zd); struct intel_soc_dts_sensors *sensors; unsigned long raw; =20 - dts =3D tzd->devdata; sensors =3D dts->sensors; status =3D iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, SOC_DTS_OFFSET_TEMP, &out); diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index 1c2de84742df..22f0f206d8f2 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -107,7 +107,7 @@ static struct zone_device *pkg_temp_thermal_get_dev(uns= igned int cpu) =20 static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) { - struct zone_device *zonedev =3D tzd->devdata; + struct zone_device *zonedev =3D thermal_zone_device_get_data(tzd); int val; =20 val =3D intel_tcc_get_temp(zonedev->cpu, true); @@ -122,7 +122,7 @@ static int sys_get_curr_temp(struct thermal_zone_device= *tzd, int *temp) static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { - struct zone_device *zonedev =3D tzd->devdata; + struct zone_device *zonedev =3D thermal_zone_device_get_data(tzd); u32 l, h, mask, shift, intr; int tj_max, ret; =20 diff --git a/drivers/thermal/k3_bandgap.c b/drivers/thermal/k3_bandgap.c index 22c9bcb899c3..8cbd7361b492 100644 --- a/drivers/thermal/k3_bandgap.c +++ b/drivers/thermal/k3_bandgap.c @@ -141,7 +141,7 @@ static int k3_bgp_read_temp(struct k3_thermal_data *dev= data, =20 static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { - struct k3_thermal_data *data =3D tz->devdata; + struct k3_thermal_data *data =3D thermal_zone_device_get_data(tz); int ret =3D 0; =20 ret =3D k3_bgp_read_temp(data, temp); diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_= bandgap.c index 031ea1091909..300a3f985776 100644 --- a/drivers/thermal/k3_j72xx_bandgap.c +++ b/drivers/thermal/k3_j72xx_bandgap.c @@ -248,7 +248,7 @@ static inline int k3_bgp_read_temp(struct k3_thermal_da= ta *devdata, /* Get temperature callback function for thermal zone */ static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { - return k3_bgp_read_temp(tz->devdata, temp); + return k3_bgp_read_temp(thermal_zone_device_get_data(tz), temp); } =20 static const struct thermal_zone_device_ops k3_of_thermal_ops =3D { diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_= thermal.c index bec7ec20e79d..8e39c875ba58 100644 --- a/drivers/thermal/kirkwood_thermal.c +++ b/drivers/thermal/kirkwood_thermal.c @@ -27,7 +27,7 @@ static int kirkwood_get_temp(struct thermal_zone_device *= thermal, int *temp) { unsigned long reg; - struct kirkwood_thermal_priv *priv =3D thermal->devdata; + struct kirkwood_thermal_priv *priv =3D thermal_zone_device_get_data(therm= al); =20 reg =3D readl_relaxed(priv->sensor); =20 diff --git a/drivers/thermal/max77620_thermal.c b/drivers/thermal/max77620_= thermal.c index 6451a55eb582..05b6e9a2a283 100644 --- a/drivers/thermal/max77620_thermal.c +++ b/drivers/thermal/max77620_thermal.c @@ -46,7 +46,7 @@ struct max77620_therm_info { =20 static int max77620_thermal_read_temp(struct thermal_zone_device *tz, int = *temp) { - struct max77620_therm_info *mtherm =3D tz->devdata; + struct max77620_therm_info *mtherm =3D thermal_zone_device_get_data(tz); unsigned int val; int ret; =20 diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/me= diatek/auxadc_thermal.c index ab730f9552d0..d7bf725d224b 100644 --- a/drivers/thermal/mediatek/auxadc_thermal.c +++ b/drivers/thermal/mediatek/auxadc_thermal.c @@ -763,7 +763,7 @@ static int mtk_thermal_bank_temperature(struct mtk_ther= mal_bank *bank) =20 static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature) { - struct mtk_thermal *mt =3D tz->devdata; + struct mtk_thermal *mt =3D thermal_zone_device_get_data(tz); int i; int tempmax =3D INT_MIN; =20 diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/medi= atek/lvts_thermal.c index 84ba65a27acf..86d280187c83 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -252,7 +252,7 @@ static u32 lvts_temp_to_raw(int temperature) =20 static int lvts_get_temp(struct thermal_zone_device *tz, int *temp) { - struct lvts_sensor *lvts_sensor =3D tz->devdata; + struct lvts_sensor *lvts_sensor =3D thermal_zone_device_get_data(tz); void __iomem *msr =3D lvts_sensor->msr; u32 value; =20 @@ -290,7 +290,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz= , int *temp) =20 static int lvts_set_trips(struct thermal_zone_device *tz, int low, int hig= h) { - struct lvts_sensor *lvts_sensor =3D tz->devdata; + struct lvts_sensor *lvts_sensor =3D thermal_zone_device_get_data(tz); void __iomem *base =3D lvts_sensor->base; u32 raw_low =3D lvts_temp_to_raw(low); u32 raw_high =3D lvts_temp_to_raw(high); diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qco= m/qcom-spmi-adc-tm5.c index 31164ade2dd1..b0269daf128a 100644 --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c @@ -360,7 +360,7 @@ static irqreturn_t adc_tm5_gen2_isr(int irq, void *data) =20 static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp) { - struct adc_tm5_channel *channel =3D tz->devdata; + struct adc_tm5_channel *channel =3D thermal_zone_device_get_data(tz); int ret; =20 if (!channel || !channel->iio) @@ -642,7 +642,7 @@ static int adc_tm5_gen2_configure(struct adc_tm5_channe= l *channel, int low, int =20 static int adc_tm5_set_trips(struct thermal_zone_device *tz, int low, int = high) { - struct adc_tm5_channel *channel =3D tz->devdata; + struct adc_tm5_channel *channel =3D thermal_zone_device_get_data(tz); struct adc_tm5_chip *chip; int ret; =20 diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/= qcom/qcom-spmi-temp-alarm.c index 101c75d0e13f..c817b03deb00 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -187,7 +187,7 @@ static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_ch= ip *chip) =20 static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp) { - struct qpnp_tm_chip *chip =3D tz->devdata; + struct qpnp_tm_chip *chip =3D thermal_zone_device_get_data(tz); int ret, mili_celsius; =20 if (!temp) @@ -265,7 +265,7 @@ static int qpnp_tm_update_critical_trip_temp(struct qpn= p_tm_chip *chip, =20 static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_= id, int temp) { - struct qpnp_tm_chip *chip =3D tz->devdata; + struct qpnp_tm_chip *chip =3D thermal_zone_device_get_data(tz); struct thermal_trip trip; int ret; =20 diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_therma= l.c index 431c29c0898a..8b6fe0c9ade2 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -83,7 +83,7 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct= qoriq_sensor *s) =20 static int tmu_get_temp(struct thermal_zone_device *tz, int *temp) { - struct qoriq_sensor *qsensor =3D tz->devdata; + struct qoriq_sensor *qsensor =3D thermal_zone_device_get_data(tz); struct qoriq_tmu_data *qdata =3D qoriq_sensor_to_data(qsensor); u32 val; /* diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen= 3_thermal.c index d6b5b59c5c53..8ad713cb4bf7 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -167,7 +167,7 @@ static int rcar_gen3_thermal_round(int temp) =20 static int rcar_gen3_thermal_get_temp(struct thermal_zone_device *tz, int = *temp) { - struct rcar_gen3_thermal_tsc *tsc =3D tz->devdata; + struct rcar_gen3_thermal_tsc *tsc =3D thermal_zone_device_get_data(tz); int mcelsius, val; int reg; =20 @@ -206,7 +206,7 @@ static int rcar_gen3_thermal_mcelsius_to_temp(struct rc= ar_gen3_thermal_tsc *tsc, =20 static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int= low, int high) { - struct rcar_gen3_thermal_tsc *tsc =3D tz->devdata; + struct rcar_gen3_thermal_tsc *tsc =3D thermal_zone_device_get_data(tz); u32 irqmsk =3D 0; =20 if (low !=3D -INT_MAX) { diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 436f5f9cf729..538ed6731589 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -101,7 +101,6 @@ struct rcar_thermal_priv { list_for_each_entry(pos, &common->head, list) =20 #define MCELSIUS(temp) ((temp) * 1000) -#define rcar_zone_to_priv(zone) ((zone)->devdata) #define rcar_priv_to_dev(priv) ((priv)->common->dev) #define rcar_has_irq_support(priv) ((priv)->common->base) #define rcar_id_to_shift(priv) ((priv)->id * 8) @@ -273,7 +272,7 @@ static int rcar_thermal_get_current_temp(struct rcar_th= ermal_priv *priv, =20 static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *te= mp) { - struct rcar_thermal_priv *priv =3D rcar_zone_to_priv(zone); + struct rcar_thermal_priv *priv =3D thermal_zone_device_get_data(zone); =20 return rcar_thermal_get_current_temp(priv, temp); } diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_= thermal.c index 4b7c43f34d1a..dafbdbb7c0c0 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -1213,7 +1213,7 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(= int irq, void *dev) =20 static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int = low, int high) { - struct rockchip_thermal_sensor *sensor =3D tz->devdata; + struct rockchip_thermal_sensor *sensor =3D thermal_zone_device_get_data(t= z); struct rockchip_thermal_data *thermal =3D sensor->thermal; const struct rockchip_tsadc_chip *tsadc =3D thermal->chip; =20 @@ -1226,7 +1226,7 @@ static int rockchip_thermal_set_trips(struct thermal_= zone_device *tz, int low, i =20 static int rockchip_thermal_get_temp(struct thermal_zone_device *tz, int *= out_temp) { - struct rockchip_thermal_sensor *sensor =3D tz->devdata; + struct rockchip_thermal_sensor *sensor =3D thermal_zone_device_get_data(t= z); struct rockchip_thermal_data *thermal =3D sensor->thermal; const struct rockchip_tsadc_chip *tsadc =3D sensor->thermal->chip; int retval; diff --git a/drivers/thermal/rzg2l_thermal.c b/drivers/thermal/rzg2l_therma= l.c index 2e0649f38506..d3ba2a74e42d 100644 --- a/drivers/thermal/rzg2l_thermal.c +++ b/drivers/thermal/rzg2l_thermal.c @@ -75,7 +75,7 @@ static inline void rzg2l_thermal_write(struct rzg2l_therm= al_priv *priv, u32 reg, =20 static int rzg2l_thermal_get_temp(struct thermal_zone_device *tz, int *tem= p) { - struct rzg2l_thermal_priv *priv =3D tz->devdata; + struct rzg2l_thermal_priv *priv =3D thermal_zone_device_get_data(tz); u32 result =3D 0, dsensor, ts_code_ave; int val, i; =20 diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 527d1eb0663a..a2301e235a2b 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -645,7 +645,7 @@ static void exynos7_tmu_control(struct platform_device = *pdev, bool on) =20 static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) { - struct exynos_tmu_data *data =3D tz->devdata; + struct exynos_tmu_data *data =3D thermal_zone_device_get_data(tz); int value, ret =3D 0; =20 if (!data || !data->tmu_read) @@ -723,7 +723,7 @@ static void exynos4412_tmu_set_emulation(struct exynos_= tmu_data *data, =20 static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int te= mp) { - struct exynos_tmu_data *data =3D tz->devdata; + struct exynos_tmu_data *data =3D thermal_zone_device_get_data(tz); int ret =3D -EINVAL; =20 if (data->soc =3D=3D SOC_ARCH_EXYNOS4210) diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_therma= l.c index 6a722b10d738..62cd9305eb9c 100644 --- a/drivers/thermal/spear_thermal.c +++ b/drivers/thermal/spear_thermal.c @@ -31,7 +31,7 @@ struct spear_thermal_dev { static inline int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) { - struct spear_thermal_dev *stdev =3D thermal->devdata; + struct spear_thermal_dev *stdev =3D thermal_zone_device_get_data(thermal); =20 /* * Data are ready to be read after 628 usec from POWERDOWN signal @@ -48,7 +48,7 @@ static struct thermal_zone_device_ops ops =3D { static int __maybe_unused spear_thermal_suspend(struct device *dev) { struct thermal_zone_device *spear_thermal =3D dev_get_drvdata(dev); - struct spear_thermal_dev *stdev =3D spear_thermal->devdata; + struct spear_thermal_dev *stdev =3D thermal_zone_device_get_data(spear_th= ermal); unsigned int actual_mask =3D 0; =20 /* Disable SPEAr Thermal Sensor */ @@ -64,7 +64,7 @@ static int __maybe_unused spear_thermal_suspend(struct de= vice *dev) static int __maybe_unused spear_thermal_resume(struct device *dev) { struct thermal_zone_device *spear_thermal =3D dev_get_drvdata(dev); - struct spear_thermal_dev *stdev =3D spear_thermal->devdata; + struct spear_thermal_dev *stdev =3D thermal_zone_device_get_data(spear_th= ermal); unsigned int actual_mask =3D 0; int ret =3D 0; =20 @@ -154,7 +154,7 @@ static int spear_thermal_exit(struct platform_device *p= dev) { unsigned int actual_mask =3D 0; struct thermal_zone_device *spear_thermal =3D platform_get_drvdata(pdev); - struct spear_thermal_dev *stdev =3D spear_thermal->devdata; + struct spear_thermal_dev *stdev =3D thermal_zone_device_get_data(spear_th= ermal); =20 thermal_zone_device_unregister(spear_thermal); =20 diff --git a/drivers/thermal/sprd_thermal.c b/drivers/thermal/sprd_thermal.c index ac884514f116..69078a55dc0c 100644 --- a/drivers/thermal/sprd_thermal.c +++ b/drivers/thermal/sprd_thermal.c @@ -206,7 +206,7 @@ static int sprd_thm_temp_to_rawdata(int temp, struct sp= rd_thermal_sensor *sen) =20 static int sprd_thm_read_temp(struct thermal_zone_device *tz, int *temp) { - struct sprd_thermal_sensor *sen =3D tz->devdata; + struct sprd_thermal_sensor *sen =3D thermal_zone_device_get_data(tz); u32 data; =20 data =3D readl(sen->data->base + SPRD_THM_TEMP(sen->id)) & diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_therma= l.c index 497beac63e5d..085b7b0b7c72 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -110,7 +110,7 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev, =20 static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp) { - struct tsensor *s =3D tz->devdata; + struct tsensor *s =3D thermal_zone_device_get_data(tz); struct ths_device *tmdev =3D s->tmdev; int val =3D 0; =20 diff --git a/drivers/thermal/tegra/tegra-bpmp-thermal.c b/drivers/thermal/t= egra/tegra-bpmp-thermal.c index 0b7a1a1948cb..31a660b009fc 100644 --- a/drivers/thermal/tegra/tegra-bpmp-thermal.c +++ b/drivers/thermal/tegra/tegra-bpmp-thermal.c @@ -62,12 +62,14 @@ static int __tegra_bpmp_thermal_get_temp(struct tegra_b= pmp_thermal_zone *zone, =20 static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int= *out_temp) { - return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp); + struct tegra_bpmp_thermal_zone *zone =3D thermal_zone_device_get_data(tz); +=09 + return __tegra_bpmp_thermal_get_temp(zone, out_temp); } =20 static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, in= t low, int high) { - struct tegra_bpmp_thermal_zone *zone =3D tz->devdata; + struct tegra_bpmp_thermal_zone *zone =3D thermal_zone_device_get_data(tz); struct mrq_thermal_host_to_bpmp_request req; struct tegra_bpmp_message msg; int err; diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index b3218b71b6d9..537413acc6d2 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -160,7 +160,7 @@ static void devm_tegra_tsensor_hw_disable(void *data) =20 static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *tem= p) { - const struct tegra_tsensor_channel *tsc =3D tz->devdata; + const struct tegra_tsensor_channel *tsc =3D thermal_zone_device_get_data(= tz); const struct tegra_tsensor *ts =3D tsc->ts; int err, c1, c2, c3, c4, counter; u32 val; @@ -218,7 +218,7 @@ static int tegra_tsensor_temp_to_counter(const struct t= egra_tsensor *ts, int tem =20 static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low= , int high) { - const struct tegra_tsensor_channel *tsc =3D tz->devdata; + const struct tegra_tsensor_channel *tsc =3D thermal_zone_device_get_data(= tz); const struct tegra_tsensor *ts =3D tsc->ts; u32 val; =20 diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/therma= l-generic-adc.c index 323e273e3298..8e2ff0df7e64 100644 --- a/drivers/thermal/thermal-generic-adc.c +++ b/drivers/thermal/thermal-generic-adc.c @@ -54,7 +54,7 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_i= nfo *gti, int val) =20 static int gadc_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { - struct gadc_thermal_info *gti =3D tz->devdata; + struct gadc_thermal_info *gti =3D thermal_zone_device_get_data(tz); int val; int ret; =20 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 0675df54c8e6..05e5a6bda695 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1378,6 +1378,12 @@ struct thermal_zone_device *thermal_zone_device_regi= ster(const char *type, int n } EXPORT_SYMBOL_GPL(thermal_zone_device_register); =20 +void *thermal_zone_device_get_data(struct thermal_zone_device *tzd) +{ + return tzd->devdata; +} +EXPORT_SYMBOL_GPL(thermal_zone_device_get_data); + /** * thermal_zone_device_unregister - removes the registered thermal zone de= vice * @tz: the thermal zone device to remove diff --git a/drivers/thermal/thermal_mmio.c b/drivers/thermal/thermal_mmio.c index ea616731066c..05a70205f86f 100644 --- a/drivers/thermal/thermal_mmio.c +++ b/drivers/thermal/thermal_mmio.c @@ -23,7 +23,7 @@ static u32 thermal_mmio_readb(void __iomem *mmio_base) static int thermal_mmio_get_temperature(struct thermal_zone_device *tz, in= t *temp) { int t; - struct thermal_mmio *sensor =3D tz->devdata; + struct thermal_mmio *sensor =3D thermal_zone_device_get_data(tz); =20 t =3D sensor->read_mmio(sensor->mmio_base) & sensor->mask; t *=3D sensor->factor; diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/t= hermal/ti-soc-thermal/ti-thermal-common.c index 8a9055bd376e..7f6b71d11eed 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -68,7 +68,7 @@ static inline int ti_thermal_hotspot_temperature(int t, i= nt s, int c) static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, in= t *temp) { struct thermal_zone_device *pcb_tz =3D NULL; - struct ti_thermal_data *data =3D tz->devdata; + struct ti_thermal_data *data =3D thermal_zone_device_get_data(tz); struct ti_bandgap *bgp; const struct ti_temp_sensor *s; int ret, tmp, slope, constant; @@ -109,7 +109,7 @@ static inline int __ti_thermal_get_temp(struct thermal_= zone_device *tz, int *tem =20 static int __ti_thermal_get_trend(struct thermal_zone_device *tz, int trip= , enum thermal_trend *trend) { - struct ti_thermal_data *data =3D tz->devdata; + struct ti_thermal_data *data =3D thermal_zone_device_get_data(tz); struct ti_bandgap *bgp; int id, tr, ret =3D 0; =20 diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_= thermal.c index 47801841b3f5..25247de7780c 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -187,7 +187,7 @@ static void uniphier_tm_disable_sensor(struct uniphier_= tm_dev *tdev) =20 static int uniphier_tm_get_temp(struct thermal_zone_device *tz, int *out_t= emp) { - struct uniphier_tm_dev *tdev =3D tz->devdata; + struct uniphier_tm_dev *tdev =3D thermal_zone_device_get_data(tz); struct regmap *map =3D tdev->regmap; int ret; u32 temp; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 2bb4bf33f4f3..724b95662da9 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -365,6 +365,8 @@ thermal_zone_device_register_with_trips(const char *, s= truct thermal_trip *, int void *, struct thermal_zone_device_ops *, struct thermal_zone_params *, int, int); =20 +void *thermal_zone_device_get_data(struct thermal_zone_device *tzd); + int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *, unsigned long, unsigned long, --=20 2.34.1