Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/core: Use the thermal zone 'devdata' accessor in remaining drivers

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>

authored by

Daniel Lezcano and committed by
Rafael J. Wysocki
3d4e1bad 0ce637a5

+23 -23
+8 -8
drivers/acpi/thermal.c
··· 498 498 499 499 static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) 500 500 { 501 - struct acpi_thermal *tz = thermal->devdata; 501 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 502 502 int result; 503 503 504 504 if (!tz) ··· 516 516 static int thermal_get_trip_type(struct thermal_zone_device *thermal, 517 517 int trip, enum thermal_trip_type *type) 518 518 { 519 - struct acpi_thermal *tz = thermal->devdata; 519 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 520 520 int i; 521 521 522 522 if (!tz || trip < 0) ··· 560 560 static int thermal_get_trip_temp(struct thermal_zone_device *thermal, 561 561 int trip, int *temp) 562 562 { 563 - struct acpi_thermal *tz = thermal->devdata; 563 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 564 564 int i; 565 565 566 566 if (!tz || trip < 0) ··· 613 613 static int thermal_get_crit_temp(struct thermal_zone_device *thermal, 614 614 int *temperature) 615 615 { 616 - struct acpi_thermal *tz = thermal->devdata; 616 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 617 617 618 618 if (tz->trips.critical.flags.valid) { 619 619 *temperature = deci_kelvin_to_millicelsius_with_offset( ··· 628 628 static int thermal_get_trend(struct thermal_zone_device *thermal, 629 629 int trip, enum thermal_trend *trend) 630 630 { 631 - struct acpi_thermal *tz = thermal->devdata; 631 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 632 632 enum thermal_trip_type type; 633 633 int i; 634 634 ··· 670 670 671 671 static void acpi_thermal_zone_device_hot(struct thermal_zone_device *thermal) 672 672 { 673 - struct acpi_thermal *tz = thermal->devdata; 673 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 674 674 675 675 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 676 676 dev_name(&tz->device->dev), ··· 679 679 680 680 static void acpi_thermal_zone_device_critical(struct thermal_zone_device *thermal) 681 681 { 682 - struct acpi_thermal *tz = thermal->devdata; 682 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 683 683 684 684 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 685 685 dev_name(&tz->device->dev), ··· 693 693 bool bind) 694 694 { 695 695 struct acpi_device *device = cdev->devdata; 696 - struct acpi_thermal *tz = thermal->devdata; 696 + struct acpi_thermal *tz = thermal_zone_device_priv(thermal); 697 697 struct acpi_device *dev; 698 698 acpi_handle handle; 699 699 int i;
+1 -1
drivers/ata/ahci_imx.c
··· 418 418 419 419 static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp) 420 420 { 421 - return __sata_ahci_read_temperature(tz->devdata, temp); 421 + return __sata_ahci_read_temperature(thermal_zone_device_priv(tz), temp); 422 422 } 423 423 424 424 static ssize_t sata_ahci_show_temp(struct device *dev,
+1 -1
drivers/iio/adc/sun4i-gpadc-iio.c
··· 414 414 415 415 static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp) 416 416 { 417 - struct sun4i_gpadc_iio *info = tz->devdata; 417 + struct sun4i_gpadc_iio *info = thermal_zone_device_priv(tz); 418 418 int val, scale, offset; 419 419 420 420 if (sun4i_gpadc_temp_read(info->indio_dev, &val))
+1 -1
drivers/input/touchscreen/sun4i-ts.c
··· 194 194 195 195 static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp) 196 196 { 197 - return sun4i_get_temp(tz->devdata, temp); 197 + return sun4i_get_temp(thermal_zone_device_priv(tz), temp); 198 198 } 199 199 200 200 static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
+1 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
··· 12 12 static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev, 13 13 int *temp) 14 14 { 15 - struct adapter *adap = tzdev->devdata; 15 + struct adapter *adap = thermal_zone_device_priv(tzdev); 16 16 u32 param, val; 17 17 int ret; 18 18
+7 -7
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
··· 201 201 static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev, 202 202 struct thermal_cooling_device *cdev) 203 203 { 204 - struct mlxsw_thermal *thermal = tzdev->devdata; 204 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 205 205 struct device *dev = thermal->bus_info->dev; 206 206 int i, err; 207 207 ··· 227 227 static int mlxsw_thermal_unbind(struct thermal_zone_device *tzdev, 228 228 struct thermal_cooling_device *cdev) 229 229 { 230 - struct mlxsw_thermal *thermal = tzdev->devdata; 230 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 231 231 struct device *dev = thermal->bus_info->dev; 232 232 int i; 233 233 int err; ··· 249 249 static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev, 250 250 int *p_temp) 251 251 { 252 - struct mlxsw_thermal *thermal = tzdev->devdata; 252 + struct mlxsw_thermal *thermal = thermal_zone_device_priv(tzdev); 253 253 struct device *dev = thermal->bus_info->dev; 254 254 char mtmp_pl[MLXSW_REG_MTMP_LEN]; 255 255 int temp; ··· 281 281 static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev, 282 282 struct thermal_cooling_device *cdev) 283 283 { 284 - struct mlxsw_thermal_module *tz = tzdev->devdata; 284 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 285 285 struct mlxsw_thermal *thermal = tz->parent; 286 286 int i, j, err; 287 287 ··· 310 310 static int mlxsw_thermal_module_unbind(struct thermal_zone_device *tzdev, 311 311 struct thermal_cooling_device *cdev) 312 312 { 313 - struct mlxsw_thermal_module *tz = tzdev->devdata; 313 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 314 314 struct mlxsw_thermal *thermal = tz->parent; 315 315 int i; 316 316 int err; ··· 356 356 static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev, 357 357 int *p_temp) 358 358 { 359 - struct mlxsw_thermal_module *tz = tzdev->devdata; 359 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 360 360 struct mlxsw_thermal *thermal = tz->parent; 361 361 int temp, crit_temp, emerg_temp; 362 362 struct device *dev; ··· 391 391 static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev, 392 392 int *p_temp) 393 393 { 394 - struct mlxsw_thermal_module *tz = tzdev->devdata; 394 + struct mlxsw_thermal_module *tz = thermal_zone_device_priv(tzdev); 395 395 struct mlxsw_thermal *thermal = tz->parent; 396 396 char mtmp_pl[MLXSW_REG_MTMP_LEN]; 397 397 u16 index;
+2 -2
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
··· 615 615 static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, 616 616 int *temperature) 617 617 { 618 - struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; 618 + struct iwl_mvm *mvm = thermal_zone_device_priv(device); 619 619 int ret; 620 620 int temp; 621 621 ··· 641 641 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, 642 642 int trip, int temp) 643 643 { 644 - struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; 644 + struct iwl_mvm *mvm = thermal_zone_device_priv(device); 645 645 struct iwl_mvm_thermal_device *tzone; 646 646 int ret; 647 647
+1 -1
drivers/power/supply/power_supply_core.c
··· 1142 1142 int ret; 1143 1143 1144 1144 WARN_ON(tzd == NULL); 1145 - psy = tzd->devdata; 1145 + psy = thermal_zone_device_priv(tzd); 1146 1146 ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); 1147 1147 if (ret) 1148 1148 return ret;
+1 -1
drivers/regulator/max8973-regulator.c
··· 436 436 437 437 static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp) 438 438 { 439 - struct max8973_chip *mchip = tz->devdata; 439 + struct max8973_chip *mchip = thermal_zone_device_priv(tz); 440 440 unsigned int val; 441 441 int ret; 442 442