thermal/core: Use the thermal zone 'devdata' accessor in remaining drivers
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:32 +0000 (21:14 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 3 Mar 2023 19:45:02 +0000 (20:45 +0100)
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.

Use the devdata accessor introduced in the previous patch.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com> #mlxsw
Acked-by: Gregory Greenman <gregory.greenman@intel.com> #iwlwifi
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> #power_supply
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> #ahci
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/thermal.c
drivers/ata/ahci_imx.c
drivers/iio/adc/sun4i-gpadc-iio.c
drivers/input/touchscreen/sun4i-ts.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
drivers/power/supply/power_supply_core.c
drivers/regulator/max8973-regulator.c

index 0b4b844f9d4cb63fc8c5838aeb69155db600da11..392b73b3e26959754b6601e11fce9b03f041dd5b 100644 (file)
@@ -498,7 +498,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
 
 static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
        int result;
 
        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 = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
        int i;
 
        if (!tz || trip < 0)
@@ -560,7 +560,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
 static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
                                 int trip, int *temp)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
        int i;
 
        if (!tz || trip < 0)
@@ -613,7 +613,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
 static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
                                int *temperature)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
 
        if (tz->trips.critical.flags.valid) {
                *temperature = deci_kelvin_to_millicelsius_with_offset(
@@ -628,7 +628,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
 static int thermal_get_trend(struct thermal_zone_device *thermal,
                             int trip, enum thermal_trend *trend)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
        enum thermal_trip_type type;
        int i;
 
@@ -670,7 +670,7 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
 
 static void acpi_thermal_zone_device_hot(struct thermal_zone_device *thermal)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
 
        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)
 
 static void acpi_thermal_zone_device_critical(struct thermal_zone_device *thermal)
 {
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
 
        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 thermal_zone_device *thermal,
                                          bool bind)
 {
        struct acpi_device *device = cdev->devdata;
-       struct acpi_thermal *tz = thermal->devdata;
+       struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
        struct acpi_device *dev;
        acpi_handle handle;
        int i;
index a950767f794839046ef2fb8915bcd72cf1b1a7fe..e45e91f5e703530ce23d2405aa3f9de3983e6815 100644 (file)
@@ -418,7 +418,7 @@ static int __sata_ahci_read_temperature(void *dev, int *temp)
 
 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_priv(tz), temp);
 }
 
 static ssize_t sata_ahci_show_temp(struct device *dev,
index a6ade70dedf89fbfc9b97b14a6a4ce5edf78de33..a5322550c4225132abf2d7c6037af3303b72578e 100644 (file)
@@ -414,7 +414,7 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)
 
 static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct sun4i_gpadc_iio *info = tz->devdata;
+       struct sun4i_gpadc_iio *info = thermal_zone_device_priv(tz);
        int val, scale, offset;
 
        if (sun4i_gpadc_temp_read(info->indio_dev, &val))
index 73eb8f80be6ef369143e1755c67574bcae3db81f..1117fba30020d0f6719062157953ab05cf9e61b7 100644 (file)
@@ -194,7 +194,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
 
 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_priv(tz), temp);
 }
 
 static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
index 95e1b415ba132e41069ba3e664f2710cc3b8e546..dea9d290766671ca8c3953aeca42a7ef9983bf91 100644 (file)
@@ -12,7 +12,7 @@
 static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev,
                                  int *temp)
 {
-       struct adapter *adap = tzdev->devdata;
+       struct adapter *adap = thermal_zone_device_priv(tzdev);
        u32 param, val;
        int ret;
 
index c5240d38c9dbd83ca87f4b8802144cb7ed4a2018..722e4a40afefb0c86fa264e5474a6dd40bbee5a6 100644 (file)
@@ -201,7 +201,7 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
 static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
                              struct thermal_cooling_device *cdev)
 {
-       struct mlxsw_thermal *thermal = tzdev->devdata;
+       struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);
        struct device *dev = thermal->bus_info->dev;
        int i, err;
 
@@ -227,7 +227,7 @@ static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
 static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,
                                struct thermal_cooling_device *cdev)
 {
-       struct mlxsw_thermal *thermal = tzdev->devdata;
+       struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);
        struct device *dev = thermal->bus_info->dev;
        int i;
        int err;
@@ -249,7 +249,7 @@ static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev,
 static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
                                  int *p_temp)
 {
-       struct mlxsw_thermal *thermal = tzdev->devdata;
+       struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev);
        struct device *dev = 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 = {
 static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
                                     struct thermal_cooling_device *cdev)
 {
-       struct mlxsw_thermal_module *tz = tzdev->devdata;
+       struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);
        struct mlxsw_thermal *thermal = tz->parent;
        int i, j, err;
 
@@ -310,7 +310,7 @@ err_thermal_zone_bind_cooling_device:
 static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev,
                                       struct thermal_cooling_device *cdev)
 {
-       struct mlxsw_thermal_module *tz = tzdev->devdata;
+       struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);
        struct mlxsw_thermal *thermal = tz->parent;
        int i;
        int err;
@@ -356,7 +356,7 @@ mlxsw_thermal_module_temp_and_thresholds_get(struct mlxsw_core *core,
 static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
                                         int *p_temp)
 {
-       struct mlxsw_thermal_module *tz = tzdev->devdata;
+       struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);
        struct mlxsw_thermal *thermal = tz->parent;
        int temp, crit_temp, emerg_temp;
        struct device *dev;
@@ -391,7 +391,7 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
 static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
                                          int *p_temp)
 {
-       struct mlxsw_thermal_module *tz = tzdev->devdata;
+       struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev);
        struct mlxsw_thermal *thermal = tz->parent;
        char mtmp_pl[MLXSW_REG_MTMP_LEN];
        u16 index;
index 232c200af38fcfec2bf82b7fd562df2fce41431c..354d95222b1beb512304734491e42fa16c2e2544 100644 (file)
@@ -615,7 +615,7 @@ send:
 static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
                                  int *temperature)
 {
-       struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+       struct iwl_mvm *mvm = thermal_zone_device_priv(device);
        int ret;
        int temp;
 
@@ -641,7 +641,7 @@ out:
 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
                                       int trip, int temp)
 {
-       struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
+       struct iwl_mvm *mvm = thermal_zone_device_priv(device);
        struct iwl_mvm_thermal_device *tzone;
        int ret;
 
index cc5b2e22b42ac277913490a9e3e54bc0175ee05a..ecb571842c181f3fadd0616dcd880ef32ba92e8d 100644 (file)
@@ -1142,7 +1142,7 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,
        int ret;
 
        WARN_ON(tzd == NULL);
-       psy = tzd->devdata;
+       psy = thermal_zone_device_priv(tzd);
        ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
        if (ret)
                return ret;
index 7e00a45db26a31cfb048c05c45a445b100919a8d..303426135276dfb667588c6cfbd93b7795f3e5af 100644 (file)
@@ -436,7 +436,7 @@ static int max8973_init_dcdc(struct max8973_chip *max,
 
 static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
 {
-       struct max8973_chip *mchip = tz->devdata;
+       struct max8973_chip *mchip = thermal_zone_device_priv(tz);
        unsigned int val;
        int ret;