Thermal zone devices currently have no parent device, potentially causing issues with suspend ordering and making it impossible for user space appications to associate a given thermal zone device with its parent device.
Extend the functions used to register thermal zone devices to also accept a parent device pointer. Also update all users of those functions to provide a parent device pointer if available. Signed-off-by: Armin Wolf <[email protected]> --- Documentation/driver-api/thermal/sysfs-api.rst | 5 ++- drivers/acpi/thermal.c | 16 +++++--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c | 4 +- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 45 +++++++++++----------- drivers/net/wireless/intel/iwlwifi/mld/thermal.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++--- drivers/platform/x86/acerhdf.c | 2 +- drivers/power/supply/power_supply_core.c | 4 +- drivers/thermal/armada_thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 2 +- .../intel/int340x_thermal/int3400_thermal.c | 2 +- .../intel/int340x_thermal/int340x_thermal_zone.c | 13 +++---- .../int340x_thermal/processor_thermal_device_pci.c | 7 ++-- drivers/thermal/intel/intel_pch_thermal.c | 2 +- drivers/thermal/intel/intel_quark_dts_thermal.c | 2 +- drivers/thermal/intel/intel_soc_dts_iosf.c | 2 +- drivers/thermal/intel/x86_pkg_temp_thermal.c | 6 +-- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/renesas/rcar_thermal.c | 10 +++-- drivers/thermal/spear_thermal.c | 2 +- drivers/thermal/testing/zone.c | 2 +- drivers/thermal/thermal_core.c | 7 +++- drivers/thermal/thermal_of.c | 9 +++-- include/linux/thermal.h | 4 ++ 26 files changed, 92 insertions(+), 74 deletions(-) diff --git a/Documentation/driver-api/thermal/sysfs-api.rst b/Documentation/driver-api/thermal/sysfs-api.rst index cf242cd16f2e..0a29bc949ef3 100644 --- a/Documentation/driver-api/thermal/sysfs-api.rst +++ b/Documentation/driver-api/thermal/sysfs-api.rst @@ -37,7 +37,8 @@ temperature) and throttle appropriate devices. :: struct thermal_zone_device * - thermal_zone_device_register_with_trips(const char *type, + thermal_zone_device_register_with_trips(struct device *parent, + const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, @@ -49,6 +50,8 @@ temperature) and throttle appropriate devices. /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the thermal cooling devices registered to it at the same time. + parent: + parent device pointer. type: the thermal zone type. trips: diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 99ad67bbd764..483e28ce0d67 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -607,16 +607,20 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz, unsigned int trip_count, int passive_delay) { + unsigned int polling_delay = tz->polling_frequency * 100; int result; if (trip_count) - tz->thermal_zone = thermal_zone_device_register_with_trips( - "acpitz", trip_table, trip_count, tz, - &acpi_thermal_zone_ops, NULL, passive_delay, - tz->polling_frequency * 100); + tz->thermal_zone = thermal_zone_device_register_with_trips(&tz->device->dev, + "acpitz", trip_table, + trip_count, tz, + &acpi_thermal_zone_ops, + NULL, passive_delay, + polling_delay); else - tz->thermal_zone = thermal_tripless_zone_device_register( - "acpitz", tz, &acpi_thermal_zone_ops, NULL); + tz->thermal_zone = thermal_tripless_zone_device_register(&tz->device->dev, "acpitz", + tz, &acpi_thermal_zone_ops, + NULL); if (IS_ERR(tz->thermal_zone)) return PTR_ERR(tz->thermal_zone); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 7bab8da8f6e6..05a1ec7df7a5 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c @@ -59,8 +59,8 @@ int cxgb4_thermal_init(struct adapter *adap) } snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name); - ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip, - adap, + ch_thermal->tzdev = thermal_zone_device_register_with_trips(adap->pdev_dev, ch_tz_name, + &trip, num_trip, adap, &cxgb4_thermal_ops, NULL, 0, 0); if (IS_ERR(ch_thermal->tzdev)) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index 1117d59b74fd..a1b1e9e8dd3d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -349,6 +349,8 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = { static int mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) { + unsigned int polling_delay = module_tz->parent->polling_delay; + struct device *dev = module_tz->parent->bus_info->dev; char tz_name[40]; int err; @@ -358,14 +360,12 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) else snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", module_tz->module + 1); - module_tz->tzdev = thermal_zone_device_register_with_trips(tz_name, - module_tz->trips, - MLXSW_THERMAL_NUM_TRIPS, - module_tz, - &mlxsw_thermal_module_ops, - &mlxsw_thermal_params, - 0, - module_tz->parent->polling_delay); + module_tz->tzdev = thermal_zone_device_register_with_trips(dev, tz_name, module_tz->trips, + MLXSW_THERMAL_NUM_TRIPS, + module_tz, + &mlxsw_thermal_module_ops, + &mlxsw_thermal_params, 0, + polling_delay); if (IS_ERR(module_tz->tzdev)) { err = PTR_ERR(module_tz->tzdev); return err; @@ -466,6 +466,8 @@ mlxsw_thermal_modules_fini(struct mlxsw_thermal *thermal, static int mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) { + unsigned int polling_delay = gearbox_tz->parent->polling_delay; + struct device *dev = gearbox_tz->parent->bus_info->dev; char tz_name[40]; int ret; @@ -475,13 +477,13 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) else snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", gearbox_tz->module + 1); - gearbox_tz->tzdev = thermal_zone_device_register_with_trips(tz_name, - gearbox_tz->trips, - MLXSW_THERMAL_NUM_TRIPS, - gearbox_tz, - &mlxsw_thermal_gearbox_ops, - &mlxsw_thermal_params, 0, - gearbox_tz->parent->polling_delay); + gearbox_tz->tzdev = thermal_zone_device_register_with_trips(dev, tz_name, + gearbox_tz->trips, + MLXSW_THERMAL_NUM_TRIPS, + gearbox_tz, + &mlxsw_thermal_gearbox_ops, + &mlxsw_thermal_params, 0, + polling_delay); if (IS_ERR(gearbox_tz->tzdev)) return PTR_ERR(gearbox_tz->tzdev); @@ -709,13 +711,12 @@ int mlxsw_thermal_init(struct mlxsw_core *core, MLXSW_THERMAL_SLOW_POLL_INT : MLXSW_THERMAL_POLL_INT; - thermal->tzdev = thermal_zone_device_register_with_trips("mlxsw", - thermal->trips, - MLXSW_THERMAL_NUM_TRIPS, - thermal, - &mlxsw_thermal_ops, - &mlxsw_thermal_params, 0, - thermal->polling_delay); + thermal->tzdev = thermal_zone_device_register_with_trips(dev, "mlxsw", + thermal->trips, + MLXSW_THERMAL_NUM_TRIPS, + thermal, &mlxsw_thermal_ops, + &mlxsw_thermal_params, 0, + thermal->polling_delay); if (IS_ERR(thermal->tzdev)) { err = PTR_ERR(thermal->tzdev); dev_err(dev, "Failed to register thermal zone\n"); diff --git a/drivers/net/wireless/intel/iwlwifi/mld/thermal.c b/drivers/net/wireless/intel/iwlwifi/mld/thermal.c index 9e56e6e80ab7..56a0022d33db 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/thermal.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/thermal.c @@ -256,7 +256,7 @@ static void iwl_mld_thermal_zone_register(struct iwl_mld *mld) sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF); mld->tzone = - thermal_zone_device_register_with_trips(name, trips, + thermal_zone_device_register_with_trips(mld->dev, name, trips, IWL_MAX_DTS_TRIPS, mld, &tzone_ops, NULL, 0, 0); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c index b184f08230b9..e4777b815976 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c @@ -672,11 +672,11 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP; } - mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, - mvm->tz_device.trips, - IWL_MAX_DTS_TRIPS, - mvm, &tzone_ops, - NULL, 0, 0); + mvm->tz_device.tzone = thermal_zone_device_register_with_trips(mvm->dev, name, + mvm->tz_device.trips, + IWL_MAX_DTS_TRIPS, + mvm, &tzone_ops, + NULL, 0, 0); if (IS_ERR(mvm->tz_device.tzone)) { IWL_DEBUG_TEMP(mvm, "Failed to register to thermal zone (err = %ld)\n", diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index c74937d475e5..abdb5749c169 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -656,7 +656,7 @@ static int __init acerhdf_register_thermal(void) if (IS_ERR(cl_dev)) return -EINVAL; - thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips), + thz_dev = thermal_zone_device_register_with_trips(NULL, "acerhdf", trips, ARRAY_SIZE(trips), NULL, &acerhdf_dev_ops, &acerhdf_zone_params, 0, (kernelmode) ? interval*1000 : 0); diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 9a28381e2607..cbc4bed17efa 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1531,8 +1531,8 @@ static int psy_register_thermal(struct power_supply *psy) struct thermal_zone_params tzp = { .no_hwmon = IS_ENABLED(CONFIG_POWER_SUPPLY_HWMON) }; - psy->tzd = thermal_tripless_zone_device_register(psy->desc->name, - psy, &psy_tzd_ops, &tzp); + psy->tzd = thermal_tripless_zone_device_register(&psy->dev, psy->desc->name, psy, + &psy_tzd_ops, &tzp); if (IS_ERR(psy->tzd)) return PTR_ERR(psy->tzd); ret = thermal_zone_device_enable(psy->tzd); diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index c2fbdb534f61..fc60b0bab627 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -871,7 +871,7 @@ static int armada_thermal_probe(struct platform_device *pdev) /* Wait the sensors to be valid */ armada_wait_sensor_validity(priv); - tz = thermal_tripless_zone_device_register(priv->zone_name, + tz = thermal_tripless_zone_device_register(&pdev->dev, priv->zone_name, priv, &legacy_ops, NULL); if (IS_ERR(tz)) { diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c index a8d4b766ba21..c5368c2b53b9 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -196,7 +196,7 @@ static int da9062_thermal_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); mutex_init(&thermal->lock); - thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name, + thermal->zone = thermal_zone_device_register_with_trips(&pdev->dev, thermal->config->name, trips, ARRAY_SIZE(trips), thermal, &da9062_thermal_ops, NULL, pp_tmp, 0); diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c index 723bc72f0626..101c6109b04a 100644 --- a/drivers/thermal/dove_thermal.c +++ b/drivers/thermal/dove_thermal.c @@ -139,7 +139,7 @@ static int dove_thermal_probe(struct platform_device *pdev) return ret; } - thermal = thermal_tripless_zone_device_register("dove_thermal", priv, + thermal = thermal_tripless_zone_device_register(&pdev->dev, "dove_thermal", priv, &ops, NULL); if (IS_ERR(thermal)) { dev_err(&pdev->dev, diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 38c993d1bcb3..043e80756017 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -679,7 +679,7 @@ static int imx_thermal_probe(struct platform_device *pdev) goto legacy_cleanup; } - data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone", + data->tz = thermal_zone_device_register_with_trips(dev, "imx_thermal_zone", trips, ARRAY_SIZE(trips), data, diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 41d3bc3ed8a2..ed21da8f0a47 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -594,7 +594,7 @@ static int int3400_thermal_probe(struct platform_device *pdev) evaluate_odvp(priv); - priv->thermal = thermal_tripless_zone_device_register("INT3400 Thermal", priv, + priv->thermal = thermal_tripless_zone_device_register(&pdev->dev, "INT3400 Thermal", priv, &int3400_thermal_ops, &int3400_thermal_params); if (IS_ERR(priv->thermal)) { diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 3d9efe69d562..3adccb7fc157 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -160,13 +160,12 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, int34x_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle); - int34x_zone->zone = thermal_zone_device_register_with_trips( - acpi_device_bid(adev), - zone_trips, trip_cnt, - int34x_zone, - &zone_ops, - &int340x_thermal_params, - 0, 0); + int34x_zone->zone = thermal_zone_device_register_with_trips(&adev->dev, + acpi_device_bid(adev), + zone_trips, trip_cnt, + int34x_zone, &zone_ops, + &int340x_thermal_params, + 0, 0); kfree(zone_trips); if (IS_ERR(int34x_zone->zone)) { diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c index 0d4dcc66e097..2b3116e23fa1 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c @@ -371,10 +371,9 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_ psv_trip.temperature = get_trip_temp(pci_info); - pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip, - 1, pci_info, - &tzone_ops, - &tzone_params, 0, 0); + pci_info->tzone = thermal_zone_device_register_with_trips(&pdev->dev, "TCPU_PCI", &psv_trip, + 1, pci_info, &tzone_ops, + &tzone_params, 0, 0); if (IS_ERR(pci_info->tzone)) { ret = PTR_ERR(pci_info->tzone); goto err_del_legacy; diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index fc326985796c..754527b2b09a 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -235,7 +235,7 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev, nr_trips += pch_wpt_add_acpi_psv_trip(ptd, &ptd_trips[nr_trips]); - ptd->tzd = thermal_zone_device_register_with_trips(board_names[board_id], + ptd->tzd = thermal_zone_device_register_with_trips(&pdev->dev, board_names[board_id], ptd_trips, nr_trips, ptd, &tzd_ops, NULL, 0, 0); diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c index 89498eb29a89..d8d38b6ed452 100644 --- a/drivers/thermal/intel/intel_quark_dts_thermal.c +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c @@ -376,7 +376,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void) trips[QRK_DTS_ID_TP_HOT].temperature = get_trip_temp(QRK_DTS_ID_TP_HOT); trips[QRK_DTS_ID_TP_HOT].type = THERMAL_TRIP_HOT; - aux_entry->tzone = thermal_zone_device_register_with_trips("quark_dts", + aux_entry->tzone = thermal_zone_device_register_with_trips(NULL, "quark_dts", trips, QRK_MAX_DTS_TRIPS, aux_entry, diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c index ea87439fe7a9..74638dac75e6 100644 --- a/drivers/thermal/intel/intel_soc_dts_iosf.c +++ b/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -230,7 +230,7 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, } } snprintf(name, sizeof(name), "soc_dts%d", id); - dts->tzone = thermal_zone_device_register_with_trips(name, trips, + dts->tzone = thermal_zone_device_register_with_trips(NULL, name, trips, SOC_MAX_DTS_TRIPS, dts, &tzone_ops, NULL, 0, 0); diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c index 3fc679b6f11b..807126dc4bea 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -342,9 +342,9 @@ static int pkg_temp_thermal_device_add(unsigned int cpu) INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn); zonedev->cpu = cpu; - zonedev->tzone = thermal_zone_device_register_with_trips("x86_pkg_temp", - trips, thres_count, - zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0); + zonedev->tzone = thermal_zone_device_register_with_trips(NULL, "x86_pkg_temp", trips, + thres_count, zonedev, &tzone_ops, + &pkg_temp_tz_params, 0, 0); if (IS_ERR(zonedev->tzone)) { err = PTR_ERR(zonedev->tzone); goto out_kfree_zonedev; diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c index 4619e090f756..4827ad2bdb49 100644 --- a/drivers/thermal/kirkwood_thermal.c +++ b/drivers/thermal/kirkwood_thermal.c @@ -71,7 +71,7 @@ static int kirkwood_thermal_probe(struct platform_device *pdev) if (IS_ERR(priv->sensor)) return PTR_ERR(priv->sensor); - thermal = thermal_tripless_zone_device_register("kirkwood_thermal", + thermal = thermal_tripless_zone_device_register(&pdev->dev, "kirkwood_thermal", priv, &ops, NULL); if (IS_ERR(thermal)) { dev_err(&pdev->dev, diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c index fdd7afdc4ff6..3d228e4c7b09 100644 --- a/drivers/thermal/renesas/rcar_thermal.c +++ b/drivers/thermal/renesas/rcar_thermal.c @@ -488,10 +488,12 @@ static int rcar_thermal_probe(struct platform_device *pdev) dev, i, priv, &rcar_thermal_zone_ops); } else { - priv->zone = thermal_zone_device_register_with_trips( - "rcar_thermal", trips, ARRAY_SIZE(trips), priv, - &rcar_thermal_zone_ops, NULL, 0, - idle); + priv->zone = thermal_zone_device_register_with_trips(dev, "rcar_thermal", + trips, + ARRAY_SIZE(trips), + priv, + &rcar_thermal_zone_ops, + NULL, 0, idle); ret = thermal_zone_device_enable(priv->zone); if (ret) { diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c index 603dadcd3df5..c5bba9d600d4 100644 --- a/drivers/thermal/spear_thermal.c +++ b/drivers/thermal/spear_thermal.c @@ -122,7 +122,7 @@ static int spear_thermal_probe(struct platform_device *pdev) stdev->flags = val; writel_relaxed(stdev->flags, stdev->thermal_base); - spear_thermal = thermal_tripless_zone_device_register("spear_thermal", + spear_thermal = thermal_tripless_zone_device_register(&pdev->dev, "spear_thermal", stdev, &ops, NULL); if (IS_ERR(spear_thermal)) { dev_err(&pdev->dev, "thermal zone device is NULL\n"); diff --git a/drivers/thermal/testing/zone.c b/drivers/thermal/testing/zone.c index c12c405225bb..5a7e9969582e 100644 --- a/drivers/thermal/testing/zone.c +++ b/drivers/thermal/testing/zone.c @@ -402,7 +402,7 @@ static int tt_zone_register_tz(struct tt_thermal_zone *tt_zone) tt_zone->tz_temp = tt_zone->temp; - tz = thermal_zone_device_register_with_trips("test_tz", trips, i, tt_zone, + tz = thermal_zone_device_register_with_trips(NULL, "test_tz", trips, i, tt_zone, &tt_zone_ops, NULL, 0, 0); if (IS_ERR(tz)) return PTR_ERR(tz); diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 92e51d2e4535..9d8499999579 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1475,6 +1475,7 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz) /** * thermal_zone_device_register_with_trips() - register a new thermal zone device + * @parent: parent device pointer * @type: the thermal zone device type * @trips: a pointer to an array of thermal trips * @num_trips: the number of trip points the thermal zone support @@ -1498,7 +1499,7 @@ static void thermal_zone_init_complete(struct thermal_zone_device *tz) * IS_ERR*() helpers. */ struct thermal_zone_device * -thermal_zone_device_register_with_trips(const char *type, +thermal_zone_device_register_with_trips(struct device *parent, const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, @@ -1576,6 +1577,7 @@ thermal_zone_device_register_with_trips(const char *type, tz->ops.critical = thermal_zone_device_critical; tz->device.class = thermal_class; + tz->device.parent = parent; tz->devdata = devdata; tz->num_trips = num_trips; for_each_trip_desc(tz, td) { @@ -1651,12 +1653,13 @@ thermal_zone_device_register_with_trips(const char *type, EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips); struct thermal_zone_device *thermal_tripless_zone_device_register( + struct device *parent, const char *type, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp) { - return thermal_zone_device_register_with_trips(type, NULL, 0, devdata, + return thermal_zone_device_register_with_trips(parent, type, NULL, 0, devdata, ops, tzp, 0, 0); } EXPORT_SYMBOL_GPL(thermal_tripless_zone_device_register); diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 1a51a4d240ff..e3359ca20d77 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -354,6 +354,7 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz) * zone properties and registers new thermal zone with those * properties. * + * @parent: parent device pointer * @sensor: A device node pointer corresponding to the sensor in the device tree * @id: An integer as sensor identifier * @data: A private data to be stored in the thermal zone dedicated private area @@ -364,7 +365,9 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz) * - ENOMEM: if one structure can not be allocated * - Other negative errors are returned by the underlying called functions */ -static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, +static struct thermal_zone_device *thermal_of_zone_register(struct device *parent, + struct device_node *sensor, + int id, void *data, const struct thermal_zone_device_ops *ops) { struct thermal_zone_device_ops of_ops = *ops; @@ -412,7 +415,7 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * of_ops.critical = thermal_zone_device_critical_shutdown; } - tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, + tz = thermal_zone_device_register_with_trips(parent, np->name, trips, ntrips, data, &of_ops, &tzp, pdelay, delay); if (IS_ERR(tz)) { @@ -478,7 +481,7 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in if (!ptr) return ERR_PTR(-ENOMEM); - tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops); + tzd = thermal_of_zone_register(dev, dev->of_node, sensor_id, data, ops); if (IS_ERR(tzd)) { devres_free(ptr); return tzd; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 29a608bf5f80..0c5a91313bd5 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -226,6 +226,7 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register_with_trips( + struct device *parent, const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, @@ -235,6 +236,7 @@ struct thermal_zone_device *thermal_zone_device_register_with_trips( unsigned int polling_delay); struct thermal_zone_device *thermal_tripless_zone_device_register( + struct device *parent, const char *type, void *devdata, const struct thermal_zone_device_ops *ops, @@ -276,6 +278,7 @@ int thermal_zone_device_disable(struct thermal_zone_device *tz); void thermal_zone_device_critical(struct thermal_zone_device *tz); #else static inline struct thermal_zone_device *thermal_zone_device_register_with_trips( + struct device *parent, const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, @@ -285,6 +288,7 @@ static inline struct thermal_zone_device *thermal_zone_device_register_with_trip { return ERR_PTR(-ENODEV); } static inline struct thermal_zone_device *thermal_tripless_zone_device_register( + struct device *parent, const char *type, void *devdata, struct thermal_zone_device_ops *ops, -- 2.39.5
