New thermal OF code
Subsystems (30)
v5 cover New thermal OF code
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
Changelog:
v5:
- Fixed st, exynos_tmu and adc iio sun4i compilation issue when THERMAL_EMULATION or THERMAL_OF are not set
- Add the pmbus_core.c API conversion which was missing
- Collected more tags
v4:
- Fixed a compilation error when THERMAL_OF=n
- Collected more tags
v3:
- Rebased on the right branch as reported by Niklas Söderlund
- Collected more tags
v2:
- Changed the code in the register thermal zone function to prevent the 'const' annotation being removed in the different drivers
- Collected the tags and adding Cc for more context
- Changed the first line patch description to comply to the 'input' subsystem format
- Give a more detailed description in the changelog for the drivers
- Remove pointless calls to unregister as the devm version is used instead
- Moved dummy functions from one patch to another to prevent git bisecting issue when THERMAL_OF=n
- Fixed thermal zone disabled by default
Daniel Lezcano (33):
thermal/of: Rework the thermal device tree initialization thermal/of: Make new code and old code co-exist thermal/drivers/rockchip: Switch to new of API thermal/drivers/uniphier: Switch to new of API thermal/drivers/generic-adc: Switch to new of API thermal/drivers/mmio: Switch to new of API thermal/drivers/tegra: Switch to new of API thermal/drivers/sun8i: Switch to new of API thermal/drivers/sprd: Switch to new of API thermal/drivers/broadcom: Switch to new of API thermal/drivers/qcom: Switch to new of API thermal/drivers/st: Switch to new of API thermal/drivers/amlogic: Switch to new of API thermal/drivers/armada: Switch to new of API thermal/drivers/db8500: Switch to new of API thermal/drivers/imx: Switch to new of API thermal/drivers/rcar: Switch to new of API thermal/drivers/rzg2l: Switch to new of API thermal/drivers/qoriq: Switch to new of API thermal/drivers/mtk: Switch to new of API thermal/drivers/banggap: Switch to new of API thermal/drivers/maxim: Switch to new of API thermal/drivers/hisilicon: Switch to new of API thermal/drivers/ti-soc: Switch to new of API ata/drivers/ahci_imx: Switch to new of thermal API hwmon/drivers/pm_bus: Switch to new of thermal API hwmon/drivers/core: Switch to new of thermal API iio/drivers/sun4i_gpadc: Switch to new of thermal API
Input: sun4i-ts - switch to new of thermal API regulator/drivers/max8976: Switch to new of thermal API thermal/drivers/samsung: Switch to new of thermal API thermal/core: Move set_trip_temp ops to the sysfs code thermal/of: Remove old OF code
drivers/ata/ahci_imx.c | 15 +- drivers/hwmon/hwmon.c | 14 +- drivers/hwmon/pmbus/pmbus_core.c | 10 +- drivers/hwmon/scpi-hwmon.c | 14 +- drivers/iio/adc/sun4i-gpadc-iio.c | 14 +- drivers/input/touchscreen/sun4i-ts.c | 10 +- drivers/regulator/max8973-regulator.c | 10 +- drivers/thermal/amlogic_thermal.c | 16 +- drivers/thermal/armada_thermal.c | 12 +- drivers/thermal/broadcom/bcm2711_thermal.c | 14 +- drivers/thermal/broadcom/bcm2835_thermal.c | 14 +- drivers/thermal/broadcom/brcmstb_thermal.c | 20 +- drivers/thermal/broadcom/ns-thermal.c | 50 +- drivers/thermal/broadcom/sr-thermal.c | 16 +- drivers/thermal/db8500_thermal.c | 8 +- drivers/thermal/hisi_thermal.c | 14 +- drivers/thermal/imx8mm_thermal.c | 14 +- drivers/thermal/imx_sc_thermal.c | 14 +- drivers/thermal/k3_bandgap.c | 12 +- drivers/thermal/k3_j72xx_bandgap.c | 12 +- drivers/thermal/max77620_thermal.c | 8 +- drivers/thermal/mtk_thermal.c | 10 +- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 19 +- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 12 +- drivers/thermal/qcom/tsens.c | 16 +- drivers/thermal/qoriq_thermal.c | 12 +- drivers/thermal/rcar_gen3_thermal.c | 16 +- drivers/thermal/rcar_thermal.c | 13 +- drivers/thermal/rockchip_thermal.c | 14 +- drivers/thermal/rzg2l_thermal.c | 10 +- drivers/thermal/samsung/exynos_tmu.c | 24 +- drivers/thermal/sprd_thermal.c | 18 +- drivers/thermal/st/stm_thermal.c | 18 +- drivers/thermal/sun8i_thermal.c | 14 +- drivers/thermal/tegra/soctherm.c | 21 +- drivers/thermal/tegra/tegra-bpmp-thermal.c | 19 +- drivers/thermal/tegra/tegra30-tsensor.c | 12 +- drivers/thermal/thermal-generic-adc.c | 10 +- drivers/thermal/thermal_core.c | 6 - drivers/thermal/thermal_core.h | 2 - drivers/thermal/thermal_mmio.c | 17 +- drivers/thermal/thermal_of.c | 1140 ++++++----------- drivers/thermal/thermal_sysfs.c | 5 +- .../ti-soc-thermal/ti-thermal-common.c | 16 +- drivers/thermal/uniphier_thermal.c | 10 +- include/linux/thermal.h | 85 +- 46 files changed, 708 insertions(+), 1142 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/33 thermal/of: Rework the thermal device tree initialization
The following changes are reworking entirely the thermal device tree initialization. The old version is kept until the different drivers using it are converted to the new API.
The old approach creates the different actors independently. This approach is the source of the code duplication in the thermal OF because a thermal zone is created but a sensor is registered after. The thermal zones are created unconditionnaly with a fake sensor at init time, thus forcing to provide fake ops and store all the thermal zone related information in duplicated structures. Then the sensor is initialized and the code looks up the thermal zone name using the device tree. Then the sensor is associated to the thermal zone, and the sensor specific ops are called with a second level of indirection from the thermal zone ops.
When a sensor is removed (with a module unload), the thermal zone stays there with the fake sensor.
The cooling device associated with a thermal zone and a trip point is stored in a list, again duplicating information, using the node name of the device tree to match afterwards the cooling devices.
The new approach is simpler, it creates a thermal zone when the sensor is registered and destroys it when the sensor is removed. All the matching between the cooling device, trip points and thermal zones are done using the device tree, as well as bindings. The ops are no longer specific but uses the generic ones provided by the thermal framework.
When the old code won't have any users, it can be removed and the remaining thermal OF code will be much simpler.
--- drivers/thermal/thermal_of.c | 460 ++++++++++++++++++++++++++++++++++- include/linux/thermal.h | 18 ++ 2 files changed, 468 insertions(+), 10 deletions(-)
drivers/thermal/thermal_of.c +450 -10
@@ -811,16 +811,6 @@ static int thermal_of_get_trip_type(struct device_node *np,return -ENODEV ; } -/** -* thermal_of_populate_trip - parse and fill one trip point data -* @np: DT node containing a trip point node -* @trip: trip point data structure to be filled up -* -* This function parses a trip point type of node represented by -* @np parameter and fills the read data into @trip data structure. -* -* Return: 0 on success, proper error code otherwise -*/ static int thermal_of_populate_trip (struct device_node *np,struct thermal_trip *trip) {
@@ -1065,6 +1055,456 @@ static __init void of_thermal_destroy_zones(void)of_node_put (np); } +static struct device_node *of_thermal_zone_find (struct device_node *sensor,int id) +{ +struct device_node *np, *tz; +struct of_phandle_args sensor_specs; + + np =of_find_node_by_name (NULL ,"thermal-zones" ); +if (!np) { +pr_err ("Unable to find thermal zones description\n" ); +return ERR_PTR (-EINVAL ); + } + +/* +* Search for each thermal zone, a defined sensor +* corresponding to the one passed as parameter +*/ +for_each_available_child_of_node (np, tz) { + +int count, i; + + count =of_count_phandle_with_args (tz,"thermal-sensors" , +"#thermal-sensor-cells" ); +if (count <=0 ) { +pr_err ("%pOFn: missing thermal sensor\n" , tz); + tz =ERR_PTR (-EINVAL ); + goto out; + } + +for (i =0 ; i < count; i++) { + +int ret; + + ret =of_parse_phandle_with_args (tz,"thermal-sensors" , +"#thermal-sensor-cells" , + i, &sensor_specs); +if (ret <0 ) { +pr_err ("%pOFn: Failed to read thermal-sensors cells: %d\n" , tz, ret); + tz =ERR_PTR (ret); + goto out; + } + +if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? + sensor_specs.args[0 ] :0 )) { +pr_debug ("sensor %pOFn id=%d belongs to %pOFn\n" , sensor, id, tz); + goto out; + } + } + } +out: +of_node_put (np); +return tz; +} + +static int thermal_of_monitor_init (struct device_node *np,int *delay,int *pdelay) +{ +int ret; + + ret =of_property_read_u32 (np,"polling-delay-passive" , pdelay); +if (ret <0 ) { +pr_err ("%pOFn: missing polling-delay-passive property\n" , np); +return ret; + } + + ret =of_property_read_u32 (np,"polling-delay" , delay); +if (ret <0 ) { +pr_err ("%pOFn: missing polling-delay property\n" , np); +return ret; + } + +return 0 ; +} + +static struct thermal_zone_params *thermal_of_parameters_init (struct device_node *np) +{ +struct thermal_zone_params *tzp; +int coef[2 ]; +int ncoef =ARRAY_SIZE (coef); +int prop, ret; + + tzp =kzalloc (sizeof (*tzp),GFP_KERNEL ); +if (!tzp) +return ERR_PTR (-ENOMEM ); + + tzp->no_hwmon = true; + +if (!of_property_read_u32 (np,"sustainable-power" , &prop)) + tzp->sustainable_power = prop; + +/* +* For now, the thermal framework supports only one sensor per +* thermal zone. Thus, we are considering only the first two +* values as slope and offset. +*/ + ret =of_property_read_u32_array (np,"coefficients" , coef, ncoef); +if (ret) { + coef[0 ] =1 ; + coef[1 ] =0 ; + } + + tzp->slope = coef[0 ]; + tzp->offset = coef[1 ]; + +return tzp; +} + +static struct device_node *thermal_of_zone_get_by_name (struct thermal_zone_device *tz) +{ +struct device_node *np, *tz_np; + + np =of_find_node_by_name (NULL ,"thermal-zones" ); +if (!np) +return ERR_PTR (-ENODEV ); + + tz_np =of_get_child_by_name (np, tz->type); + +of_node_put (np); + +if (!tz_np) +return ERR_PTR (-ENODEV ); + +return tz_np; +} + +static int __thermal_of_unbind (struct device_node *map_np,int index,int trip_id, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev) +{ +struct of_phandle_args cooling_spec; +int ret; + + ret =of_parse_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" , + index, &cooling_spec); + +of_node_put (cooling_spec.np); + +if (ret <0 ) { +pr_err ("Invalid cooling-device entry\n" ); +return ret; + } + +if (cooling_spec.args_count <2 ) { +pr_err ("wrong reference to cooling device, missing limits\n" ); +return -EINVAL ; + } + +if (cooling_spec.np != cdev->np) +return 0 ; + + ret =thermal_zone_unbind_cooling_device (tz, trip_id, cdev); +if (ret) +pr_err ("Failed to unbind '%s' with '%s': %d\n" , tz->type, cdev->type, ret); + +return ret; +} + +static int __thermal_of_bind (struct device_node *map_np,int index,int trip_id, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev) +{ +struct of_phandle_args cooling_spec; +int ret, weight =THERMAL_WEIGHT_DEFAULT ; + +of_property_read_u32 (map_np,"contribution" , &weight); + + ret =of_parse_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" , + index, &cooling_spec); + +of_node_put (cooling_spec.np); + +if (ret <0 ) { +pr_err ("Invalid cooling-device entry\n" ); +return ret; + } + +if (cooling_spec.args_count <2 ) { +pr_err ("wrong reference to cooling device, missing limits\n" ); +return -EINVAL ; + } + +if (cooling_spec.np != cdev->np) +return 0 ; + + ret =thermal_zone_bind_cooling_device (tz, trip_id, cdev, cooling_spec.args[1 ], + cooling_spec.args[0 ], + weight); +if (ret) +pr_err ("Failed to bind '%s' with '%s': %d\n" , tz->type, cdev->type, ret); + +return ret; +} + +static int thermal_of_for_each_cooling_device (struct device_node *tz_np,struct device_node *map_np, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev, +int (*action)(struct device_node *,int ,int , +struct thermal_zone_device *,struct thermal_cooling_device *)) +{ +struct device_node *tr_np; +int count, i, trip_id; + + tr_np =of_parse_phandle (map_np,"trip" ,0 ); +if (!tr_np) +return -ENODEV ; + + trip_id =of_find_trip_id (tz_np, tr_np); +if (trip_id <0 ) +return trip_id; + + count =of_count_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" ); +if (count <=0 ) { +pr_err ("Add a cooling_device property with at least one device\n" ); +return -ENOENT ; + } + +/* +* At this point, we don't want to bail out when there is an +* error, we will try to bind/unbind as many as possible +* cooling devices +*/ +for (i =0 ; i < count; i++) +action (map_np, i, trip_id, tz, cdev); + +return 0 ; +} + +static int thermal_of_for_each_cooling_maps (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev, +int (*action)(struct device_node *,int ,int , +struct thermal_zone_device *,struct thermal_cooling_device *)) +{ +struct device_node *tz_np, *cm_np, *child; +int ret =0 ; + + tz_np =thermal_of_zone_get_by_name (tz); +if (IS_ERR (tz_np)) { +pr_err ("Failed to get node tz by name\n" ); +return PTR_ERR (tz_np); + } + + cm_np =of_get_child_by_name (tz_np,"cooling-maps" ); +if (!cm_np) + goto out; + +for_each_child_of_node (cm_np, child) { + ret =thermal_of_for_each_cooling_device (tz_np, child, tz, cdev, action); +if (ret) +break ; + } + +of_node_put (cm_np); +out: +of_node_put (tz_np); + +return ret; +} + +static int thermal_of_bind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) +{ +return thermal_of_for_each_cooling_maps (tz, cdev, __thermal_of_bind); +} + +static int thermal_of_unbind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) +{ +return thermal_of_for_each_cooling_maps (tz, cdev, __thermal_of_unbind); +} + +/** +* thermal_of_zone_unregister - Cleanup the specific allocated ressources +* +* This function disables the thermal zone and frees the different +* ressources allocated specific to the thermal OF. +* +* @tz: a pointer to the thermal zone structure +*/ +void thermal_of_zone_unregister (struct thermal_zone_device *tz) +{ +thermal_zone_device_disable (tz); +thermal_zone_device_unregister (tz); +kfree (tz->trips); +kfree (tz->tzp); +kfree (tz->ops); +} +EXPORT_SYMBOL_GPL (thermal_of_zone_unregister); + +/** +* thermal_of_zone_register - Register a thermal zone with device node +* sensor +* +* The thermal_of_zone_register() parses a device tree given a device +* node sensor and identifier. It searches for the thermal zone +* associated to the couple sensor/id and retrieves all the thermal +* zone properties and registers new thermal zone with those +* properties. +* +* @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 +* @ops: A set of thermal sensor ops +* +* Return: a valid thermal zone structure pointer on success. +* - EINVAL: if the device tree thermal description is malformed +* - ENOMEM: if one structure can not be allocated +* - Other negative errors are returned by the underlying called functions +*/ +struct thermal_zone_device *thermal_of_zone_register (struct device_node *sensor,int id,void *data, +const struct thermal_zone_device_ops *ops) +{ +struct thermal_zone_device *tz; +struct thermal_trip *trips; +struct thermal_zone_params *tzp; +struct thermal_zone_device_ops *of_ops; +struct device_node *np; +int delay, pdelay; +int ntrips, mask; +int ret; + + of_ops =kmemdup (ops,sizeof (*ops),GFP_KERNEL ); +if (!of_ops) +return ERR_PTR (-ENOMEM ); + + np =of_thermal_zone_find (sensor, id); +if (IS_ERR (np)) { +pr_err ("Failed to find thermal zone for %pOFn id=%d\n" , sensor, id); +return ERR_CAST (np); + } + + trips =thermal_of_trips_init (np, &ntrips); +if (IS_ERR (trips)) { +pr_err ("Failed to find trip points for %pOFn id=%d\n" , sensor, id); +return ERR_CAST (trips); + } + + ret =thermal_of_monitor_init (np, &delay, &pdelay); +if (ret) { +pr_err ("Failed to initialize monitoring delays from %pOFn\n" , np); + goto out_kfree_trips; + } + + tzp =thermal_of_parameters_init (np); +if (IS_ERR (tzp)) { + ret =PTR_ERR (tzp); +pr_err ("Failed to initialize parameter from %pOFn: %d\n" , np, ret); + goto out_kfree_trips; + } + + of_ops->get_trip_type = of_ops->get_trip_type ? : of_thermal_get_trip_type; + of_ops->get_trip_temp = of_ops->get_trip_temp ? : of_thermal_get_trip_temp; + of_ops->get_trip_hyst = of_ops->get_trip_hyst ? : of_thermal_get_trip_hyst; + of_ops->set_trip_hyst = of_ops->set_trip_hyst ? : of_thermal_set_trip_hyst; + of_ops->get_crit_temp = of_ops->get_crit_temp ? : of_thermal_get_crit_temp; + of_ops->bind = thermal_of_bind; + of_ops->unbind = thermal_of_unbind; + + mask =GENMASK_ULL ((ntrips) -1 ,0 ); + + tz =thermal_zone_device_register_with_trips (np->name, trips, ntrips, + mask, data, of_ops, tzp, + pdelay, delay); +if (IS_ERR (tz)) { + ret =PTR_ERR (tz); +pr_err ("Failed to register thermal zone %pOFn: %d\n" , np, ret); + goto out_kfree_tzp; + } + + ret =thermal_zone_device_enable (tz); +if (ret) { +pr_err ("Failed to enabled thermal zone '%s', id=%d: %d\n" , + tz->type, tz->id, ret); +thermal_of_zone_unregister (tz); +return ERR_PTR (ret); + } + +return tz; + +out_kfree_tzp: +kfree (tzp); +out_kfree_trips: +kfree (trips); + +return ERR_PTR (ret); +} +EXPORT_SYMBOL_GPL (thermal_of_zone_register); + +static void devm_thermal_of_zone_release (struct device *dev,void *res) +{ +thermal_of_zone_unregister (*(struct thermal_zone_device **)res); +} + +static int devm_thermal_of_zone_match (struct device *dev,void *res, +void *data) +{ +struct thermal_zone_device **r = res; + +if (WARN_ON (!r || !*r)) +return 0 ; + +return *r == data; +} + +/** +* devm_thermal_of_zone_register - register a thermal tied with the sensor life cycle +* +* This function is the device version of the thermal_of_zone_register() function. +* +* @dev: a device structure pointer to sensor to be tied with the thermal zone OF life cycle +* @sensor_id: the sensor identifier +* @data: a pointer to a private data to be stored in the thermal zone 'devdata' field +* @ops: a pointer to the ops structure associated with the sensor +*/ +struct thermal_zone_device *devm_thermal_of_zone_register (struct device *dev,int sensor_id,void *data, +const struct thermal_zone_device_ops *ops) +{ +struct thermal_zone_device **ptr, *tzd; + + ptr =devres_alloc (devm_thermal_of_zone_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + tzd =thermal_of_zone_register (dev->of_node, sensor_id, data, ops); +if (IS_ERR (tzd)) { +devres_free (ptr); +return tzd; + } + + *ptr = tzd; +devres_add (dev, ptr); + +return tzd; +} +EXPORT_SYMBOL_GPL (devm_thermal_of_zone_register); + +/** +* devm_thermal_of_zone_unregister - Resource managed version of +* thermal_of_zone_unregister(). +* @dev: Device for which which resource was allocated. +* @tz: a pointer to struct thermal_zone where the sensor is registered. +* +* This function removes the sensor callbacks and private data from the +* thermal zone device registered with devm_thermal_zone_of_sensor_register() +* API. It will also silent the zone by remove the .get_temp() and .get_trend() +* thermal zone device callbacks. +* Normally this function will not need to be called and the resource +* management code will ensure that the resource is freed. +*/ +void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz) +{ +WARN_ON (devres_release (dev, devm_thermal_zone_of_sensor_release, + devm_thermal_of_zone_match, tz)); +} +EXPORT_SYMBOL_GPL (devm_thermal_of_zone_unregister); +/** * of_parse_thermal_zones - parse device tree thermal data *
include/linux/thermal.h +18 -0
@@ -325,6 +325,16 @@ struct thermal_zone_of_device_ops {/* Function declarations */ #ifdef CONFIG_THERMAL_OF +struct thermal_zone_device *thermal_of_zone_register (struct device_node *sensor,int id,void *data, +const struct thermal_zone_device_ops *ops); + +struct thermal_zone_device *devm_thermal_of_zone_register (struct device *dev,int id,void *data, +const struct thermal_zone_device_ops *ops); + +void thermal_of_zone_unregister (struct thermal_zone_device *tz); + +void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz); +int thermal_zone_of_get_sensor_id (struct device_node *tz_np,struct device_node *sensor_np,u32 *id);
@@ -366,6 +376,14 @@ static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(return ERR_PTR (-ENODEV ); } +static inline void thermal_of_zone_unregister (struct thermal_zone_device *tz) +{ +} + +static inline void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz) +{ +} +static inline void devm_thermal_zone_of_sensor_unregister (struct device *dev,struct thermal_zone_device *tz)
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/of: Rework the thermal device tree initialization
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 3fd6d6e2b4e80fe45bfd1c8f01dff7d30a0f9b53 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//3fd6d6e2b4e80fe45bfd1c8f01dff7d30a0f9b53 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:17 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/of: Rework the thermal device tree initialization
The following changes are reworking entirely the thermal device tree initialization. The old version is kept until the different drivers using it are converted to the new API.
The old approach creates the different actors independently. This approach is the source of the code duplication in the thermal OF because a thermal zone is created but a sensor is registered after. The thermal zones are created unconditionnaly with a fake sensor at init time, thus forcing to provide fake ops and store all the thermal zone related information in duplicated structures. Then the sensor is initialized and the code looks up the thermal zone name using the device tree. Then the sensor is associated to the thermal zone, and the sensor specific ops are called with a second level of indirection from the thermal zone ops.
When a sensor is removed (with a module unload), the thermal zone stays there with the fake sensor.
The cooling device associated with a thermal zone and a trip point is stored in a list, again duplicating information, using the node name of the device tree to match afterwards the cooling devices.
The new approach is simpler, it creates a thermal zone when the sensor is registered and destroys it when the sensor is removed. All the matching between the cooling device, trip points and thermal zones are done using the device tree, as well as bindings. The ops are no longer specific but uses the generic ones provided by the thermal framework.
When the old code won't have any users, it can be removed and the remaining thermal OF code will be much simpler.
--- drivers/thermal/thermal_of.c | 460 +++++++++++++++++++++++++++++++++- include/linux/thermal.h | 18 +- 2 files changed, 468 insertions(+), 10 deletions(-)
drivers/thermal/thermal_of.c +450 -10
@@ -811,16 +811,6 @@ static int thermal_of_get_trip_type(struct device_node *np,return -ENODEV ; } -/** -* thermal_of_populate_trip - parse and fill one trip point data -* @np: DT node containing a trip point node -* @trip: trip point data structure to be filled up -* -* This function parses a trip point type of node represented by -* @np parameter and fills the read data into @trip data structure. -* -* Return: 0 on success, proper error code otherwise -*/ static int thermal_of_populate_trip (struct device_node *np,struct thermal_trip *trip) {
@@ -1065,6 +1055,456 @@ static __init void of_thermal_destroy_zones(void)of_node_put (np); } +static struct device_node *of_thermal_zone_find (struct device_node *sensor,int id) +{ +struct device_node *np, *tz; +struct of_phandle_args sensor_specs; + + np =of_find_node_by_name (NULL ,"thermal-zones" ); +if (!np) { +pr_err ("Unable to find thermal zones description\n" ); +return ERR_PTR (-EINVAL ); + } + +/* +* Search for each thermal zone, a defined sensor +* corresponding to the one passed as parameter +*/ +for_each_available_child_of_node (np, tz) { + +int count, i; + + count =of_count_phandle_with_args (tz,"thermal-sensors" , +"#thermal-sensor-cells" ); +if (count <=0 ) { +pr_err ("%pOFn: missing thermal sensor\n" , tz); + tz =ERR_PTR (-EINVAL ); + goto out; + } + +for (i =0 ; i < count; i++) { + +int ret; + + ret =of_parse_phandle_with_args (tz,"thermal-sensors" , +"#thermal-sensor-cells" , + i, &sensor_specs); +if (ret <0 ) { +pr_err ("%pOFn: Failed to read thermal-sensors cells: %d\n" , tz, ret); + tz =ERR_PTR (ret); + goto out; + } + +if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? + sensor_specs.args[0 ] :0 )) { +pr_debug ("sensor %pOFn id=%d belongs to %pOFn\n" , sensor, id, tz); + goto out; + } + } + } +out: +of_node_put (np); +return tz; +} + +static int thermal_of_monitor_init (struct device_node *np,int *delay,int *pdelay) +{ +int ret; + + ret =of_property_read_u32 (np,"polling-delay-passive" , pdelay); +if (ret <0 ) { +pr_err ("%pOFn: missing polling-delay-passive property\n" , np); +return ret; + } + + ret =of_property_read_u32 (np,"polling-delay" , delay); +if (ret <0 ) { +pr_err ("%pOFn: missing polling-delay property\n" , np); +return ret; + } + +return 0 ; +} + +static struct thermal_zone_params *thermal_of_parameters_init (struct device_node *np) +{ +struct thermal_zone_params *tzp; +int coef[2 ]; +int ncoef =ARRAY_SIZE (coef); +int prop, ret; + + tzp =kzalloc (sizeof (*tzp),GFP_KERNEL ); +if (!tzp) +return ERR_PTR (-ENOMEM ); + + tzp->no_hwmon = true; + +if (!of_property_read_u32 (np,"sustainable-power" , &prop)) + tzp->sustainable_power = prop; + +/* +* For now, the thermal framework supports only one sensor per +* thermal zone. Thus, we are considering only the first two +* values as slope and offset. +*/ + ret =of_property_read_u32_array (np,"coefficients" , coef, ncoef); +if (ret) { + coef[0 ] =1 ; + coef[1 ] =0 ; + } + + tzp->slope = coef[0 ]; + tzp->offset = coef[1 ]; + +return tzp; +} + +static struct device_node *thermal_of_zone_get_by_name (struct thermal_zone_device *tz) +{ +struct device_node *np, *tz_np; + + np =of_find_node_by_name (NULL ,"thermal-zones" ); +if (!np) +return ERR_PTR (-ENODEV ); + + tz_np =of_get_child_by_name (np, tz->type); + +of_node_put (np); + +if (!tz_np) +return ERR_PTR (-ENODEV ); + +return tz_np; +} + +static int __thermal_of_unbind (struct device_node *map_np,int index,int trip_id, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev) +{ +struct of_phandle_args cooling_spec; +int ret; + + ret =of_parse_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" , + index, &cooling_spec); + +of_node_put (cooling_spec.np); + +if (ret <0 ) { +pr_err ("Invalid cooling-device entry\n" ); +return ret; + } + +if (cooling_spec.args_count <2 ) { +pr_err ("wrong reference to cooling device, missing limits\n" ); +return -EINVAL ; + } + +if (cooling_spec.np != cdev->np) +return 0 ; + + ret =thermal_zone_unbind_cooling_device (tz, trip_id, cdev); +if (ret) +pr_err ("Failed to unbind '%s' with '%s': %d\n" , tz->type, cdev->type, ret); + +return ret; +} + +static int __thermal_of_bind (struct device_node *map_np,int index,int trip_id, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev) +{ +struct of_phandle_args cooling_spec; +int ret, weight =THERMAL_WEIGHT_DEFAULT ; + +of_property_read_u32 (map_np,"contribution" , &weight); + + ret =of_parse_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" , + index, &cooling_spec); + +of_node_put (cooling_spec.np); + +if (ret <0 ) { +pr_err ("Invalid cooling-device entry\n" ); +return ret; + } + +if (cooling_spec.args_count <2 ) { +pr_err ("wrong reference to cooling device, missing limits\n" ); +return -EINVAL ; + } + +if (cooling_spec.np != cdev->np) +return 0 ; + + ret =thermal_zone_bind_cooling_device (tz, trip_id, cdev, cooling_spec.args[1 ], + cooling_spec.args[0 ], + weight); +if (ret) +pr_err ("Failed to bind '%s' with '%s': %d\n" , tz->type, cdev->type, ret); + +return ret; +} + +static int thermal_of_for_each_cooling_device (struct device_node *tz_np,struct device_node *map_np, +struct thermal_zone_device *tz,struct thermal_cooling_device *cdev, +int (*action)(struct device_node *,int ,int , +struct thermal_zone_device *,struct thermal_cooling_device *)) +{ +struct device_node *tr_np; +int count, i, trip_id; + + tr_np =of_parse_phandle (map_np,"trip" ,0 ); +if (!tr_np) +return -ENODEV ; + + trip_id =of_find_trip_id (tz_np, tr_np); +if (trip_id <0 ) +return trip_id; + + count =of_count_phandle_with_args (map_np,"cooling-device" ,"#cooling-cells" ); +if (count <=0 ) { +pr_err ("Add a cooling_device property with at least one device\n" ); +return -ENOENT ; + } + +/* +* At this point, we don't want to bail out when there is an +* error, we will try to bind/unbind as many as possible +* cooling devices +*/ +for (i =0 ; i < count; i++) +action (map_np, i, trip_id, tz, cdev); + +return 0 ; +} + +static int thermal_of_for_each_cooling_maps (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev, +int (*action)(struct device_node *,int ,int , +struct thermal_zone_device *,struct thermal_cooling_device *)) +{ +struct device_node *tz_np, *cm_np, *child; +int ret =0 ; + + tz_np =thermal_of_zone_get_by_name (tz); +if (IS_ERR (tz_np)) { +pr_err ("Failed to get node tz by name\n" ); +return PTR_ERR (tz_np); + } + + cm_np =of_get_child_by_name (tz_np,"cooling-maps" ); +if (!cm_np) + goto out; + +for_each_child_of_node (cm_np, child) { + ret =thermal_of_for_each_cooling_device (tz_np, child, tz, cdev, action); +if (ret) +break ; + } + +of_node_put (cm_np); +out: +of_node_put (tz_np); + +return ret; +} + +static int thermal_of_bind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) +{ +return thermal_of_for_each_cooling_maps (tz, cdev, __thermal_of_bind); +} + +static int thermal_of_unbind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) +{ +return thermal_of_for_each_cooling_maps (tz, cdev, __thermal_of_unbind); +} + +/** +* thermal_of_zone_unregister - Cleanup the specific allocated ressources +* +* This function disables the thermal zone and frees the different +* ressources allocated specific to the thermal OF. +* +* @tz: a pointer to the thermal zone structure +*/ +void thermal_of_zone_unregister (struct thermal_zone_device *tz) +{ +thermal_zone_device_disable (tz); +thermal_zone_device_unregister (tz); +kfree (tz->trips); +kfree (tz->tzp); +kfree (tz->ops); +} +EXPORT_SYMBOL_GPL (thermal_of_zone_unregister); + +/** +* thermal_of_zone_register - Register a thermal zone with device node +* sensor +* +* The thermal_of_zone_register() parses a device tree given a device +* node sensor and identifier. It searches for the thermal zone +* associated to the couple sensor/id and retrieves all the thermal +* zone properties and registers new thermal zone with those +* properties. +* +* @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 +* @ops: A set of thermal sensor ops +* +* Return: a valid thermal zone structure pointer on success. +* - EINVAL: if the device tree thermal description is malformed +* - ENOMEM: if one structure can not be allocated +* - Other negative errors are returned by the underlying called functions +*/ +struct thermal_zone_device *thermal_of_zone_register (struct device_node *sensor,int id,void *data, +const struct thermal_zone_device_ops *ops) +{ +struct thermal_zone_device *tz; +struct thermal_trip *trips; +struct thermal_zone_params *tzp; +struct thermal_zone_device_ops *of_ops; +struct device_node *np; +int delay, pdelay; +int ntrips, mask; +int ret; + + of_ops =kmemdup (ops,sizeof (*ops),GFP_KERNEL ); +if (!of_ops) +return ERR_PTR (-ENOMEM ); + + np =of_thermal_zone_find (sensor, id); +if (IS_ERR (np)) { +pr_err ("Failed to find thermal zone for %pOFn id=%d\n" , sensor, id); +return ERR_CAST (np); + } + + trips =thermal_of_trips_init (np, &ntrips); +if (IS_ERR (trips)) { +pr_err ("Failed to find trip points for %pOFn id=%d\n" , sensor, id); +return ERR_CAST (trips); + } + + ret =thermal_of_monitor_init (np, &delay, &pdelay); +if (ret) { +pr_err ("Failed to initialize monitoring delays from %pOFn\n" , np); + goto out_kfree_trips; + } + + tzp =thermal_of_parameters_init (np); +if (IS_ERR (tzp)) { + ret =PTR_ERR (tzp); +pr_err ("Failed to initialize parameter from %pOFn: %d\n" , np, ret); + goto out_kfree_trips; + } + + of_ops->get_trip_type = of_ops->get_trip_type ? : of_thermal_get_trip_type; + of_ops->get_trip_temp = of_ops->get_trip_temp ? : of_thermal_get_trip_temp; + of_ops->get_trip_hyst = of_ops->get_trip_hyst ? : of_thermal_get_trip_hyst; + of_ops->set_trip_hyst = of_ops->set_trip_hyst ? : of_thermal_set_trip_hyst; + of_ops->get_crit_temp = of_ops->get_crit_temp ? : of_thermal_get_crit_temp; + of_ops->bind = thermal_of_bind; + of_ops->unbind = thermal_of_unbind; + + mask =GENMASK_ULL ((ntrips) -1 ,0 ); + + tz =thermal_zone_device_register_with_trips (np->name, trips, ntrips, + mask, data, of_ops, tzp, + pdelay, delay); +if (IS_ERR (tz)) { + ret =PTR_ERR (tz); +pr_err ("Failed to register thermal zone %pOFn: %d\n" , np, ret); + goto out_kfree_tzp; + } + + ret =thermal_zone_device_enable (tz); +if (ret) { +pr_err ("Failed to enabled thermal zone '%s', id=%d: %d\n" , + tz->type, tz->id, ret); +thermal_of_zone_unregister (tz); +return ERR_PTR (ret); + } + +return tz; + +out_kfree_tzp: +kfree (tzp); +out_kfree_trips: +kfree (trips); + +return ERR_PTR (ret); +} +EXPORT_SYMBOL_GPL (thermal_of_zone_register); + +static void devm_thermal_of_zone_release (struct device *dev,void *res) +{ +thermal_of_zone_unregister (*(struct thermal_zone_device **)res); +} + +static int devm_thermal_of_zone_match (struct device *dev,void *res, +void *data) +{ +struct thermal_zone_device **r = res; + +if (WARN_ON (!r || !*r)) +return 0 ; + +return *r == data; +} + +/** +* devm_thermal_of_zone_register - register a thermal tied with the sensor life cycle +* +* This function is the device version of the thermal_of_zone_register() function. +* +* @dev: a device structure pointer to sensor to be tied with the thermal zone OF life cycle +* @sensor_id: the sensor identifier +* @data: a pointer to a private data to be stored in the thermal zone 'devdata' field +* @ops: a pointer to the ops structure associated with the sensor +*/ +struct thermal_zone_device *devm_thermal_of_zone_register (struct device *dev,int sensor_id,void *data, +const struct thermal_zone_device_ops *ops) +{ +struct thermal_zone_device **ptr, *tzd; + + ptr =devres_alloc (devm_thermal_of_zone_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + tzd =thermal_of_zone_register (dev->of_node, sensor_id, data, ops); +if (IS_ERR (tzd)) { +devres_free (ptr); +return tzd; + } + + *ptr = tzd; +devres_add (dev, ptr); + +return tzd; +} +EXPORT_SYMBOL_GPL (devm_thermal_of_zone_register); + +/** +* devm_thermal_of_zone_unregister - Resource managed version of +* thermal_of_zone_unregister(). +* @dev: Device for which which resource was allocated. +* @tz: a pointer to struct thermal_zone where the sensor is registered. +* +* This function removes the sensor callbacks and private data from the +* thermal zone device registered with devm_thermal_zone_of_sensor_register() +* API. It will also silent the zone by remove the .get_temp() and .get_trend() +* thermal zone device callbacks. +* Normally this function will not need to be called and the resource +* management code will ensure that the resource is freed. +*/ +void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz) +{ +WARN_ON (devres_release (dev, devm_thermal_zone_of_sensor_release, + devm_thermal_of_zone_match, tz)); +} +EXPORT_SYMBOL_GPL (devm_thermal_of_zone_unregister); +/** * of_parse_thermal_zones - parse device tree thermal data *
include/linux/thermal.h +18 -0
@@ -325,6 +325,16 @@ struct thermal_zone_of_device_ops {/* Function declarations */ #ifdef CONFIG_THERMAL_OF +struct thermal_zone_device *thermal_of_zone_register (struct device_node *sensor,int id,void *data, +const struct thermal_zone_device_ops *ops); + +struct thermal_zone_device *devm_thermal_of_zone_register (struct device *dev,int id,void *data, +const struct thermal_zone_device_ops *ops); + +void thermal_of_zone_unregister (struct thermal_zone_device *tz); + +void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz); +int thermal_zone_of_get_sensor_id (struct device_node *tz_np,struct device_node *sensor_np,u32 *id);
@@ -366,6 +376,14 @@ static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(return ERR_PTR (-ENODEV ); } +static inline void thermal_of_zone_unregister (struct thermal_zone_device *tz) +{ +} + +static inline void devm_thermal_of_zone_unregister (struct device *dev,struct thermal_zone_device *tz) +{ +} +static inline void devm_thermal_zone_of_sensor_unregister (struct device *dev,struct thermal_zone_device *tz)
Re: [PATCH v5 01/33] thermal/of: Rework the thermal device tree initialization
In reply to Daniel LezcanoQuoted 68 lines · Daniel Lezcano
(quoted diff) +68
-0+struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, + const struct thermal_zone_device_ops *ops) +{ + struct thermal_zone_device *tz; + struct thermal_trip *trips; + struct thermal_zone_params *tzp; + struct thermal_zone_device_ops *of_ops; + struct device_node *np; + int delay, pdelay; + int ntrips, mask; + int ret; + + of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); + if (!of_ops) + return ERR_PTR(-ENOMEM); + + np = of_thermal_zone_find(sensor, id); + if (IS_ERR(np)) { + pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id); + return ERR_CAST(np); + } + + trips = thermal_of_trips_init(np, &ntrips); + if (IS_ERR(trips)) { + pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id); + return ERR_CAST(trips); + } + + ret = thermal_of_monitor_init(np, &delay, &pdelay); + if (ret) { + pr_err("Failed to initialize monitoring delays from %pOFn\n", np); + goto out_kfree_trips; + } + + tzp = thermal_of_parameters_init(np); + if (IS_ERR(tzp)) { + ret = PTR_ERR(tzp); + pr_err("Failed to initialize parameter from %pOFn: %d\n", np, ret); + goto out_kfree_trips; + } + + of_ops->get_trip_type = of_ops->get_trip_type ? : of_thermal_get_trip_type; + of_ops->get_trip_temp = of_ops->get_trip_temp ? : of_thermal_get_trip_temp; + of_ops->get_trip_hyst = of_ops->get_trip_hyst ? : of_thermal_get_trip_hyst; + of_ops->set_trip_hyst = of_ops->set_trip_hyst ? : of_thermal_set_trip_hyst; + of_ops->get_crit_temp = of_ops->get_crit_temp ? : of_thermal_get_crit_temp; + of_ops->bind = thermal_of_bind; + of_ops->unbind = thermal_of_unbind; + + mask = GENMASK_ULL((ntrips) - 1, 0); + + tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, + mask, data, of_ops, tzp, + pdelay, delay); + if (IS_ERR(tz)) { + ret = PTR_ERR(tz); + pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret); + goto out_kfree_tzp; + } + + ret = thermal_zone_device_enable(tz); + if (ret) { + pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n", + tz->type, tz->id, ret); + thermal_of_zone_unregister(tz); + return ERR_PTR(ret); + } +
Review
Quoted 10 lines
(quoted diff) +10
-0+ return tz; + +out_kfree_tzp: + kfree(tzp); +out_kfree_trips: + kfree(trips); + + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(thermal_of_zone_register);
Daniel, I started seeing these memory leaks [1] since commit 613ed3f67609 ("hwmon: pm_bus: core: Switch to new of thermal API"). Seems to be fixed by the following patch [2].
Do you already have a patch for this issue or should I submit it?
Thanks
[1]
unreferenced object 0xffff8ee846198c80 (size 128):
comm "swapper/0", pid 1, jiffies 4294699704 (age 70.076s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0 3f 6e 8c ff ff ff ff 00 00 00 00 00 00 00 00 .?n.............
backtrace:
[<00000000d136f562>] __kmalloc_node_track_caller+0x42/0x120
[<0000000063f31678>] kmemdup+0x1d/0x40
[<00000000e6d24096>] thermal_of_zone_register+0x49/0x520
[<000000005e78c755>] devm_thermal_of_zone_register+0x54/0x90
[<00000000ee6b209e>] pmbus_add_sensor+0x1b4/0x1d0
[<00000000896105e3>] pmbus_add_sensor_attrs_one+0x123/0x440
[<0000000049e990a6>] pmbus_add_sensor_attrs+0xfe/0x1d0
[<00000000466b5440>] pmbus_do_probe+0x66b/0x14e0
[<0000000084d42285>] i2c_device_probe+0x13b/0x2f0
[<0000000029e2ae74>] really_probe+0xce/0x2c0
[<00000000692df15c>] driver_probe_device+0x19/0xd0
[<00000000547d9cce>] __device_attach_driver+0x6f/0x100
[<0000000020abd24b>] bus_for_each_drv+0x76/0xc0
[<00000000665d9563>] __device_attach+0xfc/0x180
[<000000008ddd4d6a>] bus_probe_device+0x82/0xa0
[<000000009e61132b>] device_add+0x3fe/0x920
unreferenced object 0xffff8ee846199200 (size 128):
comm "swapper/0", pid 1, jiffies 4294699710 (age 70.070s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0 3f 6e 8c ff ff ff ff 00 00 00 00 00 00 00 00 .?n.............
backtrace:
[<00000000d136f562>] __kmalloc_node_track_caller+0x42/0x120
[<0000000063f31678>] kmemdup+0x1d/0x40
[<00000000e6d24096>] thermal_of_zone_register+0x49/0x520
[<000000005e78c755>] devm_thermal_of_zone_register+0x54/0x90
[<00000000ee6b209e>] pmbus_add_sensor+0x1b4/0x1d0
[<00000000896105e3>] pmbus_add_sensor_attrs_one+0x123/0x440
[<0000000049e990a6>] pmbus_add_sensor_attrs+0xfe/0x1d0
[<00000000466b5440>] pmbus_do_probe+0x66b/0x14e0
[<0000000084d42285>] i2c_device_probe+0x13b/0x2f0
[<0000000029e2ae74>] really_probe+0xce/0x2c0
[<00000000692df15c>] driver_probe_device+0x19/0xd0
[<00000000547d9cce>] __device_attach_driver+0x6f/0x100
[<0000000020abd24b>] bus_for_each_drv+0x76/0xc0
[<00000000665d9563>] __device_attach+0xfc/0x180
[<000000008ddd4d6a>] bus_probe_device+0x82/0xa0
[<000000009e61132b>] device_add+0x3fe/0x920
unreferenced object 0xffff8ee846199780 (size 128):
comm "swapper/0", pid 1, jiffies 4294699716 (age 70.064s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0 3f 6e 8c ff ff ff ff 00 00 00 00 00 00 00 00 .?n.............
backtrace:
[<00000000d136f562>] __kmalloc_node_track_caller+0x42/0x120
[<0000000063f31678>] kmemdup+0x1d/0x40
[<00000000e6d24096>] thermal_of_zone_register+0x49/0x520
[<000000005e78c755>] devm_thermal_of_zone_register+0x54/0x90
[<00000000ee6b209e>] pmbus_add_sensor+0x1b4/0x1d0
[<00000000896105e3>] pmbus_add_sensor_attrs_one+0x123/0x440
[<0000000049e990a6>] pmbus_add_sensor_attrs+0xfe/0x1d0
[<00000000466b5440>] pmbus_do_probe+0x66b/0x14e0
[<0000000084d42285>] i2c_device_probe+0x13b/0x2f0
[<0000000029e2ae74>] really_probe+0xce/0x2c0
[<00000000692df15c>] driver_probe_device+0x19/0xd0
[<00000000547d9cce>] __device_attach_driver+0x6f/0x100
[<0000000020abd24b>] bus_for_each_drv+0x76/0xc0
[<00000000665d9563>] __device_attach+0xfc/0x180
[<000000008ddd4d6a>] bus_probe_device+0x82/0xa0
[<000000009e61132b>] device_add+0x3fe/0x920[2]
drivers/thermal/thermal_of.c +6 -2
@@ -604,13 +604,15 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,if (IS_ERR (np)) {if (PTR_ERR (np) != -ENODEV )pr_err ("Failed to find thermal zone for %pOFn id=%d\n" , sensor, id); -return ERR_CAST (np); + ret =PTR_ERR (np); + goto out_kfree_of_ops; } trips =thermal_of_trips_init (np, &ntrips);if (IS_ERR (trips)) {pr_err ("Failed to find trip points for %pOFn id=%d\n" , sensor, id); -return ERR_CAST (trips); + ret =PTR_ERR (np); + goto out_kfree_of_ops; } ret =thermal_of_monitor_init (np, &delay, &pdelay);
@@ -659,6 +661,8 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,kfree (tzp); out_kfree_trips:kfree (trips); +out_kfree_of_ops: +kfree (of_ops);return ERR_PTR (ret); }
Re: [PATCH v5 01/33] thermal/of: Rework the thermal device tree initialization
Quoted 8 lines · Ido Schimmel
drivers/thermal/thermal_of.c +0
-0@@ -604,13 +604,15 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,if (IS_ERR (np)) {if (PTR_ERR (np) != -ENODEV )pr_err ("Failed to find thermal zone for %pOFn id=%d\n" , sensor, id);
drivers/thermal/thermal_of.c struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, · line 614
Quoted 10 lines
drivers/thermal/thermal_of.c +3
-2-return ERR_CAST (np); + ret =PTR_ERR (np); + goto out_kfree_of_ops; } trips =thermal_of_trips_init (np, &ntrips);if (IS_ERR (trips)) {pr_err ("Failed to find trip points for %pOFn id=%d\n" , sensor, id); -return ERR_CAST (trips); + ret =PTR_ERR (np);
Sorry, should be:
ret = PTR_ERR(trips);
Quoted 13 lines
drivers/thermal/thermal_of.c +3
-0+ goto out_kfree_of_ops; } ret =thermal_of_monitor_init (np, &delay, &pdelay);@@ -659,6 +661,8 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,kfree (tzp); out_kfree_trips:kfree (trips); +out_kfree_of_ops: +kfree (of_ops);return ERR_PTR (ret); }
Re: [PATCH v5 01/33] thermal/of: Rework the thermal device tree initialization
In reply to Ido SchimmelHi Ido,
Quoted 84 lines · Ido Schimmel
Quoted 68 lines · Daniel Lezcano
(quoted diff) +68
-0+struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, + const struct thermal_zone_device_ops *ops) +{ + struct thermal_zone_device *tz; + struct thermal_trip *trips; + struct thermal_zone_params *tzp; + struct thermal_zone_device_ops *of_ops; + struct device_node *np; + int delay, pdelay; + int ntrips, mask; + int ret; + + of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); + if (!of_ops) + return ERR_PTR(-ENOMEM); + + np = of_thermal_zone_find(sensor, id); + if (IS_ERR(np)) { + pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id); + return ERR_CAST(np); + } + + trips = thermal_of_trips_init(np, &ntrips); + if (IS_ERR(trips)) { + pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id); + return ERR_CAST(trips); + } + + ret = thermal_of_monitor_init(np, &delay, &pdelay); + if (ret) { + pr_err("Failed to initialize monitoring delays from %pOFn\n", np); + goto out_kfree_trips; + } + + tzp = thermal_of_parameters_init(np); + if (IS_ERR(tzp)) { + ret = PTR_ERR(tzp); + pr_err("Failed to initialize parameter from %pOFn: %d\n", np, ret); + goto out_kfree_trips; + } + + of_ops->get_trip_type = of_ops->get_trip_type ? : of_thermal_get_trip_type; + of_ops->get_trip_temp = of_ops->get_trip_temp ? : of_thermal_get_trip_temp; + of_ops->get_trip_hyst = of_ops->get_trip_hyst ? : of_thermal_get_trip_hyst; + of_ops->set_trip_hyst = of_ops->set_trip_hyst ? : of_thermal_set_trip_hyst; + of_ops->get_crit_temp = of_ops->get_crit_temp ? : of_thermal_get_crit_temp; + of_ops->bind = thermal_of_bind; + of_ops->unbind = thermal_of_unbind; + + mask = GENMASK_ULL((ntrips) - 1, 0); + + tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, + mask, data, of_ops, tzp, + pdelay, delay); + if (IS_ERR(tz)) { + ret = PTR_ERR(tz); + pr_err("Failed to register thermal zone %pOFn: %d\n", np, ret); + goto out_kfree_tzp; + } + + ret = thermal_zone_device_enable(tz); + if (ret) { + pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n", + tz->type, tz->id, ret); + thermal_of_zone_unregister(tz); + return ERR_PTR(ret); + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ return tz; + +out_kfree_tzp: + kfree(tzp); +out_kfree_trips: + kfree(trips); + + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(thermal_of_zone_register);Daniel, I started seeing these memory leaks [1] since commit
613ed3f67609("hwmon:pm_bus: core: Switch to new of thermal API"). Seems to be fixed by the following patch [2].
Quoted 1 line
Do you already have a patch for this issue or should I submit it?
Thanks for reporting the issue. If you can submit it, that would be great
Re: [PATCH v5 01/33] thermal/of: Rework the thermal device tree initialization
Quoted 1 line · Daniel Lezcano
Thanks for reporting the issue. If you can submit it, that would be great
PATCH v5 2/33 thermal/of: Make new code and old code co-exist
In reply to Daniel LezcanoThis transient change allows to use old and new OF together until all the drivers are converted to use the new OF API.
This will go away when the old OF code will be removed.
--- drivers/thermal/thermal_core.c | 6 ------ drivers/thermal/thermal_of.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +0 -6
@@ -1491,10 +1491,6 @@ static int __init thermal_init(void)if (result) goto unregister_governors; - result =of_parse_thermal_zones (); -if (result) - goto unregister_class; - result =register_pm_notifier (&thermal_pm_nb);if (result) pr_warn("Thermal: Can not register suspend notifier, return %d\n",
@@ -1502,8 +1498,6 @@ static int __init thermal_init(void)return 0 ; -unregister_class: -class_unregister (&thermal_class); unregister_governors:thermal_unregister_governors (); error:
drivers/thermal/thermal_of.c +11 -2
@@ -485,6 +485,15 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, {struct device_node *np, *child, *sensor_np;struct thermal_zone_device *tzd =ERR_PTR (-ENODEV ); +static int old_tz_initialized; +int ret; + +if (!old_tz_initialized) { + ret =of_parse_thermal_zones (); +if (ret) +return ERR_PTR (ret); + old_tz_initialized =1 ; + } np =of_find_node_by_name (NULL ,"thermal-zones" );if (!np)
@@ -1004,7 +1013,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)return ERR_PTR (ret); } -static __init void of_thermal_free_zone (struct __thermal_zone *tz) +static void of_thermal_free_zone (struct __thermal_zone *tz) {struct __thermal_bind_params *tbp;int i, j;
@@ -1517,7 +1526,7 @@ EXPORT_SYMBOL_GPL(devm_thermal_of_zone_unregister);* Return: 0 on success, proper error code otherwise * */ -int __init of_parse_thermal_zones (void ) +int of_parse_thermal_zones (void ) {struct device_node *np, *child;struct __thermal_zone *tz;
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/of: Make new code and old code co-exist
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 48ad3b104b9ec85de58c2b4e38fdad9a26446f99 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//48ad3b104b9ec85de58c2b4e38fdad9a26446f99 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:18 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/of: Make new code and old code co-exist
This transient change allows to use old and new OF together until all the drivers are converted to use the new OF API.
This will go away when the old OF code will be removed.
--- drivers/thermal/thermal_core.c | 6 ------ drivers/thermal/thermal_of.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +0 -6
@@ -1492,10 +1492,6 @@ static int __init thermal_init(void)if (result) goto unregister_governors; - result =of_parse_thermal_zones (); -if (result) - goto unregister_class; - result =register_pm_notifier (&thermal_pm_nb);if (result) pr_warn("Thermal: Can not register suspend notifier, return %d\n",
@@ -1503,8 +1499,6 @@ static int __init thermal_init(void)return 0 ; -unregister_class: -class_unregister (&thermal_class); unregister_governors:thermal_unregister_governors (); error:
drivers/thermal/thermal_of.c +11 -2
@@ -485,6 +485,15 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, {struct device_node *np, *child, *sensor_np;struct thermal_zone_device *tzd =ERR_PTR (-ENODEV ); +static int old_tz_initialized; +int ret; + +if (!old_tz_initialized) { + ret =of_parse_thermal_zones (); +if (ret) +return ERR_PTR (ret); + old_tz_initialized =1 ; + } np =of_find_node_by_name (NULL ,"thermal-zones" );if (!np)
@@ -1004,7 +1013,7 @@ free_tz:return ERR_PTR (ret); } -static __init void of_thermal_free_zone (struct __thermal_zone *tz) +static void of_thermal_free_zone (struct __thermal_zone *tz) {struct __thermal_bind_params *tbp;int i, j;
@@ -1523,7 +1532,7 @@ EXPORT_SYMBOL_GPL(devm_thermal_of_zone_unregister);* Return: 0 on success, proper error code otherwise * */ -int __init of_parse_thermal_zones (void ) +int of_parse_thermal_zones (void ) {struct device_node *np, *child;struct __thermal_zone *tz;
PATCH v5 3/33 thermal/drivers/rockchip: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rockchip_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/rockchip_thermal.c +7 -7
@@ -1211,9 +1211,9 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)return IRQ_HANDLED ; } -static int rockchip_thermal_set_trips (void *_sensor,int low,int high) +static int rockchip_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct rockchip_thermal_sensor *sensor = _sensor; +struct rockchip_thermal_sensor *sensor = tz->devdata;struct rockchip_thermal_data *thermal = sensor->thermal;const struct rockchip_tsadc_chip *tsadc = thermal->chip;
@@ -1224,9 +1224,9 @@ static int rockchip_thermal_set_trips(void *_sensor, int low, int high) sensor->id, thermal->regs, high); } -static int rockchip_thermal_get_temp (void *_sensor,int *out_temp) +static int rockchip_thermal_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct rockchip_thermal_sensor *sensor = _sensor; +struct rockchip_thermal_sensor *sensor = tz->devdata;struct rockchip_thermal_data *thermal = sensor->thermal;const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;int retval;
@@ -1239,7 +1239,7 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)return retval; } -static const struct thermal_zone_of_device_ops rockchip_of_thermal_ops = { +static const struct thermal_zone_device_ops rockchip_of_thermal_ops = { .get_temp = rockchip_thermal_get_temp, .set_trips = rockchip_thermal_set_trips, };
@@ -1326,8 +1326,8 @@ rockchip_thermal_register_sensor(struct platform_device *pdev, sensor->thermal = thermal; sensor->id = id; - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, id, - sensor, &rockchip_of_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, id, sensor, + &rockchip_of_thermal_ops);if (IS_ERR (sensor->tzd)) { error =PTR_ERR (sensor->tzd); dev_err(&pdev->dev, "failed to register sensor %d: %d\n",
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/rockchip: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 90b2ca02a969963bb37c30b42510fc3dfb0a3ae7 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//90b2ca02a969963bb37c30b42510fc3dfb0a3ae7 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:19 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/drivers/rockchip: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rockchip_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/rockchip_thermal.c +7 -7
@@ -1211,9 +1211,9 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)return IRQ_HANDLED ; } -static int rockchip_thermal_set_trips (void *_sensor,int low,int high) +static int rockchip_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct rockchip_thermal_sensor *sensor = _sensor; +struct rockchip_thermal_sensor *sensor = tz->devdata;struct rockchip_thermal_data *thermal = sensor->thermal;const struct rockchip_tsadc_chip *tsadc = thermal->chip;
@@ -1224,9 +1224,9 @@ static int rockchip_thermal_set_trips(void *_sensor, int low, int high) sensor->id, thermal->regs, high); } -static int rockchip_thermal_get_temp (void *_sensor,int *out_temp) +static int rockchip_thermal_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct rockchip_thermal_sensor *sensor = _sensor; +struct rockchip_thermal_sensor *sensor = tz->devdata;struct rockchip_thermal_data *thermal = sensor->thermal;const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;int retval;
@@ -1239,7 +1239,7 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)return retval; } -static const struct thermal_zone_of_device_ops rockchip_of_thermal_ops = { +static const struct thermal_zone_device_ops rockchip_of_thermal_ops = { .get_temp = rockchip_thermal_get_temp, .set_trips = rockchip_thermal_set_trips, };
@@ -1326,8 +1326,8 @@ rockchip_thermal_register_sensor(struct platform_device *pdev, sensor->thermal = thermal; sensor->id = id; - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, id, - sensor, &rockchip_of_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, id, sensor, + &rockchip_of_thermal_ops);if (IS_ERR (sensor->tzd)) { error =PTR_ERR (sensor->tzd); dev_err(&pdev->dev, "failed to register sensor %d: %d\n",
PATCH v5 4/33 thermal/drivers/uniphier: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/uniphier_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/uniphier_thermal.c +5 -5
@@ -187,9 +187,9 @@ static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev)usleep_range (1000 ,2000 );/* The spec note says at least 1ms */ } -static int uniphier_tm_get_temp (void *data,int *out_temp) +static int uniphier_tm_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct uniphier_tm_dev *tdev = data; +struct uniphier_tm_dev *tdev = tz->devdata;struct regmap *map = tdev->regmap;int ret;u32 temp;
@@ -204,7 +204,7 @@ static int uniphier_tm_get_temp(void *data, int *out_temp)return 0 ; } -static const struct thermal_zone_of_device_ops uniphier_of_thermal_ops = { +static const struct thermal_zone_device_ops uniphier_of_thermal_ops = { .get_temp = uniphier_tm_get_temp, };
@@ -289,8 +289,8 @@ static int uniphier_tm_probe(struct platform_device *pdev)platform_set_drvdata (pdev, tdev); - tdev->tz_dev =devm_thermal_zone_of_sensor_register (dev,0 , tdev, - &uniphier_of_thermal_ops); + tdev->tz_dev =devm_thermal_of_zone_register (dev,0 , tdev, + &uniphier_of_thermal_ops);if (IS_ERR (tdev->tz_dev)) {dev_err (dev,"failed to register sensor device\n" );return PTR_ERR (tdev->tz_dev);
Signature · 1 line
2.25.1
Re: [PATCH v5 04/33] thermal/drivers/uniphier: Switch to new of API
Quoted 8 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>
Quoted 46 lines
--- drivers/thermal/uniphier_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/thermal/uniphier_thermal.c +2
-2@@ -187,9 +187,9 @@ static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev) usleep_range(1000, 2000); /* The spec note says at least 1ms*/ } -static int uniphier_tm_get_temp (void *data,int *out_temp) +static int uniphier_tm_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct uniphier_tm_dev *tdev = data; +struct uniphier_tm_dev *tdev = tz->devdata;struct regmap *map = tdev->regmap; int ret; u32 temp;drivers/thermal/uniphier_thermal.c +1
-1@@ -204,7 +204,7 @@ static int uniphier_tm_get_temp(void *data, int *out_temp)return 0 ; } -static const struct thermal_zone_of_device_ops uniphier_of_thermal_ops = { +static const struct thermal_zone_device_ops uniphier_of_thermal_ops = { .get_temp = uniphier_tm_get_temp,};drivers/thermal/uniphier_thermal.c +2
-2@@ -289,8 +289,8 @@ static int uniphier_tm_probe(struct platform_device *pdev)platform_set_drvdata (pdev, tdev); - tdev->tz_dev =devm_thermal_zone_of_sensor_register (dev,0 , tdev, - &uniphier_of_thermal_ops); + tdev->tz_dev =devm_thermal_of_zone_register (dev,0 , tdev, + &uniphier_of_thermal_ops);if (IS_ERR (tdev->tz_dev)) {
Quoted 3 lines
dev_err(dev, "failed to register sensor device\n"); return PTR_ERR(tdev->tz_dev);
---
Best Regards
Kunihiko Hayashi
[thermal: thermal/next] thermal/drivers/uniphier: Switch to new of API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: c5f12023ff1d5622c7499352786233399beab7f8 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//c5f12023ff1d5622c7499352786233399beab7f8 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:20 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/drivers/uniphier: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/uniphier_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/uniphier_thermal.c +5 -5
@@ -187,9 +187,9 @@ static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev)usleep_range (1000 ,2000 );/* The spec note says at least 1ms */ } -static int uniphier_tm_get_temp (void *data,int *out_temp) +static int uniphier_tm_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct uniphier_tm_dev *tdev = data; +struct uniphier_tm_dev *tdev = tz->devdata;struct regmap *map = tdev->regmap;int ret;u32 temp;
@@ -204,7 +204,7 @@ static int uniphier_tm_get_temp(void *data, int *out_temp)return 0 ; } -static const struct thermal_zone_of_device_ops uniphier_of_thermal_ops = { +static const struct thermal_zone_device_ops uniphier_of_thermal_ops = { .get_temp = uniphier_tm_get_temp, };
@@ -289,8 +289,8 @@ static int uniphier_tm_probe(struct platform_device *pdev)platform_set_drvdata (pdev, tdev); - tdev->tz_dev =devm_thermal_zone_of_sensor_register (dev,0 , tdev, - &uniphier_of_thermal_ops); + tdev->tz_dev =devm_thermal_of_zone_register (dev,0 , tdev, + &uniphier_of_thermal_ops);if (IS_ERR (tdev->tz_dev)) {dev_err (dev,"failed to register sensor device\n" );return PTR_ERR (tdev->tz_dev);
PATCH v5 5/33 thermal/drivers/generic-adc: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/thermal-generic-adc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/thermal-generic-adc.c +5 -5
@@ -52,9 +52,9 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)return temp; } -static int gadc_thermal_get_temp (void *data,int *temp) +static int gadc_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct gadc_thermal_info *gti = data; +struct gadc_thermal_info *gti = tz->devdata;int val;int ret;
@@ -68,7 +68,7 @@ static int gadc_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops gadc_thermal_ops = { +static const struct thermal_zone_device_ops gadc_thermal_ops = { .get_temp = gadc_thermal_get_temp, };
@@ -143,8 +143,8 @@ static int gadc_thermal_probe(struct platform_device *pdev) gti->dev = &pdev->dev;platform_set_drvdata (pdev, gti); - gti->tz_dev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , gti, - &gadc_thermal_ops); + gti->tz_dev =devm_thermal_of_zone_register (&pdev->dev,0 , gti, + &gadc_thermal_ops);if (IS_ERR (gti->tz_dev)) { ret =PTR_ERR (gti->tz_dev);if (ret != -EPROBE_DEFER )
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/generic-adc: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 2ff66cba5beb9302f5787fd34617c5f64ad98309 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//2ff66cba5beb9302f5787fd34617c5f64ad98309 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:21 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/drivers/generic-adc: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/thermal-generic-adc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/thermal-generic-adc.c +5 -5
@@ -52,9 +52,9 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)return temp; } -static int gadc_thermal_get_temp (void *data,int *temp) +static int gadc_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct gadc_thermal_info *gti = data; +struct gadc_thermal_info *gti = tz->devdata;int val;int ret;
@@ -68,7 +68,7 @@ static int gadc_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops gadc_thermal_ops = { +static const struct thermal_zone_device_ops gadc_thermal_ops = { .get_temp = gadc_thermal_get_temp, };
@@ -143,8 +143,8 @@ static int gadc_thermal_probe(struct platform_device *pdev) gti->dev = &pdev->dev;platform_set_drvdata (pdev, gti); - gti->tz_dev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , gti, - &gadc_thermal_ops); + gti->tz_dev =devm_thermal_of_zone_register (&pdev->dev,0 , gti, + &gadc_thermal_ops);if (IS_ERR (gti->tz_dev)) { ret =PTR_ERR (gti->tz_dev);if (ret != -EPROBE_DEFER )
PATCH v5 6/33 thermal/drivers/mmio: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/thermal_mmio.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/thermal/thermal_mmio.c +8 -9
@@ -20,11 +20,10 @@ static u32 thermal_mmio_readb(void __iomem *mmio_base)return readb (mmio_base); } -static int thermal_mmio_get_temperature (void *private,int *temp) +static int thermal_mmio_get_temperature (struct thermal_zone_device *tz,int *temp) {int t; -struct thermal_mmio *sensor = - (struct thermal_mmio *)private; +struct thermal_mmio *sensor = tz->devdata; t = sensor->read_mmio (sensor->mmio_base) & sensor->mask; t *= sensor->factor;
@@ -34,7 +33,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops thermal_mmio_ops = { +static const struct thermal_zone_device_ops thermal_mmio_ops = { .get_temp = thermal_mmio_get_temperature, };
@@ -68,10 +67,10 @@ static int thermal_mmio_probe(struct platform_device *pdev) } } - thermal_zone =devm_thermal_zone_of_sensor_register (&pdev->dev, -0 , - sensor, - &thermal_mmio_ops); + thermal_zone =devm_thermal_of_zone_register (&pdev->dev, +0 , + sensor, + &thermal_mmio_ops);if (IS_ERR (thermal_zone)) { dev_err(&pdev->dev, "failed to register sensor (%ld)\n",
@@ -79,7 +78,7 @@ static int thermal_mmio_probe(struct platform_device *pdev)return PTR_ERR (thermal_zone); } -thermal_mmio_get_temperature (sensor, &temperature); +thermal_mmio_get_temperature (thermal_zone, &temperature);dev_info (&pdev->dev,"thermal mmio sensor %s registered, current temperature: %d\n" , pdev->name, temperature);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/mmio: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 44b5554d98d422a4411341d9aed5352c2ce34fc1 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//44b5554d98d422a4411341d9aed5352c2ce34fc1 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:22 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:37 +02:00
thermal/drivers/mmio: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/thermal_mmio.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/thermal/thermal_mmio.c +8 -9
@@ -20,11 +20,10 @@ static u32 thermal_mmio_readb(void __iomem *mmio_base)return readb (mmio_base); } -static int thermal_mmio_get_temperature (void *private,int *temp) +static int thermal_mmio_get_temperature (struct thermal_zone_device *tz,int *temp) {int t; -struct thermal_mmio *sensor = - (struct thermal_mmio *)private; +struct thermal_mmio *sensor = tz->devdata; t = sensor->read_mmio (sensor->mmio_base) & sensor->mask; t *= sensor->factor;
@@ -34,7 +33,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops thermal_mmio_ops = { +static const struct thermal_zone_device_ops thermal_mmio_ops = { .get_temp = thermal_mmio_get_temperature, };
@@ -68,10 +67,10 @@ static int thermal_mmio_probe(struct platform_device *pdev) } } - thermal_zone =devm_thermal_zone_of_sensor_register (&pdev->dev, -0 , - sensor, - &thermal_mmio_ops); + thermal_zone =devm_thermal_of_zone_register (&pdev->dev, +0 , + sensor, + &thermal_mmio_ops);if (IS_ERR (thermal_zone)) { dev_err(&pdev->dev, "failed to register sensor (%ld)\n",
@@ -79,7 +78,7 @@ static int thermal_mmio_probe(struct platform_device *pdev)return PTR_ERR (thermal_zone); } -thermal_mmio_get_temperature (sensor, &temperature); +thermal_mmio_get_temperature (thermal_zone, &temperature);dev_info (&pdev->dev,"thermal mmio sensor %s registered, current temperature: %d\n" , pdev->name, temperature);
PATCH v5 7/33 thermal/drivers/tegra: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/tegra/soctherm.c | 21 ++++++++++----------- drivers/thermal/tegra/tegra-bpmp-thermal.c | 19 ++++++++++++------- drivers/thermal/tegra/tegra30-tsensor.c | 12 ++++++------ 3 files changed, 28 insertions(+), 24 deletions(-)
drivers/thermal/tegra/soctherm.c +10 -11
@@ -421,9 +421,9 @@ static int translate_temp(u16 val)return t; } -static int tegra_thermctl_get_temp (void *data,int *out_temp) +static int tegra_thermctl_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct tegra_thermctl_zone *zone = data; +struct tegra_thermctl_zone *zone = tz->devdata;u32 val; val =readl (zone->reg);
@@ -582,10 +582,9 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)return temp; } -static int tegra_thermctl_set_trip_temp (void *data,int trip,int temp) +static int tegra_thermctl_set_trip_temp (struct thermal_zone_device *tz,int trip,int temp) { -struct tegra_thermctl_zone *zone = data; -struct thermal_zone_device *tz = zone->tz; +struct tegra_thermctl_zone *zone = tz->devdata;struct tegra_soctherm *ts = zone->ts;const struct tegra_tsensor_group *sg = zone->sg;struct device *dev = zone->dev;
@@ -657,9 +656,9 @@ static void thermal_irq_disable(struct tegra_thermctl_zone *zn)mutex_unlock (&zn->ts->thermctl_lock); } -static int tegra_thermctl_set_trips (void *data,int lo,int hi) +static int tegra_thermctl_set_trips (struct thermal_zone_device *tz,int lo,int hi) { -struct tegra_thermctl_zone *zone = data; +struct tegra_thermctl_zone *zone = tz->devdata;u32 r;thermal_irq_disable (zone);
@@ -682,7 +681,7 @@ static int tegra_thermctl_set_trips(void *data, int lo, int hi)return 0 ; } -static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = { +static const struct thermal_zone_device_ops tegra_of_thermal_ops = { .get_temp = tegra_thermctl_get_temp, .set_trip_temp = tegra_thermctl_set_trip_temp, .set_trips = tegra_thermctl_set_trips,
@@ -2194,9 +2193,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev) zone->sg = soc->ttgs[i]; zone->ts = tegra; - z =devm_thermal_zone_of_sensor_register (&pdev->dev, - soc->ttgs[i]->id, zone, - &tegra_of_thermal_ops); + z =devm_thermal_of_zone_register (&pdev->dev, + soc->ttgs[i]->id, zone, + &tegra_of_thermal_ops);if (IS_ERR (z)) { err =PTR_ERR (z); dev_err(&pdev->dev, "failed to register sensor: %d\n",
drivers/thermal/tegra/tegra-bpmp-thermal.c +12 -7
@@ -30,9 +30,9 @@ struct tegra_bpmp_thermal {struct tegra_bpmp_thermal_zone **zones; }; -static int tegra_bpmp_thermal_get_temp (void *data,int *out_temp) +static int __tegra_bpmp_thermal_get_temp (struct tegra_bpmp_thermal_zone *zone, +int *out_temp) { -struct tegra_bpmp_thermal_zone *zone = data;struct mrq_thermal_host_to_bpmp_request req;union mrq_thermal_bpmp_to_host_response reply;struct tegra_bpmp_message msg;
@@ -60,9 +60,14 @@ static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)return 0 ; } -static int tegra_bpmp_thermal_set_trips (void *data,int low,int high) +static int tegra_bpmp_thermal_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct tegra_bpmp_thermal_zone *zone = data; +return __tegra_bpmp_thermal_get_temp (tz->devdata, out_temp); +} + +static int tegra_bpmp_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) +{ +struct tegra_bpmp_thermal_zone *zone = tz->devdata;struct mrq_thermal_host_to_bpmp_request req;struct tegra_bpmp_message msg;int err;
@@ -157,7 +162,7 @@ static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,return 0 ; } -static const struct thermal_zone_of_device_ops tegra_bpmp_of_thermal_ops = { +static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops = { .get_temp = tegra_bpmp_thermal_get_temp, .set_trips = tegra_bpmp_thermal_set_trips, };
@@ -200,13 +205,13 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev) zone->idx = i; zone->tegra = tegra; - err =tegra_bpmp_thermal_get_temp (zone, &temp); + err =__tegra_bpmp_thermal_get_temp (zone, &temp);if (err <0 ) {devm_kfree (&pdev->dev, zone);continue ; } - tzd =devm_thermal_zone_of_sensor_register ( + tzd =devm_thermal_of_zone_register ( &pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) == -EPROBE_DEFER )
drivers/thermal/tegra/tegra30-tsensor.c +6 -6
@@ -159,9 +159,9 @@ static void devm_tegra_tsensor_hw_disable(void *data)tegra_tsensor_hw_disable (ts); } -static int tegra_tsensor_get_temp (void *data,int *temp) +static int tegra_tsensor_get_temp (struct thermal_zone_device *tz,int *temp) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;int err, c1, c2, c3, c4, counter;u32 val;
@@ -217,9 +217,9 @@ static int tegra_tsensor_temp_to_counter(const struct tegra_tsensor *ts, int temreturn DIV_ROUND_CLOSEST (c2 *1000000 - ts->calib.b, ts->calib.a); } -static int tegra_tsensor_set_trips (void *data,int low,int high) +static int tegra_tsensor_set_trips (struct thermal_zone_device *tz,int low,int high) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;u32 val;
@@ -240,7 +240,7 @@ static int tegra_tsensor_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops ops = { +static const struct thermal_zone_device_ops ops = { .get_temp = tegra_tsensor_get_temp, .set_trips = tegra_tsensor_set_trips, };
@@ -516,7 +516,7 @@ static int tegra_tsensor_register_channel(struct tegra_tsensor *ts, tsc->id = id; tsc->regs = ts->regs +0x40 * (hw_id +1 ); - tsc->tzd =devm_thermal_zone_of_sensor_register (ts->dev, id, tsc, &ops); + tsc->tzd =devm_thermal_of_zone_register (ts->dev, id, tsc, &ops);if (IS_ERR (tsc->tzd)) {if (PTR_ERR (tsc->tzd) != -ENODEV ) return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd),
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/tegra: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 6fc2e1a5f98feb9cf0698b69c90701e0b9de2bf5 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//6fc2e1a5f98feb9cf0698b69c90701e0b9de2bf5 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:23 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/tegra: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/tegra/soctherm.c | 21 ++++++++++----------- drivers/thermal/tegra/tegra-bpmp-thermal.c | 19 ++++++++++++------- drivers/thermal/tegra/tegra30-tsensor.c | 12 ++++++------ 3 files changed, 28 insertions(+), 24 deletions(-)
drivers/thermal/tegra/soctherm.c +10 -11
@@ -421,9 +421,9 @@ static int translate_temp(u16 val)return t; } -static int tegra_thermctl_get_temp (void *data,int *out_temp) +static int tegra_thermctl_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct tegra_thermctl_zone *zone = data; +struct tegra_thermctl_zone *zone = tz->devdata;u32 val; val =readl (zone->reg);
@@ -582,10 +582,9 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)return temp; } -static int tegra_thermctl_set_trip_temp (void *data,int trip,int temp) +static int tegra_thermctl_set_trip_temp (struct thermal_zone_device *tz,int trip,int temp) { -struct tegra_thermctl_zone *zone = data; -struct thermal_zone_device *tz = zone->tz; +struct tegra_thermctl_zone *zone = tz->devdata;struct tegra_soctherm *ts = zone->ts;const struct tegra_tsensor_group *sg = zone->sg;struct device *dev = zone->dev;
@@ -657,9 +656,9 @@ static void thermal_irq_disable(struct tegra_thermctl_zone *zn)mutex_unlock (&zn->ts->thermctl_lock); } -static int tegra_thermctl_set_trips (void *data,int lo,int hi) +static int tegra_thermctl_set_trips (struct thermal_zone_device *tz,int lo,int hi) { -struct tegra_thermctl_zone *zone = data; +struct tegra_thermctl_zone *zone = tz->devdata;u32 r;thermal_irq_disable (zone);
@@ -682,7 +681,7 @@ static int tegra_thermctl_set_trips(void *data, int lo, int hi)return 0 ; } -static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = { +static const struct thermal_zone_device_ops tegra_of_thermal_ops = { .get_temp = tegra_thermctl_get_temp, .set_trip_temp = tegra_thermctl_set_trip_temp, .set_trips = tegra_thermctl_set_trips,
@@ -2194,9 +2193,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev) zone->sg = soc->ttgs[i]; zone->ts = tegra; - z =devm_thermal_zone_of_sensor_register (&pdev->dev, - soc->ttgs[i]->id, zone, - &tegra_of_thermal_ops); + z =devm_thermal_of_zone_register (&pdev->dev, + soc->ttgs[i]->id, zone, + &tegra_of_thermal_ops);if (IS_ERR (z)) { err =PTR_ERR (z); dev_err(&pdev->dev, "failed to register sensor: %d\n",
drivers/thermal/tegra/tegra-bpmp-thermal.c +12 -7
@@ -30,9 +30,9 @@ struct tegra_bpmp_thermal {struct tegra_bpmp_thermal_zone **zones; }; -static int tegra_bpmp_thermal_get_temp (void *data,int *out_temp) +static int __tegra_bpmp_thermal_get_temp (struct tegra_bpmp_thermal_zone *zone, +int *out_temp) { -struct tegra_bpmp_thermal_zone *zone = data;struct mrq_thermal_host_to_bpmp_request req;union mrq_thermal_bpmp_to_host_response reply;struct tegra_bpmp_message msg;
@@ -60,9 +60,14 @@ static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)return 0 ; } -static int tegra_bpmp_thermal_set_trips (void *data,int low,int high) +static int tegra_bpmp_thermal_get_temp (struct thermal_zone_device *tz,int *out_temp) { -struct tegra_bpmp_thermal_zone *zone = data; +return __tegra_bpmp_thermal_get_temp (tz->devdata, out_temp); +} + +static int tegra_bpmp_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) +{ +struct tegra_bpmp_thermal_zone *zone = tz->devdata;struct mrq_thermal_host_to_bpmp_request req;struct tegra_bpmp_message msg;int err;
@@ -157,7 +162,7 @@ static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,return 0 ; } -static const struct thermal_zone_of_device_ops tegra_bpmp_of_thermal_ops = { +static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops = { .get_temp = tegra_bpmp_thermal_get_temp, .set_trips = tegra_bpmp_thermal_set_trips, };
@@ -200,13 +205,13 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev) zone->idx = i; zone->tegra = tegra; - err =tegra_bpmp_thermal_get_temp (zone, &temp); + err =__tegra_bpmp_thermal_get_temp (zone, &temp);if (err <0 ) {devm_kfree (&pdev->dev, zone);continue ; } - tzd =devm_thermal_zone_of_sensor_register ( + tzd =devm_thermal_of_zone_register ( &pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) == -EPROBE_DEFER )
drivers/thermal/tegra/tegra30-tsensor.c +6 -6
@@ -159,9 +159,9 @@ static void devm_tegra_tsensor_hw_disable(void *data)tegra_tsensor_hw_disable (ts); } -static int tegra_tsensor_get_temp (void *data,int *temp) +static int tegra_tsensor_get_temp (struct thermal_zone_device *tz,int *temp) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;int err, c1, c2, c3, c4, counter;u32 val;
@@ -217,9 +217,9 @@ static int tegra_tsensor_temp_to_counter(const struct tegra_tsensor *ts, int temreturn DIV_ROUND_CLOSEST (c2 *1000000 - ts->calib.b, ts->calib.a); } -static int tegra_tsensor_set_trips (void *data,int low,int high) +static int tegra_tsensor_set_trips (struct thermal_zone_device *tz,int low,int high) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;u32 val;
@@ -240,7 +240,7 @@ static int tegra_tsensor_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops ops = { +static const struct thermal_zone_device_ops ops = { .get_temp = tegra_tsensor_get_temp, .set_trips = tegra_tsensor_set_trips, };
@@ -516,7 +516,7 @@ static int tegra_tsensor_register_channel(struct tegra_tsensor *ts, tsc->id = id; tsc->regs = ts->regs +0x40 * (hw_id +1 ); - tsc->tzd =devm_thermal_zone_of_sensor_register (ts->dev, id, tsc, &ops); + tsc->tzd =devm_thermal_of_zone_register (ts->dev, id, tsc, &ops);if (IS_ERR (tsc->tzd)) {if (PTR_ERR (tsc->tzd) != -ENODEV ) return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd),
Re: [PATCH v5 07/33] thermal/drivers/tegra: Switch to new of API
In reply to Daniel LezcanoQuoted 38 lines · Daniel Lezcano
drivers/thermal/tegra/tegra30-tsensor.c +5
-5@@ -159,9 +159,9 @@ static void devm_tegra_tsensor_hw_disable(void *data)tegra_tsensor_hw_disable (ts); } -static int tegra_tsensor_get_temp (void *data,int *temp) +static int tegra_tsensor_get_temp (struct thermal_zone_device *tz,int *temp) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;int err, c1, c2, c3, c4, counter;u32 val;@@ -217,9 +217,9 @@ static int tegra_tsensor_temp_to_counter(const struct tegra_tsensor *ts, int temreturn DIV_ROUND_CLOSEST (c2 *1000000 - ts->calib.b, ts->calib.a); } -static int tegra_tsensor_set_trips (void *data,int low,int high) +static int tegra_tsensor_set_trips (struct thermal_zone_device *tz,int low,int high) { -const struct tegra_tsensor_channel *tsc = data; +const struct tegra_tsensor_channel *tsc = tz->devdata;const struct tegra_tsensor *ts = tsc->ts;u32 val;@@ -240,7 +240,7 @@ static int tegra_tsensor_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops ops = { +static const struct thermal_zone_device_ops ops = { .get_temp = tegra_tsensor_get_temp, .set_trips = tegra_tsensor_set_trips, };
drivers/thermal/tegra/tegra30-tsensor.c static int tegra_tsensor_register_channel(struct tegra_tsensor *ts, · line 522
Quoted 8 lines
drivers/thermal/tegra/tegra30-tsensor.c +1
-1@@ -516,7 +516,7 @@ static int tegra_tsensor_register_channel(struct tegra_tsensor *ts, tsc->id = id; tsc->regs = ts->regs +0x40 * (hw_id +1 ); - tsc->tzd =devm_thermal_zone_of_sensor_register (ts->dev, id, tsc, &ops); + tsc->tzd =devm_thermal_of_zone_register (ts->dev, id, tsc, &ops);if (IS_ERR (tsc->tzd)) {if (PTR_ERR (tsc->tzd) != -ENODEV ) return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd),
Signature · 2 lines
Best regards, Dmitry
PATCH v5 8/33 thermal/drivers/sun8i: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/sun8i_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/sun8i_thermal.c +7 -7
@@ -108,9 +108,9 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev,return -1590 * reg /10 +276000 ; } -static int sun8i_ths_get_temp (void *data,int *temp) +static int sun8i_ths_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tsensor *s = data; +struct tsensor *s = tz->devdata;struct ths_device *tmdev = s->tmdev;int val =0 ;
@@ -135,7 +135,7 @@ static int sun8i_ths_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops ths_ops = { +static const struct thermal_zone_device_ops ths_ops = { .get_temp = sun8i_ths_get_temp, };
@@ -468,10 +468,10 @@ static int sun8i_ths_register(struct ths_device *tmdev) tmdev->sensor[i].tmdev = tmdev; tmdev->sensor[i].id = i; tmdev->sensor[i].tzd = -devm_thermal_zone_of_sensor_register (tmdev->dev, - i, - &tmdev->sensor[i], - &ths_ops); +devm_thermal_of_zone_register (tmdev->dev, + i, + &tmdev->sensor[i], + &ths_ops);if (IS_ERR (tmdev->sensor[i].tzd))return PTR_ERR (tmdev->sensor[i].tzd);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/sun8i: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 2e2150c7946764f289bafd716cbd6721283dc9ce Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//2e2150c7946764f289bafd716cbd6721283dc9ce Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:24 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/sun8i: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/sun8i_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/sun8i_thermal.c +7 -7
@@ -108,9 +108,9 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev,return -1590 * reg /10 +276000 ; } -static int sun8i_ths_get_temp (void *data,int *temp) +static int sun8i_ths_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tsensor *s = data; +struct tsensor *s = tz->devdata;struct ths_device *tmdev = s->tmdev;int val =0 ;
@@ -135,7 +135,7 @@ static int sun8i_ths_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops ths_ops = { +static const struct thermal_zone_device_ops ths_ops = { .get_temp = sun8i_ths_get_temp, };
@@ -468,10 +468,10 @@ static int sun8i_ths_register(struct ths_device *tmdev) tmdev->sensor[i].tmdev = tmdev; tmdev->sensor[i].id = i; tmdev->sensor[i].tzd = -devm_thermal_zone_of_sensor_register (tmdev->dev, - i, - &tmdev->sensor[i], - &ths_ops); +devm_thermal_of_zone_register (tmdev->dev, + i, + &tmdev->sensor[i], + &ths_ops);if (IS_ERR (tmdev->sensor[i].tzd))return PTR_ERR (tmdev->sensor[i].tzd);
PATCH v5 9/33 thermal/drivers/sprd: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/sprd_thermal.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/thermal/sprd_thermal.c +9 -9
@@ -204,9 +204,9 @@ static int sprd_thm_temp_to_rawdata(int temp, struct sprd_thermal_sensor *sen)return clamp (val, val, (u32)(SPRD_THM_RAW_DATA_HIGH -1 )); } -static int sprd_thm_read_temp (void *devdata,int *temp) +static int sprd_thm_read_temp (struct thermal_zone_device *tz,int *temp) { -struct sprd_thermal_sensor *sen = devdata; +struct sprd_thermal_sensor *sen = tz->devdata;u32 data; data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
@@ -217,7 +217,7 @@ static int sprd_thm_read_temp(void *devdata, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sprd_thm_ops = { +static const struct thermal_zone_device_ops sprd_thm_ops = { .get_temp = sprd_thm_read_temp, };
@@ -408,10 +408,10 @@ static int sprd_thm_probe(struct platform_device *pdev)sprd_thm_sensor_init (thm, sen); - sen->tzd =devm_thermal_zone_of_sensor_register (sen->dev, - sen->id, - sen, - &sprd_thm_ops); + sen->tzd =devm_thermal_of_zone_register (sen->dev, + sen->id, + sen, + &sprd_thm_ops);if (IS_ERR (sen->tzd)) {dev_err (&pdev->dev,"register thermal zone failed %d\n" , sen->id);
@@ -523,8 +523,8 @@ static int sprd_thm_remove(struct platform_device *pdev)for (i =0 ; i < thm->nr_sensors; i++) {sprd_thm_toggle_sensor (thm->sensor[i], false); -devm_thermal_zone_of_sensor_unregister (&pdev->dev, - thm->sensor[i]->tzd); +devm_thermal_of_zone_unregister (&pdev->dev, + thm->sensor[i]->tzd); }clk_disable_unprepare (thm->clk);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/sprd: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 7f689a2ef4f6422b200682f80be225c1f61218f7 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//7f689a2ef4f6422b200682f80be225c1f61218f7 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:25 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/sprd: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/sprd_thermal.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/thermal/sprd_thermal.c +9 -9
@@ -204,9 +204,9 @@ static int sprd_thm_temp_to_rawdata(int temp, struct sprd_thermal_sensor *sen)return clamp (val, val, (u32)(SPRD_THM_RAW_DATA_HIGH -1 )); } -static int sprd_thm_read_temp (void *devdata,int *temp) +static int sprd_thm_read_temp (struct thermal_zone_device *tz,int *temp) { -struct sprd_thermal_sensor *sen = devdata; +struct sprd_thermal_sensor *sen = tz->devdata;u32 data; data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
@@ -217,7 +217,7 @@ static int sprd_thm_read_temp(void *devdata, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sprd_thm_ops = { +static const struct thermal_zone_device_ops sprd_thm_ops = { .get_temp = sprd_thm_read_temp, };
@@ -408,10 +408,10 @@ static int sprd_thm_probe(struct platform_device *pdev)sprd_thm_sensor_init (thm, sen); - sen->tzd =devm_thermal_zone_of_sensor_register (sen->dev, - sen->id, - sen, - &sprd_thm_ops); + sen->tzd =devm_thermal_of_zone_register (sen->dev, + sen->id, + sen, + &sprd_thm_ops);if (IS_ERR (sen->tzd)) {dev_err (&pdev->dev,"register thermal zone failed %d\n" , sen->id);
@@ -523,8 +523,8 @@ static int sprd_thm_remove(struct platform_device *pdev)for (i =0 ; i < thm->nr_sensors; i++) {sprd_thm_toggle_sensor (thm->sensor[i], false); -devm_thermal_zone_of_sensor_unregister (&pdev->dev, - thm->sensor[i]->tzd); +devm_thermal_of_zone_unregister (&pdev->dev, + thm->sensor[i]->tzd); }clk_disable_unprepare (thm->clk);
PATCH v5 10/33 thermal/drivers/broadcom: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/broadcom/bcm2711_thermal.c | 14 +++--- drivers/thermal/broadcom/bcm2835_thermal.c | 14 +++--- drivers/thermal/broadcom/brcmstb_thermal.c | 20 ++++----- drivers/thermal/broadcom/ns-thermal.c | 50 +++++++++------------- drivers/thermal/broadcom/sr-thermal.c | 16 +++---- 5 files changed, 53 insertions(+), 61 deletions(-)
drivers/thermal/broadcom/bcm2711_thermal.c +7 -7
@@ -31,11 +31,11 @@ struct bcm2711_thermal_priv {struct thermal_zone_device *thermal; }; -static int bcm2711_get_temp (void *data,int *temp) +static int bcm2711_get_temp (struct thermal_zone_device *tz,int *temp) { -struct bcm2711_thermal_priv *priv = data; -int slope =thermal_zone_get_slope (priv->thermal); -int offset =thermal_zone_get_offset (priv->thermal); +struct bcm2711_thermal_priv *priv = tz->devdata; +int slope =thermal_zone_get_slope (tz); +int offset =thermal_zone_get_offset (tz);u32 val;int ret;
@@ -54,7 +54,7 @@ static int bcm2711_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = { +static const struct thermal_zone_device_ops bcm2711_thermal_of_ops = { .get_temp = bcm2711_get_temp, };
@@ -88,8 +88,8 @@ static int bcm2711_thermal_probe(struct platform_device *pdev) } priv->regmap = regmap; - thermal =devm_thermal_zone_of_sensor_register (dev,0 , priv, - &bcm2711_thermal_of_ops); + thermal =devm_thermal_of_zone_register (dev,0 , priv, + &bcm2711_thermal_of_ops);if (IS_ERR (thermal)) { ret =PTR_ERR (thermal);dev_err (dev,"could not register sensor: %d\n" , ret);
drivers/thermal/broadcom/bcm2835_thermal.c +7 -7
@@ -88,9 +88,9 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope)return temp; } -static int bcm2835_thermal_get_temp (void *d,int *temp) +static int bcm2835_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct bcm2835_thermal_data *data = d; +struct bcm2835_thermal_data *data = tz->devdata;u32 val =readl (data->regs +BCM2835_TS_TSENSSTAT );if (!(val &BCM2835_TS_TSENSSTAT_VALID ))
@@ -135,7 +135,7 @@ static void bcm2835_thermal_debugfs(struct platform_device *pdev)debugfs_create_regset32 ("regset" ,0444 , data->debugfsdir, regset); } -static const struct thermal_zone_of_device_ops bcm2835_thermal_ops = { +static const struct thermal_zone_device_ops bcm2835_thermal_ops = { .get_temp = bcm2835_thermal_get_temp, };
@@ -206,8 +206,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) data->clk, rate);/* register of thermal sensor and get info from DT */ - tz =thermal_zone_of_sensor_register (&pdev->dev,0 , data, - &bcm2835_thermal_ops); + tz =devm_thermal_of_zone_register (&pdev->dev,0 , data, + &bcm2835_thermal_ops);if (IS_ERR (tz)) { err =PTR_ERR (tz); dev_err(&pdev->dev,
@@ -277,7 +277,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)return 0 ; err_tz: -thermal_zone_of_sensor_unregister (&pdev->dev, tz); +thermal_of_zone_unregister (tz); err_clk:clk_disable_unprepare (data->clk);
@@ -290,7 +290,7 @@ static int bcm2835_thermal_remove(struct platform_device *pdev)struct thermal_zone_device *tz = data->tz;debugfs_remove_recursive (data->debugfsdir); -thermal_zone_of_sensor_unregister (&pdev->dev, tz); +thermal_of_zone_unregister (tz);clk_disable_unprepare (data->clk);return 0 ;
drivers/thermal/broadcom/brcmstb_thermal.c +10 -10
@@ -105,7 +105,7 @@ static struct avs_tmon_trip avs_tmon_trips[] = {struct brcmstb_thermal_params {unsigned int offset;unsigned int mult; -const struct thermal_zone_of_device_ops *of_ops; +const struct thermal_zone_device_ops *of_ops; };struct brcmstb_thermal_priv {
@@ -150,9 +150,9 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,return (u32)((offset - temp) / mult); } -static int brcmstb_get_temp (void *data,int *temp) +static int brcmstb_get_temp (struct thermal_zone_device *tz,int *temp) { -struct brcmstb_thermal_priv *priv = data; +struct brcmstb_thermal_priv *priv = tz->devdata;u32 val;long t;
@@ -260,9 +260,9 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data)return IRQ_HANDLED ; } -static int brcmstb_set_trips (void *data,int low,int high) +static int brcmstb_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct brcmstb_thermal_priv *priv = data; +struct brcmstb_thermal_priv *priv = tz->devdata;dev_dbg (priv->dev,"set trips %d <--> %d\n" , low, high);
@@ -288,7 +288,7 @@ static int brcmstb_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops brcmstb_16nm_of_ops = { +static const struct thermal_zone_device_ops brcmstb_16nm_of_ops = { .get_temp = brcmstb_get_temp, };
@@ -298,7 +298,7 @@ static const struct brcmstb_thermal_params brcmstb_16nm_params = { .of_ops = &brcmstb_16nm_of_ops, }; -static const struct thermal_zone_of_device_ops brcmstb_28nm_of_ops = { +static const struct thermal_zone_device_ops brcmstb_28nm_of_ops = { .get_temp = brcmstb_get_temp, .set_trips = brcmstb_set_trips, };
@@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);static int brcmstb_thermal_probe (struct platform_device *pdev) { -const struct thermal_zone_of_device_ops *of_ops; +const struct thermal_zone_device_ops *of_ops;struct thermal_zone_device *thermal;struct brcmstb_thermal_priv *priv;struct resource *res;
@@ -341,8 +341,8 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); of_ops = priv->temp_params->of_ops; - thermal =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , priv, - of_ops); + thermal =devm_thermal_of_zone_register (&pdev->dev,0 , priv, + of_ops);if (IS_ERR (thermal)) { ret =PTR_ERR (thermal);dev_err (&pdev->dev,"could not register sensor: %d\n" , ret);
drivers/thermal/broadcom/ns-thermal.c +21 -29
90 lines not on this page · raw message
drivers/thermal/broadcom/sr-thermal.c +8 -8
@@ -19,7 +19,6 @@#define SR_TMON_MAX_LIST 6struct sr_tmon { -struct thermal_zone_device *tz;unsigned int crit_temp;unsigned int tmon_id;struct sr_thermal *priv;
@@ -31,9 +30,9 @@ struct sr_thermal {struct sr_tmon tmon[SR_TMON_MAX_LIST ]; }; -static int sr_get_temp (void *data,int *temp) +static int sr_get_temp (struct thermal_zone_device *tz,int *temp) { -struct sr_tmon *tmon = data; +struct sr_tmon *tmon = tz->devdata;struct sr_thermal *sr_thermal = tmon->priv; *temp =readl (sr_thermal->regs +SR_TMON_TEMP_BASE (tmon->tmon_id));
@@ -41,13 +40,14 @@ static int sr_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sr_tz_ops = { +static const struct thermal_zone_device_ops sr_tz_ops = { .get_temp = sr_get_temp, };static int sr_thermal_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct thermal_zone_device *tz;struct sr_thermal *sr_thermal;struct sr_tmon *tmon;struct resource *res;
@@ -84,10 +84,10 @@ static int sr_thermal_probe(struct platform_device *pdev)writel (0 , sr_thermal->regs +SR_TMON_TEMP_BASE (i)); tmon->tmon_id = i; tmon->priv = sr_thermal; - tmon->tz =devm_thermal_zone_of_sensor_register (dev, i, tmon, - &sr_tz_ops); -if (IS_ERR (tmon->tz)) -return PTR_ERR (tmon->tz); + tz =devm_thermal_of_zone_register (dev, i, tmon, + &sr_tz_ops); +if (IS_ERR (tz)) +return PTR_ERR (tz);dev_dbg (dev,"thermal sensor %d registered\n" , i); }
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/broadcom: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 944441d878b0aebd87ec404fe86c322186da458d Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//944441d878b0aebd87ec404fe86c322186da458d Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:26 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/broadcom: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/broadcom/bcm2711_thermal.c | 14 +++--- drivers/thermal/broadcom/bcm2835_thermal.c | 14 +++--- drivers/thermal/broadcom/brcmstb_thermal.c | 20 ++++---- drivers/thermal/broadcom/ns-thermal.c | 50 ++++++++------------- drivers/thermal/broadcom/sr-thermal.c | 16 +++---- 5 files changed, 53 insertions(+), 61 deletions(-)
drivers/thermal/broadcom/bcm2711_thermal.c +7 -7
@@ -31,11 +31,11 @@ struct bcm2711_thermal_priv {struct thermal_zone_device *thermal; }; -static int bcm2711_get_temp (void *data,int *temp) +static int bcm2711_get_temp (struct thermal_zone_device *tz,int *temp) { -struct bcm2711_thermal_priv *priv = data; -int slope =thermal_zone_get_slope (priv->thermal); -int offset =thermal_zone_get_offset (priv->thermal); +struct bcm2711_thermal_priv *priv = tz->devdata; +int slope =thermal_zone_get_slope (tz); +int offset =thermal_zone_get_offset (tz);u32 val;int ret;
@@ -54,7 +54,7 @@ static int bcm2711_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = { +static const struct thermal_zone_device_ops bcm2711_thermal_of_ops = { .get_temp = bcm2711_get_temp, };
@@ -88,8 +88,8 @@ static int bcm2711_thermal_probe(struct platform_device *pdev) } priv->regmap = regmap; - thermal =devm_thermal_zone_of_sensor_register (dev,0 , priv, - &bcm2711_thermal_of_ops); + thermal =devm_thermal_of_zone_register (dev,0 , priv, + &bcm2711_thermal_of_ops);if (IS_ERR (thermal)) { ret =PTR_ERR (thermal);dev_err (dev,"could not register sensor: %d\n" , ret);
drivers/thermal/broadcom/bcm2835_thermal.c +7 -7
@@ -88,9 +88,9 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope)return temp; } -static int bcm2835_thermal_get_temp (void *d,int *temp) +static int bcm2835_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct bcm2835_thermal_data *data = d; +struct bcm2835_thermal_data *data = tz->devdata;u32 val =readl (data->regs +BCM2835_TS_TSENSSTAT );if (!(val &BCM2835_TS_TSENSSTAT_VALID ))
@@ -135,7 +135,7 @@ static void bcm2835_thermal_debugfs(struct platform_device *pdev)debugfs_create_regset32 ("regset" ,0444 , data->debugfsdir, regset); } -static const struct thermal_zone_of_device_ops bcm2835_thermal_ops = { +static const struct thermal_zone_device_ops bcm2835_thermal_ops = { .get_temp = bcm2835_thermal_get_temp, };
@@ -206,8 +206,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) data->clk, rate);/* register of thermal sensor and get info from DT */ - tz =thermal_zone_of_sensor_register (&pdev->dev,0 , data, - &bcm2835_thermal_ops); + tz =devm_thermal_of_zone_register (&pdev->dev,0 , data, + &bcm2835_thermal_ops);if (IS_ERR (tz)) { err =PTR_ERR (tz); dev_err(&pdev->dev,
@@ -277,7 +277,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)return 0 ; err_tz: -thermal_zone_of_sensor_unregister (&pdev->dev, tz); +thermal_of_zone_unregister (tz); err_clk:clk_disable_unprepare (data->clk);
@@ -290,7 +290,7 @@ static int bcm2835_thermal_remove(struct platform_device *pdev)struct thermal_zone_device *tz = data->tz;debugfs_remove_recursive (data->debugfsdir); -thermal_zone_of_sensor_unregister (&pdev->dev, tz); +thermal_of_zone_unregister (tz);clk_disable_unprepare (data->clk);return 0 ;
drivers/thermal/broadcom/brcmstb_thermal.c +10 -10
@@ -105,7 +105,7 @@ static struct avs_tmon_trip avs_tmon_trips[] = {struct brcmstb_thermal_params {unsigned int offset;unsigned int mult; -const struct thermal_zone_of_device_ops *of_ops; +const struct thermal_zone_device_ops *of_ops; };struct brcmstb_thermal_priv {
@@ -150,9 +150,9 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,return (u32)((offset - temp) / mult); } -static int brcmstb_get_temp (void *data,int *temp) +static int brcmstb_get_temp (struct thermal_zone_device *tz,int *temp) { -struct brcmstb_thermal_priv *priv = data; +struct brcmstb_thermal_priv *priv = tz->devdata;u32 val;long t;
@@ -260,9 +260,9 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data)return IRQ_HANDLED ; } -static int brcmstb_set_trips (void *data,int low,int high) +static int brcmstb_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct brcmstb_thermal_priv *priv = data; +struct brcmstb_thermal_priv *priv = tz->devdata;dev_dbg (priv->dev,"set trips %d <--> %d\n" , low, high);
@@ -288,7 +288,7 @@ static int brcmstb_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops brcmstb_16nm_of_ops = { +static const struct thermal_zone_device_ops brcmstb_16nm_of_ops = { .get_temp = brcmstb_get_temp, };
@@ -298,7 +298,7 @@ static const struct brcmstb_thermal_params brcmstb_16nm_params = { .of_ops = &brcmstb_16nm_of_ops, }; -static const struct thermal_zone_of_device_ops brcmstb_28nm_of_ops = { +static const struct thermal_zone_device_ops brcmstb_28nm_of_ops = { .get_temp = brcmstb_get_temp, .set_trips = brcmstb_set_trips, };
@@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);static int brcmstb_thermal_probe (struct platform_device *pdev) { -const struct thermal_zone_of_device_ops *of_ops; +const struct thermal_zone_device_ops *of_ops;struct thermal_zone_device *thermal;struct brcmstb_thermal_priv *priv;struct resource *res;
@@ -341,8 +341,8 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); of_ops = priv->temp_params->of_ops; - thermal =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , priv, - of_ops); + thermal =devm_thermal_of_zone_register (&pdev->dev,0 , priv, + of_ops);if (IS_ERR (thermal)) { ret =PTR_ERR (thermal);dev_err (&pdev->dev,"could not register sensor: %d\n" , ret);
drivers/thermal/broadcom/ns-thermal.c +21 -29
90 lines not on this page · raw message
drivers/thermal/broadcom/sr-thermal.c +8 -8
@@ -19,7 +19,6 @@#define SR_TMON_MAX_LIST 6struct sr_tmon { -struct thermal_zone_device *tz;unsigned int crit_temp;unsigned int tmon_id;struct sr_thermal *priv;
@@ -31,9 +30,9 @@ struct sr_thermal {struct sr_tmon tmon[SR_TMON_MAX_LIST ]; }; -static int sr_get_temp (void *data,int *temp) +static int sr_get_temp (struct thermal_zone_device *tz,int *temp) { -struct sr_tmon *tmon = data; +struct sr_tmon *tmon = tz->devdata;struct sr_thermal *sr_thermal = tmon->priv; *temp =readl (sr_thermal->regs +SR_TMON_TEMP_BASE (tmon->tmon_id));
@@ -41,13 +40,14 @@ static int sr_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sr_tz_ops = { +static const struct thermal_zone_device_ops sr_tz_ops = { .get_temp = sr_get_temp, };static int sr_thermal_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct thermal_zone_device *tz;struct sr_thermal *sr_thermal;struct sr_tmon *tmon;struct resource *res;
@@ -84,10 +84,10 @@ static int sr_thermal_probe(struct platform_device *pdev)writel (0 , sr_thermal->regs +SR_TMON_TEMP_BASE (i)); tmon->tmon_id = i; tmon->priv = sr_thermal; - tmon->tz =devm_thermal_zone_of_sensor_register (dev, i, tmon, - &sr_tz_ops); -if (IS_ERR (tmon->tz)) -return PTR_ERR (tmon->tz); + tz =devm_thermal_of_zone_register (dev, i, tmon, + &sr_tz_ops); +if (IS_ERR (tz)) +return PTR_ERR (tz);dev_dbg (dev,"thermal sensor %d registered\n" , i); }
PATCH v5 11/33 thermal/drivers/qcom: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 19 +++++++++---------- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 12 ++++++------ drivers/thermal/qcom/tsens.c | 16 ++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-)
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +9 -10
@@ -357,9 +357,9 @@ static irqreturn_t adc_tm5_gen2_isr(int irq, void *data)return IRQ_HANDLED ; } -static int adc_tm5_get_temp (void *data,int *temp) +static int adc_tm5_get_temp (struct thermal_zone_device *tz,int *temp) { -struct adc_tm5_channel *channel = data; +struct adc_tm5_channel *channel = tz->devdata;int ret;if (!channel || !channel->iio)
@@ -639,9 +639,9 @@ static int adc_tm5_gen2_configure(struct adc_tm5_channel *channel, int low, intreturn ret; } -static int adc_tm5_set_trips (void *data,int low,int high) +static int adc_tm5_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct adc_tm5_channel *channel = data; +struct adc_tm5_channel *channel = tz->devdata;struct adc_tm5_chip *chip;int ret;
@@ -660,7 +660,7 @@ static int adc_tm5_set_trips(void *data, int low, int high)return ret; } -static struct thermal_zone_of_device_ops adc_tm5_thermal_ops = { +static const struct thermal_zone_device_ops adc_tm5_thermal_ops = { .get_temp = adc_tm5_get_temp, .set_trips = adc_tm5_set_trips, };
@@ -672,11 +672,10 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)for (i =0 ; i < adc_tm->nchannels; i++) { adc_tm->channels[i].chip = adc_tm; - - tzd =devm_thermal_zone_of_sensor_register (adc_tm->dev, - adc_tm->channels[i].channel, - &adc_tm->channels[i], - &adc_tm5_thermal_ops); + tzd =devm_thermal_of_zone_register (adc_tm->dev, + adc_tm->channels[i].channel, + &adc_tm->channels[i], + &adc_tm5_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) == -ENODEV ) { dev_warn(adc_tm->dev, "thermal sensor on channel %d is not used\n",
drivers/thermal/qcom/qcom-spmi-temp-alarm.c +6 -6
@@ -186,9 +186,9 @@ static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)return 0 ; } -static int qpnp_tm_get_temp (void *data,int *temp) +static int qpnp_tm_get_temp (struct thermal_zone_device *tz,int *temp) { -struct qpnp_tm_chip *chip = data; +struct qpnp_tm_chip *chip = tz->devdata;int ret, mili_celsius;if (!temp)
@@ -263,9 +263,9 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip,return qpnp_tm_write (chip,QPNP_TM_REG_SHUTDOWN_CTRL1 , reg); } -static int qpnp_tm_set_trip_temp (void *data,int trip,int temp) +static int qpnp_tm_set_trip_temp (struct thermal_zone_device *tz,int trip,int temp) { -struct qpnp_tm_chip *chip = data; +struct qpnp_tm_chip *chip = tz->devdata;const struct thermal_trip *trip_points;int ret;
@@ -283,7 +283,7 @@ static int qpnp_tm_set_trip_temp(void *data, int trip, int temp)return ret; } -static const struct thermal_zone_of_device_ops qpnp_tm_sensor_ops = { +static const struct thermal_zone_device_ops qpnp_tm_sensor_ops = { .get_temp = qpnp_tm_get_temp, .set_trip_temp = qpnp_tm_set_trip_temp, };
@@ -446,7 +446,7 @@ static int qpnp_tm_probe(struct platform_device *pdev)* read the trip points. get_temp() returns the default temperature * before the hardware initialization is completed. */ - chip->tz_dev =devm_thermal_zone_of_sensor_register ( + chip->tz_dev =devm_thermal_of_zone_register ( &pdev->dev,0 , chip, &qpnp_tm_sensor_ops);if (IS_ERR (chip->tz_dev)) {dev_err (&pdev->dev,"failed to register sensor\n" );
drivers/thermal/qcom/tsens.c +8 -8
@@ -532,9 +532,9 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)return IRQ_HANDLED ; } -static int tsens_set_trips (void *_sensor,int low,int high) +static int tsens_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct tsens_sensor *s = _sensor; +struct tsens_sensor *s = tz->devdata;struct tsens_priv *priv = s->priv;struct device *dev = priv->dev;struct tsens_irq_data d;
@@ -925,9 +925,9 @@ int __init init_common(struct tsens_priv *priv)return ret; } -static int tsens_get_temp (void *data,int *temp) +static int tsens_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tsens_sensor *s = data; +struct tsens_sensor *s = tz->devdata;struct tsens_priv *priv = s->priv;return priv->ops->get_temp (s, temp);
@@ -991,7 +991,7 @@ static const struct of_device_id tsens_table[] = { };MODULE_DEVICE_TABLE (of, tsens_table); -static const struct thermal_zone_of_device_ops tsens_of_ops = { +static const struct thermal_zone_device_ops tsens_of_ops = { .get_temp = tsens_get_temp, .set_trips = tsens_set_trips, };
@@ -1044,9 +1044,9 @@ static int tsens_register(struct tsens_priv *priv)for (i =0 ; i < priv->num_sensors; i++) { priv->sensor[i].priv = priv; - tzd =devm_thermal_zone_of_sensor_register (priv->dev, priv->sensor[i].hw_id, - &priv->sensor[i], - &tsens_of_ops); + tzd =devm_thermal_of_zone_register (priv->dev, priv->sensor[i].hw_id, + &priv->sensor[i], + &tsens_of_ops);if (IS_ERR (tzd))continue ; priv->sensor[i].tzd = tzd;
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/qcom: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: ca1b9a9eb3fdbb9aa39d0c174391af694ae77671 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//ca1b9a9eb3fdbb9aa39d0c174391af694ae77671 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:27 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/qcom: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 19 +++++++++---------- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 12 ++++++------ drivers/thermal/qcom/tsens.c | 16 ++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-)
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +9 -10
@@ -357,9 +357,9 @@ static irqreturn_t adc_tm5_gen2_isr(int irq, void *data)return IRQ_HANDLED ; } -static int adc_tm5_get_temp (void *data,int *temp) +static int adc_tm5_get_temp (struct thermal_zone_device *tz,int *temp) { -struct adc_tm5_channel *channel = data; +struct adc_tm5_channel *channel = tz->devdata;int ret;if (!channel || !channel->iio)
@@ -639,9 +639,9 @@ config_fail:return ret; } -static int adc_tm5_set_trips (void *data,int low,int high) +static int adc_tm5_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct adc_tm5_channel *channel = data; +struct adc_tm5_channel *channel = tz->devdata;struct adc_tm5_chip *chip;int ret;
@@ -660,7 +660,7 @@ static int adc_tm5_set_trips(void *data, int low, int high)return ret; } -static struct thermal_zone_of_device_ops adc_tm5_thermal_ops = { +static const struct thermal_zone_device_ops adc_tm5_thermal_ops = { .get_temp = adc_tm5_get_temp, .set_trips = adc_tm5_set_trips, };
@@ -672,11 +672,10 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)for (i =0 ; i < adc_tm->nchannels; i++) { adc_tm->channels[i].chip = adc_tm; - - tzd =devm_thermal_zone_of_sensor_register (adc_tm->dev, - adc_tm->channels[i].channel, - &adc_tm->channels[i], - &adc_tm5_thermal_ops); + tzd =devm_thermal_of_zone_register (adc_tm->dev, + adc_tm->channels[i].channel, + &adc_tm->channels[i], + &adc_tm5_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) == -ENODEV ) { dev_warn(adc_tm->dev, "thermal sensor on channel %d is not used\n",
drivers/thermal/qcom/qcom-spmi-temp-alarm.c +6 -6
@@ -186,9 +186,9 @@ static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)return 0 ; } -static int qpnp_tm_get_temp (void *data,int *temp) +static int qpnp_tm_get_temp (struct thermal_zone_device *tz,int *temp) { -struct qpnp_tm_chip *chip = data; +struct qpnp_tm_chip *chip = tz->devdata;int ret, mili_celsius;if (!temp)
@@ -263,9 +263,9 @@ skip:return qpnp_tm_write (chip,QPNP_TM_REG_SHUTDOWN_CTRL1 , reg); } -static int qpnp_tm_set_trip_temp (void *data,int trip,int temp) +static int qpnp_tm_set_trip_temp (struct thermal_zone_device *tz,int trip,int temp) { -struct qpnp_tm_chip *chip = data; +struct qpnp_tm_chip *chip = tz->devdata;const struct thermal_trip *trip_points;int ret;
@@ -283,7 +283,7 @@ static int qpnp_tm_set_trip_temp(void *data, int trip, int temp)return ret; } -static const struct thermal_zone_of_device_ops qpnp_tm_sensor_ops = { +static const struct thermal_zone_device_ops qpnp_tm_sensor_ops = { .get_temp = qpnp_tm_get_temp, .set_trip_temp = qpnp_tm_set_trip_temp, };
@@ -446,7 +446,7 @@ static int qpnp_tm_probe(struct platform_device *pdev)* read the trip points. get_temp() returns the default temperature * before the hardware initialization is completed. */ - chip->tz_dev =devm_thermal_zone_of_sensor_register ( + chip->tz_dev =devm_thermal_of_zone_register ( &pdev->dev,0 , chip, &qpnp_tm_sensor_ops);if (IS_ERR (chip->tz_dev)) {dev_err (&pdev->dev,"failed to register sensor\n" );
drivers/thermal/qcom/tsens.c +8 -8
@@ -532,9 +532,9 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)return IRQ_HANDLED ; } -static int tsens_set_trips (void *_sensor,int low,int high) +static int tsens_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct tsens_sensor *s = _sensor; +struct tsens_sensor *s = tz->devdata;struct tsens_priv *priv = s->priv;struct device *dev = priv->dev;struct tsens_irq_data d;
@@ -925,9 +925,9 @@ err_put_device:return ret; } -static int tsens_get_temp (void *data,int *temp) +static int tsens_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tsens_sensor *s = data; +struct tsens_sensor *s = tz->devdata;struct tsens_priv *priv = s->priv;return priv->ops->get_temp (s, temp);
@@ -991,7 +991,7 @@ static const struct of_device_id tsens_table[] = { };MODULE_DEVICE_TABLE (of, tsens_table); -static const struct thermal_zone_of_device_ops tsens_of_ops = { +static const struct thermal_zone_device_ops tsens_of_ops = { .get_temp = tsens_get_temp, .set_trips = tsens_set_trips, };
@@ -1044,9 +1044,9 @@ static int tsens_register(struct tsens_priv *priv)for (i =0 ; i < priv->num_sensors; i++) { priv->sensor[i].priv = priv; - tzd =devm_thermal_zone_of_sensor_register (priv->dev, priv->sensor[i].hw_id, - &priv->sensor[i], - &tsens_of_ops); + tzd =devm_thermal_of_zone_register (priv->dev, priv->sensor[i].hw_id, + &priv->sensor[i], + &tsens_of_ops);if (IS_ERR (tzd))continue ; priv->sensor[i].tzd = tzd;
PATCH v5 12/33 thermal/drivers/st: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/st/stm_thermal.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/thermal/st/stm_thermal.c +8 -10
@@ -302,9 +302,9 @@ static int stm_disable_irq(struct stm_thermal_sensor *sensor)return 0 ; } -static int stm_thermal_set_trips (void *data,int low,int high) +static int stm_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct stm_thermal_sensor *sensor = data; +struct stm_thermal_sensor *sensor = tz->devdata;u32 itr1, th;int ret;
@@ -350,9 +350,9 @@ static int stm_thermal_set_trips(void *data, int low, int high) }/* Callback to get temperature from HW */ -static int stm_thermal_get_temp (void *data,int *temp) +static int stm_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct stm_thermal_sensor *sensor = data; +struct stm_thermal_sensor *sensor = tz->devdata;u32 periods;int freqM, ret;
@@ -474,7 +474,7 @@ static int stm_thermal_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops, stm_thermal_suspend, stm_thermal_resume); -static const struct thermal_zone_of_device_ops stm_tz_ops = { +static const struct thermal_zone_device_ops stm_tz_ops = { .get_temp = stm_thermal_get_temp, .set_trips = stm_thermal_set_trips, };
@@ -539,9 +539,9 @@ static int stm_thermal_probe(struct platform_device *pdev)return ret; } - sensor->th_dev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , - sensor, - &stm_tz_ops); + sensor->th_dev =devm_thermal_of_zone_register (&pdev->dev,0 , + sensor, + &stm_tz_ops);if (IS_ERR (sensor->th_dev)) { dev_err(&pdev->dev, "%s: thermal zone sensor registering KO\n",
@@ -572,7 +572,6 @@ static int stm_thermal_probe(struct platform_device *pdev)return 0 ; err_tz: -thermal_zone_of_sensor_unregister (&pdev->dev, sensor->th_dev);return ret; }
@@ -582,7 +581,6 @@ static int stm_thermal_remove(struct platform_device *pdev)stm_thermal_sensor_off (sensor);thermal_remove_hwmon_sysfs (sensor->th_dev); -thermal_zone_of_sensor_unregister (&pdev->dev, sensor->th_dev);return 0 ; }
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/st: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 7e96f35408b6b196a3dc20db757878a7d26bf02d Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//7e96f35408b6b196a3dc20db757878a7d26bf02d Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:28 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/st: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/st/stm_thermal.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/thermal/st/stm_thermal.c +8 -10
@@ -302,9 +302,9 @@ static int stm_disable_irq(struct stm_thermal_sensor *sensor)return 0 ; } -static int stm_thermal_set_trips (void *data,int low,int high) +static int stm_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct stm_thermal_sensor *sensor = data; +struct stm_thermal_sensor *sensor = tz->devdata;u32 itr1, th;int ret;
@@ -350,9 +350,9 @@ static int stm_thermal_set_trips(void *data, int low, int high) }/* Callback to get temperature from HW */ -static int stm_thermal_get_temp (void *data,int *temp) +static int stm_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct stm_thermal_sensor *sensor = data; +struct stm_thermal_sensor *sensor = tz->devdata;u32 periods;int freqM, ret;
@@ -474,7 +474,7 @@ static int stm_thermal_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops, stm_thermal_suspend, stm_thermal_resume); -static const struct thermal_zone_of_device_ops stm_tz_ops = { +static const struct thermal_zone_device_ops stm_tz_ops = { .get_temp = stm_thermal_get_temp, .set_trips = stm_thermal_set_trips, };
@@ -539,9 +539,9 @@ static int stm_thermal_probe(struct platform_device *pdev)return ret; } - sensor->th_dev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , - sensor, - &stm_tz_ops); + sensor->th_dev =devm_thermal_of_zone_register (&pdev->dev,0 , + sensor, + &stm_tz_ops);if (IS_ERR (sensor->th_dev)) { dev_err(&pdev->dev, "%s: thermal zone sensor registering KO\n",
@@ -572,7 +572,6 @@ static int stm_thermal_probe(struct platform_device *pdev)return 0 ; err_tz: -thermal_zone_of_sensor_unregister (&pdev->dev, sensor->th_dev);return ret; }
@@ -582,7 +581,6 @@ static int stm_thermal_remove(struct platform_device *pdev)stm_thermal_sensor_off (sensor);thermal_remove_hwmon_sysfs (sensor->th_dev); -thermal_zone_of_sensor_unregister (&pdev->dev, sensor->th_dev);return 0 ; }
PATCH v5 13/33 thermal/drivers/amlogic: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/amlogic_thermal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/thermal/amlogic_thermal.c +8 -8
@@ -179,12 +179,12 @@ static int amlogic_thermal_disable(struct amlogic_thermal *data)return 0 ; } -static int amlogic_thermal_get_temp (void *data,int *temp) +static int amlogic_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {unsigned int tval; -struct amlogic_thermal *pdata = data; +struct amlogic_thermal *pdata = tz->devdata; -if (!data) +if (!pdata)return -EINVAL ;regmap_read (pdata->regmap,TSENSOR_STAT0 , &tval);
@@ -195,7 +195,7 @@ static int amlogic_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops amlogic_thermal_ops = { +static const struct thermal_zone_device_ops amlogic_thermal_ops = { .get_temp = amlogic_thermal_get_temp, };
@@ -276,10 +276,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)return PTR_ERR (pdata->sec_ao_map); } - pdata->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, -0 , - pdata, - &amlogic_thermal_ops); + pdata->tzd =devm_thermal_of_zone_register (&pdev->dev, +0 , + pdata, + &amlogic_thermal_ops);if (IS_ERR (pdata->tzd)) { ret =PTR_ERR (pdata->tzd);dev_err (dev,"Failed to register tsensor: %d\n" , ret);
Signature · 1 line
2.25.1
Re: [PATCH v5 13/33] thermal/drivers/amlogic: Switch to new of API
Quoted 46 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/amlogic_thermal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/thermal/amlogic_thermal.c +4
-5@@ -179,12 +179,12 @@ static int amlogic_thermal_disable(struct amlogic_thermal *data)return 0 ; } -static int amlogic_thermal_get_temp (void *data,int *temp) +static int amlogic_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {unsigned int tval; -struct amlogic_thermal *pdata = data; +struct amlogic_thermal *pdata = tz->devdata; -if (!data) +if (!pdata)return -EINVAL ;regmap_read (pdata->regmap,TSENSOR_STAT0 , &tval);@@ -195,7 +195,7 @@ static int amlogic_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops amlogic_thermal_ops = { +static const struct thermal_zone_device_ops amlogic_thermal_ops = { .get_temp = amlogic_thermal_get_temp, };@@ -276,10 +276,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)return PTR_ERR (pdata->sec_ao_map); } - pdata->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
drivers/thermal/amlogic_thermal.c static int amlogic_thermal_probe(struct platform_device *pdev) · line 285
Quoted 10 lines
drivers/thermal/amlogic_thermal.c +4
-3-0 , - pdata, - &amlogic_thermal_ops); + pdata->tzd =devm_thermal_of_zone_register (&pdev->dev, +0 , + pdata, + &amlogic_thermal_ops);if (IS_ERR (pdata->tzd)) { ret =PTR_ERR (pdata->tzd);dev_err (dev,"Failed to register tsensor: %d\n" , ret);
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
[thermal: thermal/next] thermal/drivers/amlogic: Switch to new of API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 1240fd6512b7df593b99ea777c846f0b59173a6b Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//1240fd6512b7df593b99ea777c846f0b59173a6b Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:29 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/amlogic: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/amlogic_thermal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/thermal/amlogic_thermal.c +8 -8
@@ -179,12 +179,12 @@ static int amlogic_thermal_disable(struct amlogic_thermal *data)return 0 ; } -static int amlogic_thermal_get_temp (void *data,int *temp) +static int amlogic_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {unsigned int tval; -struct amlogic_thermal *pdata = data; +struct amlogic_thermal *pdata = tz->devdata; -if (!data) +if (!pdata)return -EINVAL ;regmap_read (pdata->regmap,TSENSOR_STAT0 , &tval);
@@ -195,7 +195,7 @@ static int amlogic_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops amlogic_thermal_ops = { +static const struct thermal_zone_device_ops amlogic_thermal_ops = { .get_temp = amlogic_thermal_get_temp, };
@@ -276,10 +276,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)return PTR_ERR (pdata->sec_ao_map); } - pdata->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, -0 , - pdata, - &amlogic_thermal_ops); + pdata->tzd =devm_thermal_of_zone_register (&pdev->dev, +0 , + pdata, + &amlogic_thermal_ops);if (IS_ERR (pdata->tzd)) { ret =PTR_ERR (pdata->tzd);dev_err (dev,"Failed to register tsensor: %d\n" , ret);
PATCH v5 14/33 thermal/drivers/armada: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/armada_thermal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/armada_thermal.c +6 -6
@@ -420,9 +420,9 @@ static struct thermal_zone_device_ops legacy_ops = { .get_temp = armada_get_temp_legacy, }; -static int armada_get_temp (void *_sensor,int *temp) +static int armada_get_temp (struct thermal_zone_device *tz,int *temp) { -struct armada_thermal_sensor *sensor = _sensor; +struct armada_thermal_sensor *sensor = tz->devdata;struct armada_thermal_priv *priv = sensor->priv;int ret;
@@ -450,7 +450,7 @@ static int armada_get_temp(void *_sensor, int *temp)return ret; } -static const struct thermal_zone_of_device_ops of_ops = { +static const struct thermal_zone_device_ops of_ops = { .get_temp = armada_get_temp, };
@@ -928,9 +928,9 @@ static int armada_thermal_probe(struct platform_device *pdev)/* Register the sensor */ sensor->priv = priv; sensor->id = sensor_id; - tz =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->id, sensor, - &of_ops); + tz =devm_thermal_of_zone_register (&pdev->dev, + sensor->id, sensor, + &of_ops);if (IS_ERR (tz)) {dev_info (&pdev->dev,"Thermal sensor %d unavailable\n" , sensor_id);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/armada: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: e4a1150e3e8d708e989c9f7056320fbff4a2d0c4 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//e4a1150e3e8d708e989c9f7056320fbff4a2d0c4 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:30 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/armada: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/armada_thermal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/armada_thermal.c +6 -6
@@ -420,9 +420,9 @@ static struct thermal_zone_device_ops legacy_ops = { .get_temp = armada_get_temp_legacy, }; -static int armada_get_temp (void *_sensor,int *temp) +static int armada_get_temp (struct thermal_zone_device *tz,int *temp) { -struct armada_thermal_sensor *sensor = _sensor; +struct armada_thermal_sensor *sensor = tz->devdata;struct armada_thermal_priv *priv = sensor->priv;int ret;
@@ -450,7 +450,7 @@ unlock_mutex:return ret; } -static const struct thermal_zone_of_device_ops of_ops = { +static const struct thermal_zone_device_ops of_ops = { .get_temp = armada_get_temp, };
@@ -928,9 +928,9 @@ static int armada_thermal_probe(struct platform_device *pdev)/* Register the sensor */ sensor->priv = priv; sensor->id = sensor_id; - tz =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->id, sensor, - &of_ops); + tz =devm_thermal_of_zone_register (&pdev->dev, + sensor->id, sensor, + &of_ops);if (IS_ERR (tz)) {dev_info (&pdev->dev,"Thermal sensor %d unavailable\n" , sensor_id);
PATCH v5 15/33 thermal/drivers/db8500: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/db8500_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/db8500_thermal.c +4 -4
@@ -58,9 +58,9 @@ struct db8500_thermal_zone { };/* Callback to get current temperature */ -static int db8500_thermal_get_temp (void *data,int *temp) +static int db8500_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct db8500_thermal_zone *th = data; +struct db8500_thermal_zone *th = tz->devdata;/* * TODO: There is no PRCMU interface to get temperature data currently,
@@ -72,7 +72,7 @@ static int db8500_thermal_get_temp(void *data, int *temp)return 0 ; } -static struct thermal_zone_of_device_ops thdev_ops = { +static const struct thermal_zone_device_ops thdev_ops = { .get_temp = db8500_thermal_get_temp, };
@@ -182,7 +182,7 @@ static int db8500_thermal_probe(struct platform_device *pdev) }/* register of thermal sensor and get info from DT */ - th->tz =devm_thermal_zone_of_sensor_register (dev,0 , th, &thdev_ops); + th->tz =devm_thermal_of_zone_register (dev,0 , th, &thdev_ops);if (IS_ERR (th->tz)) {dev_err (dev,"register thermal zone sensor failed\n" );return PTR_ERR (th->tz);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/db8500: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 2320be6032e1c1b17a3fcac98813947d1d28c32f Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//2320be6032e1c1b17a3fcac98813947d1d28c32f Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:31 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/db8500: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/db8500_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/db8500_thermal.c +4 -4
@@ -58,9 +58,9 @@ struct db8500_thermal_zone { };/* Callback to get current temperature */ -static int db8500_thermal_get_temp (void *data,int *temp) +static int db8500_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct db8500_thermal_zone *th = data; +struct db8500_thermal_zone *th = tz->devdata;/* * TODO: There is no PRCMU interface to get temperature data currently,
@@ -72,7 +72,7 @@ static int db8500_thermal_get_temp(void *data, int *temp)return 0 ; } -static struct thermal_zone_of_device_ops thdev_ops = { +static const struct thermal_zone_device_ops thdev_ops = { .get_temp = db8500_thermal_get_temp, };
@@ -182,7 +182,7 @@ static int db8500_thermal_probe(struct platform_device *pdev) }/* register of thermal sensor and get info from DT */ - th->tz =devm_thermal_zone_of_sensor_register (dev,0 , th, &thdev_ops); + th->tz =devm_thermal_of_zone_register (dev,0 , th, &thdev_ops);if (IS_ERR (th->tz)) {dev_err (dev,"register thermal zone sensor failed\n" );return PTR_ERR (th->tz);
PATCH v5 16/33 thermal/drivers/imx: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/imx8mm_thermal.c | 14 +++++++------- drivers/thermal/imx_sc_thermal.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/thermal/imx8mm_thermal.c +7 -7
@@ -96,15 +96,15 @@ static int imx8mp_tmu_get_temp(void *data, int *temp)return 0 ; } -static int tmu_get_temp (void *data,int *temp) +static int tmu_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tmu_sensor *sensor = data; +struct tmu_sensor *sensor = tz->devdata;struct imx8mm_tmu *tmu = sensor->priv; -return tmu->socdata->get_temp (data, temp); +return tmu->socdata->get_temp (sensor, temp); } -static struct thermal_zone_of_device_ops tmu_tz_ops = { +static const struct thermal_zone_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, };
@@ -165,9 +165,9 @@ static int imx8mm_tmu_probe(struct platform_device *pdev)for (i =0 ; i < data->num_sensors; i++) { tmu->sensors[i].priv = tmu; tmu->sensors[i].tzd = -devm_thermal_zone_of_sensor_register (&pdev->dev, i, - &tmu->sensors[i], - &tmu_tz_ops); +devm_thermal_of_zone_register (&pdev->dev, i, + &tmu->sensors[i], + &tmu_tz_ops);if (IS_ERR (tmu->sensors[i].tzd)) { ret =PTR_ERR (tmu->sensors[i].tzd); dev_err(&pdev->dev,
drivers/thermal/imx_sc_thermal.c +7 -7
@@ -43,11 +43,11 @@ struct imx_sc_msg_misc_get_temp { } data; } __packed__aligned(4) ; -static int imx_sc_thermal_get_temp (void *data,int *temp) +static int imx_sc_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {struct imx_sc_msg_misc_get_temp msg;struct imx_sc_rpc_msg *hdr = &msg.hdr; -struct imx_sc_sensor *sensor = data; +struct imx_sc_sensor *sensor = tz->devdata;int ret; msg.data.req.resource_id = sensor->resource_id;
@@ -70,7 +70,7 @@ static int imx_sc_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops imx_sc_thermal_ops = { +static const struct thermal_zone_device_ops imx_sc_thermal_ops = { .get_temp = imx_sc_thermal_get_temp, };
@@ -109,10 +109,10 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)break ; } - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->resource_id, - sensor, - &imx_sc_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, + sensor->resource_id, + sensor, + &imx_sc_thermal_ops);if (IS_ERR (sensor->tzd)) {dev_err (&pdev->dev,"failed to register thermal zone\n" ); ret =PTR_ERR (sensor->tzd);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/imx: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 32fb9a8a9d0db3edee50f9c2fcc74fcc26812b86 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//32fb9a8a9d0db3edee50f9c2fcc74fcc26812b86 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:32 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/imx: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/imx8mm_thermal.c | 14 +++++++------- drivers/thermal/imx_sc_thermal.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/thermal/imx8mm_thermal.c +7 -7
@@ -96,15 +96,15 @@ static int imx8mp_tmu_get_temp(void *data, int *temp)return 0 ; } -static int tmu_get_temp (void *data,int *temp) +static int tmu_get_temp (struct thermal_zone_device *tz,int *temp) { -struct tmu_sensor *sensor = data; +struct tmu_sensor *sensor = tz->devdata;struct imx8mm_tmu *tmu = sensor->priv; -return tmu->socdata->get_temp (data, temp); +return tmu->socdata->get_temp (sensor, temp); } -static struct thermal_zone_of_device_ops tmu_tz_ops = { +static const struct thermal_zone_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, };
@@ -165,9 +165,9 @@ static int imx8mm_tmu_probe(struct platform_device *pdev)for (i =0 ; i < data->num_sensors; i++) { tmu->sensors[i].priv = tmu; tmu->sensors[i].tzd = -devm_thermal_zone_of_sensor_register (&pdev->dev, i, - &tmu->sensors[i], - &tmu_tz_ops); +devm_thermal_of_zone_register (&pdev->dev, i, + &tmu->sensors[i], + &tmu_tz_ops);if (IS_ERR (tmu->sensors[i].tzd)) { ret =PTR_ERR (tmu->sensors[i].tzd); dev_err(&pdev->dev,
drivers/thermal/imx_sc_thermal.c +7 -7
@@ -43,11 +43,11 @@ struct imx_sc_msg_misc_get_temp { } data; } __packed__aligned(4) ; -static int imx_sc_thermal_get_temp (void *data,int *temp) +static int imx_sc_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {struct imx_sc_msg_misc_get_temp msg;struct imx_sc_rpc_msg *hdr = &msg.hdr; -struct imx_sc_sensor *sensor = data; +struct imx_sc_sensor *sensor = tz->devdata;int ret; msg.data.req.resource_id = sensor->resource_id;
@@ -70,7 +70,7 @@ static int imx_sc_thermal_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops imx_sc_thermal_ops = { +static const struct thermal_zone_device_ops imx_sc_thermal_ops = { .get_temp = imx_sc_thermal_get_temp, };
@@ -109,10 +109,10 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)break ; } - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->resource_id, - sensor, - &imx_sc_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, + sensor->resource_id, + sensor, + &imx_sc_thermal_ops);if (IS_ERR (sensor->tzd)) {dev_err (&pdev->dev,"failed to register thermal zone\n" ); ret =PTR_ERR (sensor->tzd);
PATCH v5 17/33 thermal/drivers/rcar: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rcar_gen3_thermal.c | 16 ++++++++-------- drivers/thermal/rcar_thermal.c | 13 +++---------- 2 files changed, 11 insertions(+), 18 deletions(-)
drivers/thermal/rcar_gen3_thermal.c +8 -8
@@ -164,9 +164,9 @@ static int rcar_gen3_thermal_round(int temp)return result *RCAR3_THERMAL_GRAN ; } -static int rcar_gen3_thermal_get_temp (void *devdata,int *temp) +static int rcar_gen3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct rcar_gen3_thermal_tsc *tsc = devdata; +struct rcar_gen3_thermal_tsc *tsc = tz->devdata;int mcelsius, val;int reg;
@@ -203,9 +203,9 @@ static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc,return INT_FIXPT (val); } -static int rcar_gen3_thermal_set_trips (void *devdata,int low,int high) +static int rcar_gen3_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct rcar_gen3_thermal_tsc *tsc = devdata; +struct rcar_gen3_thermal_tsc *tsc = tz->devdata;u32 irqmsk =0 ;if (low != -INT_MAX ) {
@@ -225,7 +225,7 @@ static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)return 0 ; } -static struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = { +static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = { .get_temp = rcar_gen3_thermal_get_temp, .set_trips = rcar_gen3_thermal_set_trips, };
@@ -504,8 +504,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)for (i =0 ; i < priv->num_tscs; i++) {struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - zone =devm_thermal_zone_of_sensor_register (dev, i, tsc, - &rcar_gen3_tz_of_ops); + zone =devm_thermal_of_zone_register (dev, i, tsc, + &rcar_gen3_tz_of_ops);if (IS_ERR (zone)) {dev_err (dev,"Sensor %u: Can't register thermal zone\n" , i); ret =PTR_ERR (zone);
@@ -556,7 +556,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) priv->thermal_init (tsc);if (zone->ops->set_trips) -rcar_gen3_thermal_set_trips (tsc, zone->prev_low_trip, +rcar_gen3_thermal_set_trips (zone, zone->prev_low_trip, zone->prev_high_trip); }
drivers/thermal/rcar_thermal.c +3 -10
@@ -271,13 +271,6 @@ static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,return 0 ; } -static int rcar_thermal_of_get_temp (void *data,int *temp) -{ -struct rcar_thermal_priv *priv = data; - -return rcar_thermal_get_current_temp (priv, temp); -} -static int rcar_thermal_get_temp (struct thermal_zone_device *zone,int *temp) {struct rcar_thermal_priv *priv =rcar_zone_to_priv (zone);
@@ -323,8 +316,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,return 0 ; } -static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = { - .get_temp = rcar_thermal_of_get_temp, +static struct thermal_zone_device_ops rcar_thermal_zone_of_ops = { + .get_temp = rcar_thermal_get_temp, };static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
@@ -534,7 +527,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) goto error_unregister;if (chip->use_of_thermal) { - priv->zone =devm_thermal_zone_of_sensor_register ( + priv->zone =devm_thermal_of_zone_register ( dev, i, priv, &rcar_thermal_zone_of_ops); }else {
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/rcar: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 2ebd4f2f2ecfde86ce490f02b28b3282d93aa405 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//2ebd4f2f2ecfde86ce490f02b28b3282d93aa405 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:33 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/rcar: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rcar_gen3_thermal.c | 16 ++++++++-------- drivers/thermal/rcar_thermal.c | 13 +++---------- 2 files changed, 11 insertions(+), 18 deletions(-)
drivers/thermal/rcar_gen3_thermal.c +8 -8
@@ -164,9 +164,9 @@ static int rcar_gen3_thermal_round(int temp)return result *RCAR3_THERMAL_GRAN ; } -static int rcar_gen3_thermal_get_temp (void *devdata,int *temp) +static int rcar_gen3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct rcar_gen3_thermal_tsc *tsc = devdata; +struct rcar_gen3_thermal_tsc *tsc = tz->devdata;int mcelsius, val;int reg;
@@ -203,9 +203,9 @@ static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc,return INT_FIXPT (val); } -static int rcar_gen3_thermal_set_trips (void *devdata,int low,int high) +static int rcar_gen3_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct rcar_gen3_thermal_tsc *tsc = devdata; +struct rcar_gen3_thermal_tsc *tsc = tz->devdata;u32 irqmsk =0 ;if (low != -INT_MAX ) {
@@ -225,7 +225,7 @@ static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)return 0 ; } -static struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = { +static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = { .get_temp = rcar_gen3_thermal_get_temp, .set_trips = rcar_gen3_thermal_set_trips, };
@@ -508,8 +508,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)for (i =0 ; i < priv->num_tscs; i++) {struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - zone =devm_thermal_zone_of_sensor_register (dev, i, tsc, - &rcar_gen3_tz_of_ops); + zone =devm_thermal_of_zone_register (dev, i, tsc, + &rcar_gen3_tz_of_ops);if (IS_ERR (zone)) {dev_err (dev,"Sensor %u: Can't register thermal zone\n" , i); ret =PTR_ERR (zone);
@@ -560,7 +560,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) priv->thermal_init (tsc);if (zone->ops->set_trips) -rcar_gen3_thermal_set_trips (tsc, zone->prev_low_trip, +rcar_gen3_thermal_set_trips (zone, zone->prev_low_trip, zone->prev_high_trip); }
drivers/thermal/rcar_thermal.c +3 -10
@@ -271,13 +271,6 @@ static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,return 0 ; } -static int rcar_thermal_of_get_temp (void *data,int *temp) -{ -struct rcar_thermal_priv *priv = data; - -return rcar_thermal_get_current_temp (priv, temp); -} -static int rcar_thermal_get_temp (struct thermal_zone_device *zone,int *temp) {struct rcar_thermal_priv *priv =rcar_zone_to_priv (zone);
@@ -323,8 +316,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,return 0 ; } -static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = { - .get_temp = rcar_thermal_of_get_temp, +static struct thermal_zone_device_ops rcar_thermal_zone_of_ops = { + .get_temp = rcar_thermal_get_temp, };static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
@@ -534,7 +527,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) goto error_unregister;if (chip->use_of_thermal) { - priv->zone =devm_thermal_zone_of_sensor_register ( + priv->zone =devm_thermal_of_zone_register ( dev, i, priv, &rcar_thermal_zone_of_ops); }else {
PATCH v5 18/33 thermal/drivers/rzg2l: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rzg2l_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/rzg2l_thermal.c +5 -5
@@ -73,9 +73,9 @@ static inline void rzg2l_thermal_write(struct rzg2l_thermal_priv *priv, u32 reg,iowrite32 (data, priv->base + reg); } -static int rzg2l_thermal_get_temp (void *devdata,int *temp) +static int rzg2l_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct rzg2l_thermal_priv *priv = devdata; +struct rzg2l_thermal_priv *priv = tz->devdata;u32 result =0 , dsensor, ts_code_ave;int val, i;
@@ -114,7 +114,7 @@ static int rzg2l_thermal_get_temp(void *devdata, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops rzg2l_tz_of_ops = { +static const struct thermal_zone_device_ops rzg2l_tz_of_ops = { .get_temp = rzg2l_thermal_get_temp, };
@@ -207,8 +207,8 @@ static int rzg2l_thermal_probe(struct platform_device *pdev) goto err; } - zone =devm_thermal_zone_of_sensor_register (dev,0 , priv, - &rzg2l_tz_of_ops); + zone =devm_thermal_of_zone_register (dev,0 , priv, + &rzg2l_tz_of_ops);if (IS_ERR (zone)) {dev_err (dev,"Can't register thermal zone" ); ret =PTR_ERR (zone);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/rzg2l: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 396cbbc6b711ef8d329303dc179a7a1c395f1f12 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//396cbbc6b711ef8d329303dc179a7a1c395f1f12 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:34 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/rzg2l: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/rzg2l_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/rzg2l_thermal.c +5 -5
@@ -73,9 +73,9 @@ static inline void rzg2l_thermal_write(struct rzg2l_thermal_priv *priv, u32 reg,iowrite32 (data, priv->base + reg); } -static int rzg2l_thermal_get_temp (void *devdata,int *temp) +static int rzg2l_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct rzg2l_thermal_priv *priv = devdata; +struct rzg2l_thermal_priv *priv = tz->devdata;u32 result =0 , dsensor, ts_code_ave;int val, i;
@@ -114,7 +114,7 @@ static int rzg2l_thermal_get_temp(void *devdata, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops rzg2l_tz_of_ops = { +static const struct thermal_zone_device_ops rzg2l_tz_of_ops = { .get_temp = rzg2l_thermal_get_temp, };
@@ -207,8 +207,8 @@ static int rzg2l_thermal_probe(struct platform_device *pdev) goto err; } - zone =devm_thermal_zone_of_sensor_register (dev,0 , priv, - &rzg2l_tz_of_ops); + zone =devm_thermal_of_zone_register (dev,0 , priv, + &rzg2l_tz_of_ops);if (IS_ERR (zone)) {dev_err (dev,"Can't register thermal zone" ); ret =PTR_ERR (zone);
PATCH v5 19/33 thermal/drivers/qoriq: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/qoriq_thermal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/qoriq_thermal.c +6 -6
@@ -82,9 +82,9 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s) return container_of(s, struct qoriq_tmu_data, sensor[s->id]); } -static int tmu_get_temp (void *p,int *temp) +static int tmu_get_temp (struct thermal_zone_device *tz,int *temp) { -struct qoriq_sensor *qsensor = p; +struct qoriq_sensor *qsensor = tz->devdata;struct qoriq_tmu_data *qdata =qoriq_sensor_to_data (qsensor);u32 val;/*
@@ -122,7 +122,7 @@ static int tmu_get_temp(void *p, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops tmu_tz_ops = { +static const struct thermal_zone_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, };
@@ -146,9 +146,9 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, sensor->id = id; - tzd =devm_thermal_zone_of_sensor_register (dev, id, - sensor, - &tmu_tz_ops); + tzd =devm_thermal_of_zone_register (dev, id, + sensor, + &tmu_tz_ops); ret =PTR_ERR_OR_ZERO (tzd);if (ret) {if (ret == -ENODEV )
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/qoriq: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 3e7494b41c41959cd68a3f652e286c1fb7c626fc Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//3e7494b41c41959cd68a3f652e286c1fb7c626fc Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:35 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/qoriq: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/qoriq_thermal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/thermal/qoriq_thermal.c +6 -6
@@ -82,9 +82,9 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s) return container_of(s, struct qoriq_tmu_data, sensor[s->id]); } -static int tmu_get_temp (void *p,int *temp) +static int tmu_get_temp (struct thermal_zone_device *tz,int *temp) { -struct qoriq_sensor *qsensor = p; +struct qoriq_sensor *qsensor = tz->devdata;struct qoriq_tmu_data *qdata =qoriq_sensor_to_data (qsensor);u32 val;/*
@@ -122,7 +122,7 @@ static int tmu_get_temp(void *p, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops tmu_tz_ops = { +static const struct thermal_zone_device_ops tmu_tz_ops = { .get_temp = tmu_get_temp, };
@@ -146,9 +146,9 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, sensor->id = id; - tzd =devm_thermal_zone_of_sensor_register (dev, id, - sensor, - &tmu_tz_ops); + tzd =devm_thermal_of_zone_register (dev, id, + sensor, + &tmu_tz_ops); ret =PTR_ERR_OR_ZERO (tzd);if (ret) {if (ret == -ENODEV )
PATCH v5 20/33 thermal/drivers/mtk: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/mtk_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/mtk_thermal.c +5 -5
@@ -679,9 +679,9 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)return max; } -static int mtk_read_temp (void *data,int *temperature) +static int mtk_read_temp (struct thermal_zone_device *tz,int *temperature) { -struct mtk_thermal *mt = data; +struct mtk_thermal *mt = tz->devdata;int i;int tempmax =INT_MIN ;
@@ -700,7 +700,7 @@ static int mtk_read_temp(void *data, int *temperature)return 0 ; } -static const struct thermal_zone_of_device_ops mtk_thermal_ops = { +static const struct thermal_zone_device_ops mtk_thermal_ops = { .get_temp = mtk_read_temp, };
@@ -1082,8 +1082,8 @@ static int mtk_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mt); - tzdev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , mt, - &mtk_thermal_ops); + tzdev =devm_thermal_of_zone_register (&pdev->dev,0 , mt, + &mtk_thermal_ops);if (IS_ERR (tzdev)) { ret =PTR_ERR (tzdev); goto err_disable_clk_peri_therm;
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/mtk: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: ab7e865db9a54abd775327f87f32f4d0e6e24109 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//ab7e865db9a54abd775327f87f32f4d0e6e24109 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:36 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/mtk: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/mtk_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/mtk_thermal.c +5 -5
@@ -679,9 +679,9 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)return max; } -static int mtk_read_temp (void *data,int *temperature) +static int mtk_read_temp (struct thermal_zone_device *tz,int *temperature) { -struct mtk_thermal *mt = data; +struct mtk_thermal *mt = tz->devdata;int i;int tempmax =INT_MIN ;
@@ -700,7 +700,7 @@ static int mtk_read_temp(void *data, int *temperature)return 0 ; } -static const struct thermal_zone_of_device_ops mtk_thermal_ops = { +static const struct thermal_zone_device_ops mtk_thermal_ops = { .get_temp = mtk_read_temp, };
@@ -1082,8 +1082,8 @@ static int mtk_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mt); - tzdev =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , mt, - &mtk_thermal_ops); + tzdev =devm_thermal_of_zone_register (&pdev->dev,0 , mt, + &mtk_thermal_ops);if (IS_ERR (tzdev)) { ret =PTR_ERR (tzdev); goto err_disable_clk_peri_therm;
PATCH v5 21/33 thermal/drivers/banggap: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/k3_bandgap.c | 12 ++++++------ drivers/thermal/k3_j72xx_bandgap.c | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-)
drivers/thermal/k3_bandgap.c +6 -6
@@ -139,9 +139,9 @@ static int k3_bgp_read_temp(struct k3_thermal_data *devdata,return 0 ; } -static int k3_thermal_get_temp (void *devdata,int *temp) +static int k3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct k3_thermal_data *data = devdata; +struct k3_thermal_data *data = tz->devdata;int ret =0 ; ret =k3_bgp_read_temp (data, temp);
@@ -151,7 +151,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)return ret; } -static const struct thermal_zone_of_device_ops k3_of_thermal_ops = { +static const struct thermal_zone_device_ops k3_of_thermal_ops = { .get_temp = k3_thermal_get_temp, };
@@ -213,9 +213,9 @@ static int k3_bandgap_probe(struct platform_device *pdev)writel (val, data[id].bgp->base + data[id].ctrl_offset); data[id].tzd = -devm_thermal_zone_of_sensor_register (dev, id, - &data[id], - &k3_of_thermal_ops); +devm_thermal_of_zone_register (dev, id, + &data[id], + &k3_of_thermal_ops);if (IS_ERR (data[id].tzd)) {dev_err (dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (data[id].tzd);
drivers/thermal/k3_j72xx_bandgap.c +5 -7
@@ -247,9 +247,9 @@ static inline int k3_bgp_read_temp(struct k3_thermal_data *devdata, }/* Get temperature callback function for thermal zone */ -static int k3_thermal_get_temp (void *devdata,int *temp) +static int k3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct k3_thermal_data *data = devdata; +struct k3_thermal_data *data = tz->devdata;int ret =0 ; ret =k3_bgp_read_temp (data, temp);
@@ -259,7 +259,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)return ret; } -static const struct thermal_zone_of_device_ops k3_of_thermal_ops = { +static const struct thermal_zone_device_ops k3_of_thermal_ops = { .get_temp = k3_thermal_get_temp, };
@@ -474,10 +474,8 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)writel (val, data[id].bgp->cfg2_base + data[id].ctrl_offset); bgp->ts_data[id] = &data[id]; - ti_thermal = -devm_thermal_zone_of_sensor_register (bgp->dev, id, - &data[id], - &k3_of_thermal_ops); + ti_thermal =devm_thermal_of_zone_register (bgp->dev, id, &data[id], + &k3_of_thermal_ops);if (IS_ERR (ti_thermal)) {dev_err (bgp->dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (ti_thermal);
Signature · 1 line
2.25.1
Re: [PATCH v5 21/33] thermal/drivers/banggap: Switch to new of API
On August 5, 2022 thus sayeth Daniel Lezcano:
Quoted 8 lines
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>
Quoted 5 lines
--- drivers/thermal/k3_bandgap.c | 12 ++++++------ drivers/thermal/k3_j72xx_bandgap.c | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-)
Thanks for updating the drivers!
~Bryan
[thermal: thermal/next] thermal/drivers/banggap: Switch to new of API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: b86105ed9f3bfead2aaf3daefa99b694ba5da443 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//b86105ed9f3bfead2aaf3daefa99b694ba5da443 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:37 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/banggap: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/k3_bandgap.c | 12 ++++++------ drivers/thermal/k3_j72xx_bandgap.c | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-)
drivers/thermal/k3_bandgap.c +6 -6
@@ -139,9 +139,9 @@ static int k3_bgp_read_temp(struct k3_thermal_data *devdata,return 0 ; } -static int k3_thermal_get_temp (void *devdata,int *temp) +static int k3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct k3_thermal_data *data = devdata; +struct k3_thermal_data *data = tz->devdata;int ret =0 ; ret =k3_bgp_read_temp (data, temp);
@@ -151,7 +151,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)return ret; } -static const struct thermal_zone_of_device_ops k3_of_thermal_ops = { +static const struct thermal_zone_device_ops k3_of_thermal_ops = { .get_temp = k3_thermal_get_temp, };
@@ -213,9 +213,9 @@ static int k3_bandgap_probe(struct platform_device *pdev)writel (val, data[id].bgp->base + data[id].ctrl_offset); data[id].tzd = -devm_thermal_zone_of_sensor_register (dev, id, - &data[id], - &k3_of_thermal_ops); +devm_thermal_of_zone_register (dev, id, + &data[id], + &k3_of_thermal_ops);if (IS_ERR (data[id].tzd)) {dev_err (dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (data[id].tzd);
drivers/thermal/k3_j72xx_bandgap.c +5 -7
@@ -247,9 +247,9 @@ static inline int k3_bgp_read_temp(struct k3_thermal_data *devdata, }/* Get temperature callback function for thermal zone */ -static int k3_thermal_get_temp (void *devdata,int *temp) +static int k3_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct k3_thermal_data *data = devdata; +struct k3_thermal_data *data = tz->devdata;int ret =0 ; ret =k3_bgp_read_temp (data, temp);
@@ -259,7 +259,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)return ret; } -static const struct thermal_zone_of_device_ops k3_of_thermal_ops = { +static const struct thermal_zone_device_ops k3_of_thermal_ops = { .get_temp = k3_thermal_get_temp, };
@@ -474,10 +474,8 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)writel (val, data[id].bgp->cfg2_base + data[id].ctrl_offset); bgp->ts_data[id] = &data[id]; - ti_thermal = -devm_thermal_zone_of_sensor_register (bgp->dev, id, - &data[id], - &k3_of_thermal_ops); + ti_thermal =devm_thermal_of_zone_register (bgp->dev, id, &data[id], + &k3_of_thermal_ops);if (IS_ERR (ti_thermal)) {dev_err (bgp->dev,"thermal zone device is NULL\n" ); ret =PTR_ERR (ti_thermal);
PATCH v5 22/33 thermal/drivers/maxim: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/max77620_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/max77620_thermal.c +4 -4
@@ -44,9 +44,9 @@ struct max77620_therm_info {* Return 0 on success otherwise error number to show reason of failure. */ -static int max77620_thermal_read_temp (void *data,int *temp) +static int max77620_thermal_read_temp (struct thermal_zone_device *tz,int *temp) { -struct max77620_therm_info *mtherm = data; +struct max77620_therm_info *mtherm = tz->devdata;unsigned int val;int ret;
@@ -66,7 +66,7 @@ static int max77620_thermal_read_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops max77620_thermal_ops = { +static const struct thermal_zone_device_ops max77620_thermal_ops = { .get_temp = max77620_thermal_read_temp, };
@@ -114,7 +114,7 @@ static int max77620_thermal_probe(struct platform_device *pdev)*/ device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); - mtherm->tz_device =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , + mtherm->tz_device =devm_thermal_of_zone_register (&pdev->dev,0 , mtherm, &max77620_thermal_ops);if (IS_ERR (mtherm->tz_device)) { ret =PTR_ERR (mtherm->tz_device);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/maxim: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: ae11d6a87c3e742418baa591be1e719a95788059 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//ae11d6a87c3e742418baa591be1e719a95788059 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:38 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/maxim: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/max77620_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/thermal/max77620_thermal.c +4 -4
@@ -44,9 +44,9 @@ struct max77620_therm_info {* Return 0 on success otherwise error number to show reason of failure. */ -static int max77620_thermal_read_temp (void *data,int *temp) +static int max77620_thermal_read_temp (struct thermal_zone_device *tz,int *temp) { -struct max77620_therm_info *mtherm = data; +struct max77620_therm_info *mtherm = tz->devdata;unsigned int val;int ret;
@@ -66,7 +66,7 @@ static int max77620_thermal_read_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops max77620_thermal_ops = { +static const struct thermal_zone_device_ops max77620_thermal_ops = { .get_temp = max77620_thermal_read_temp, };
@@ -114,7 +114,7 @@ static int max77620_thermal_probe(struct platform_device *pdev)*/ device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); - mtherm->tz_device =devm_thermal_zone_of_sensor_register (&pdev->dev,0 , + mtherm->tz_device =devm_thermal_of_zone_register (&pdev->dev,0 , mtherm, &max77620_thermal_ops);if (IS_ERR (mtherm->tz_device)) { ret =PTR_ERR (mtherm->tz_device);
PATCH v5 23/33 thermal/drivers/hisilicon: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/hisi_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/hisi_thermal.c +7 -7
@@ -442,9 +442,9 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)return 0 ; } -static int hisi_thermal_get_temp (void *__data,int *temp) +static int hisi_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct hisi_thermal_sensor *sensor = __data; +struct hisi_thermal_sensor *sensor = tz->devdata;struct hisi_thermal_data *data = sensor->data; *temp = data->ops->get_temp (sensor);
@@ -455,7 +455,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { +static const struct thermal_zone_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };
@@ -467,7 +467,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) data->ops->irq_handler (sensor); -hisi_thermal_get_temp (sensor, &temp); + temp = data->ops->get_temp (sensor);if (temp >= sensor->thres_temp) { dev_crit(&data->pdev->dev,
@@ -492,9 +492,9 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,int ret, i;const struct thermal_trip *trip; - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->id, sensor, - &hisi_of_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, + sensor->id, sensor, + &hisi_of_thermal_ops);if (IS_ERR (sensor->tzd)) { ret =PTR_ERR (sensor->tzd); sensor->tzd =NULL ;
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/hisilicon: Switch to new of API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 5ee7811e9afa4f6a1e6bf9231d096c9e483444a2 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//5ee7811e9afa4f6a1e6bf9231d096c9e483444a2 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:39 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/hisilicon: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/hisi_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/thermal/hisi_thermal.c +7 -7
@@ -434,9 +434,9 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)return 0 ; } -static int hisi_thermal_get_temp (void *__data,int *temp) +static int hisi_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct hisi_thermal_sensor *sensor = __data; +struct hisi_thermal_sensor *sensor = tz->devdata;struct hisi_thermal_data *data = sensor->data; *temp = data->ops->get_temp (sensor);
@@ -447,7 +447,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { +static const struct thermal_zone_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };
@@ -459,7 +459,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) data->ops->irq_handler (sensor); -hisi_thermal_get_temp (sensor, &temp); + temp = data->ops->get_temp (sensor);if (temp >= sensor->thres_temp) { dev_crit(&data->pdev->dev,
@@ -484,9 +484,9 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,int ret, i;const struct thermal_trip *trip; - sensor->tzd =devm_thermal_zone_of_sensor_register (&pdev->dev, - sensor->id, sensor, - &hisi_of_thermal_ops); + sensor->tzd =devm_thermal_of_zone_register (&pdev->dev, + sensor->id, sensor, + &hisi_of_thermal_ops);if (IS_ERR (sensor->tzd)) { ret =PTR_ERR (sensor->tzd); sensor->tzd =NULL ;
PATCH v5 24/33 thermal/drivers/ti-soc: Switch to new of API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- .../thermal/ti-soc-thermal/ti-thermal-common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +8 -8
@@ -65,10 +65,10 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)/* thermal zone ops */ /* Get temperature callback function for thermal zone */ -static inline int __ti_thermal_get_temp (void *devdata,int *temp) +static inline int __ti_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {struct thermal_zone_device *pcb_tz =NULL ; -struct ti_thermal_data *data = devdata; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;const struct ti_temp_sensor *s;int ret, tmp, slope, constant;
@@ -85,8 +85,8 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret;/* Default constants */ - slope =thermal_zone_get_slope (data->ti_thermal); - constant =thermal_zone_get_offset (data->ti_thermal); + slope =thermal_zone_get_slope (tz); + constant =thermal_zone_get_offset (tz); pcb_tz = data->pcb_tz;/* In case pcb zone is available, use the extrapolation rule with it */
@@ -107,9 +107,9 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret; } -static int __ti_thermal_get_trend (void *p,int trip,enum thermal_trend *trend) +static int __ti_thermal_get_trend (struct thermal_zone_device *tz,int trip,enum thermal_trend *trend) { -struct ti_thermal_data *data = p; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;int id, tr, ret =0 ;
@@ -130,7 +130,7 @@ static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)return 0 ; } -static const struct thermal_zone_of_device_ops ti_of_thermal_ops = { +static const struct thermal_zone_device_ops ti_of_thermal_ops = { .get_temp = __ti_thermal_get_temp, .get_trend = __ti_thermal_get_trend, };
@@ -170,7 +170,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,return -EINVAL ;/* in case this is specified by DT */ - data->ti_thermal =devm_thermal_zone_of_sensor_register (bgp->dev, id, + data->ti_thermal =devm_thermal_of_zone_register (bgp->dev, id, data, &ti_of_thermal_ops);if (IS_ERR (data->ti_thermal)) {dev_err (bgp->dev,"thermal zone device is NULL\n" );
Signature · 1 line
2.25.1
Re: [PATCH v5 24/33] thermal/drivers/ti-soc: Switch to new of API
Quoted 6 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.
Quoted 64 lines
Signed-off-by Daniel Lezcano <[email protected]>--- .../thermal/ti-soc-thermal/ti-thermal-common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/thermal/ti-soc-thermal/ti-thermal-common.c +8
-8@@ -65,10 +65,10 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)/* thermal zone ops */ /* Get temperature callback function for thermal zone */ -static inline int __ti_thermal_get_temp (void *devdata,int *temp) +static inline int __ti_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {struct thermal_zone_device *pcb_tz =NULL ; -struct ti_thermal_data *data = devdata; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;const struct ti_temp_sensor *s;int ret, tmp, slope, constant;@@ -85,8 +85,8 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret;/* Default constants */ - slope =thermal_zone_get_slope (data->ti_thermal); - constant =thermal_zone_get_offset (data->ti_thermal); + slope =thermal_zone_get_slope (tz); + constant =thermal_zone_get_offset (tz); pcb_tz = data->pcb_tz;/* In case pcb zone is available, use the extrapolation rule with it */ @@ -107,9 +107,9 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret; } -static int __ti_thermal_get_trend (void *p,int trip,enum thermal_trend *trend) +static int __ti_thermal_get_trend (struct thermal_zone_device *tz,int trip,enum thermal_trend *trend) { -struct ti_thermal_data *data = p; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;int id, tr, ret =0 ;@@ -130,7 +130,7 @@ static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)return 0 ; } -static const struct thermal_zone_of_device_ops ti_of_thermal_ops = { +static const struct thermal_zone_device_ops ti_of_thermal_ops = { .get_temp = __ti_thermal_get_temp, .get_trend = __ti_thermal_get_trend, };@@ -170,7 +170,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,return -EINVAL ;/* in case this is specified by DT */ - data->ti_thermal =devm_thermal_zone_of_sensor_register (bgp->dev, id, + data->ti_thermal =devm_thermal_of_zone_register (bgp->dev, id, data, &ti_of_thermal_ops);if (IS_ERR (data->ti_thermal)) {dev_err (bgp->dev,"thermal zone device is NULL\n" );
[thermal: thermal/next] thermal/drivers/ti-soc: Switch to new of API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 2cf3c72a3ffba080b8188a07c19514cd43df6097 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//2cf3c72a3ffba080b8188a07c19514cd43df6097 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:40 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
thermal/drivers/ti-soc: Switch to new of API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 16 ++++++------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +8 -8
@@ -65,10 +65,10 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)/* thermal zone ops */ /* Get temperature callback function for thermal zone */ -static inline int __ti_thermal_get_temp (void *devdata,int *temp) +static inline int __ti_thermal_get_temp (struct thermal_zone_device *tz,int *temp) {struct thermal_zone_device *pcb_tz =NULL ; -struct ti_thermal_data *data = devdata; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;const struct ti_temp_sensor *s;int ret, tmp, slope, constant;
@@ -85,8 +85,8 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret;/* Default constants */ - slope =thermal_zone_get_slope (data->ti_thermal); - constant =thermal_zone_get_offset (data->ti_thermal); + slope =thermal_zone_get_slope (tz); + constant =thermal_zone_get_offset (tz); pcb_tz = data->pcb_tz;/* In case pcb zone is available, use the extrapolation rule with it */
@@ -107,9 +107,9 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)return ret; } -static int __ti_thermal_get_trend (void *p,int trip,enum thermal_trend *trend) +static int __ti_thermal_get_trend (struct thermal_zone_device *tz,int trip,enum thermal_trend *trend) { -struct ti_thermal_data *data = p; +struct ti_thermal_data *data = tz->devdata;struct ti_bandgap *bgp;int id, tr, ret =0 ;
@@ -130,7 +130,7 @@ static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)return 0 ; } -static const struct thermal_zone_of_device_ops ti_of_thermal_ops = { +static const struct thermal_zone_device_ops ti_of_thermal_ops = { .get_temp = __ti_thermal_get_temp, .get_trend = __ti_thermal_get_trend, };
@@ -170,7 +170,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,return -EINVAL ;/* in case this is specified by DT */ - data->ti_thermal =devm_thermal_zone_of_sensor_register (bgp->dev, id, + data->ti_thermal =devm_thermal_of_zone_register (bgp->dev, id, data, &ti_of_thermal_ops);if (IS_ERR (data->ti_thermal)) {dev_err (bgp->dev,"thermal zone device is NULL\n" );
PATCH v5 25/33 ata/drivers/ahci_imx: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
sata_ahci_read_temperature() is used by sata_ahci_show_temp() also.
So in order to change the function prototype for the get_temp ops which does not take a void* but a thermal_zone_device* structure, this function wraps the call.
--- drivers/ata/ahci_imx.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/ata/ahci_imx.c +10 -5
@@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio) }/* SATA AHCI temperature monitor */ -static int sata_ahci_read_temperature (void *dev,int *temp) +static int __sata_ahci_read_temperature (void *dev,int *temp) {u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;u32 str1, str2, str3, str4;
@@ -416,6 +416,11 @@ static int sata_ahci_read_temperature(void *dev, int *temp)return 0 ; } +static int sata_ahci_read_temperature (struct thermal_zone_device *tz,int *temp) +{ +return __sata_ahci_read_temperature (tz->devdata, temp); +} +static ssize_t sata_ahci_show_temp (struct device *dev,struct device_attribute *da,char *buf)
@@ -423,14 +428,14 @@ static ssize_t sata_ahci_show_temp(struct device *dev,unsigned int temp =0 ;int err; - err =sata_ahci_read_temperature (dev, &temp); + err =__sata_ahci_read_temperature (dev, &temp);if (err <0 )return err;return sprintf (buf,"%u\n" , temp); } -static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = { +static const struct thermal_zone_device_ops fsl_sata_ahci_of_thermal_ops = { .get_temp = sata_ahci_read_temperature, };
@@ -1131,8 +1136,8 @@ static int imx_ahci_probe(struct platform_device *pdev) ret =PTR_ERR (hwmon_dev); goto disable_clk; } -devm_thermal_zone_of_sensor_register (hwmon_dev,0 , hwmon_dev, - &fsl_sata_ahci_of_thermal_ops); +devm_thermal_of_zone_register (hwmon_dev,0 , hwmon_dev, + &fsl_sata_ahci_of_thermal_ops);dev_info (dev,"%s: sensor 'sata_ahci'\n" ,dev_name (hwmon_dev)); }
Signature · 1 line
2.25.1
[thermal: thermal/next] ata/drivers/ahci_imx: Switch to new of thermal API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: f1d8b5042ecf9e99294109bb5a1566f6a2039c89 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//f1d8b5042ecf9e99294109bb5a1566f6a2039c89 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:41 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
ata/drivers/ahci_imx: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
sata_ahci_read_temperature() is used by sata_ahci_show_temp() also.
So in order to change the function prototype for the get_temp ops which does not take a void* but a thermal_zone_device* structure, this function wraps the call.
--- drivers/ata/ahci_imx.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/ata/ahci_imx.c +10 -5
@@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio) }/* SATA AHCI temperature monitor */ -static int sata_ahci_read_temperature (void *dev,int *temp) +static int __sata_ahci_read_temperature (void *dev,int *temp) {u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;u32 str1, str2, str3, str4;
@@ -416,6 +416,11 @@ static int sata_ahci_read_temperature(void *dev, int *temp)return 0 ; } +static int sata_ahci_read_temperature (struct thermal_zone_device *tz,int *temp) +{ +return __sata_ahci_read_temperature (tz->devdata, temp); +} +static ssize_t sata_ahci_show_temp (struct device *dev,struct device_attribute *da,char *buf)
@@ -423,14 +428,14 @@ static ssize_t sata_ahci_show_temp(struct device *dev,unsigned int temp =0 ;int err; - err =sata_ahci_read_temperature (dev, &temp); + err =__sata_ahci_read_temperature (dev, &temp);if (err <0 )return err;return sprintf (buf,"%u\n" , temp); } -static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = { +static const struct thermal_zone_device_ops fsl_sata_ahci_of_thermal_ops = { .get_temp = sata_ahci_read_temperature, };
@@ -1131,8 +1136,8 @@ static int imx_ahci_probe(struct platform_device *pdev) ret =PTR_ERR (hwmon_dev); goto disable_clk; } -devm_thermal_zone_of_sensor_register (hwmon_dev,0 , hwmon_dev, - &fsl_sata_ahci_of_thermal_ops); +devm_thermal_of_zone_register (hwmon_dev,0 , hwmon_dev, + &fsl_sata_ahci_of_thermal_ops);dev_info (dev,"%s: sensor 'sata_ahci'\n" ,dev_name (hwmon_dev)); }
PATCH v5 26/33 hwmon/drivers/pm_bus: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/hwmon/pmbus/pmbus_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -5
@@ -1109,9 +1109,9 @@ struct pmbus_thermal_data {struct pmbus_sensor *sensor; }; -static int pmbus_thermal_get_temp (void *data,int *temp) +static int pmbus_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct pmbus_thermal_data *tdata = data; +struct pmbus_thermal_data *tdata = tz->devdata;struct pmbus_sensor *sensor = tdata->sensor;struct pmbus_data *pmbus_data = tdata->pmbus_data;struct i2c_client *client =to_i2c_client (pmbus_data->dev);
@@ -1135,7 +1135,7 @@ static int pmbus_thermal_get_temp(void *data, int *temp)return ret; } -static const struct thermal_zone_of_device_ops pmbus_thermal_ops = { +static const struct thermal_zone_device_ops pmbus_thermal_ops = { .get_temp = pmbus_thermal_get_temp, };
@@ -1153,8 +1153,8 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data, tdata->sensor = sensor; tdata->pmbus_data = pmbus_data; - tzd =devm_thermal_zone_of_sensor_register (dev, index, tdata, - &pmbus_thermal_ops); + tzd =devm_thermal_of_zone_register (dev, index, tdata, + &pmbus_thermal_ops);/* * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, * so ignore that error but forward any other error.
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH v5 26/33] hwmon/drivers/pm_bus: Switch to new of thermal API
Quoted 8 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>
Subject tag should be something like "hwmon: (pmbus) ...".
Also, from other patches it appears that this would or might result in a registration failure if a thermal zone for the sensor does not exist. This will need to be resolved before the patch is can be applied.
Guenter
Quoted 43 lines
--- drivers/hwmon/pmbus/pmbus_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/hwmon/pmbus/pmbus_core.c +5
-5@@ -1109,9 +1109,9 @@ struct pmbus_thermal_data {struct pmbus_sensor *sensor; }; -static int pmbus_thermal_get_temp (void *data,int *temp) +static int pmbus_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct pmbus_thermal_data *tdata = data; +struct pmbus_thermal_data *tdata = tz->devdata;struct pmbus_sensor *sensor = tdata->sensor;struct pmbus_data *pmbus_data = tdata->pmbus_data;struct i2c_client *client =to_i2c_client (pmbus_data->dev);@@ -1135,7 +1135,7 @@ static int pmbus_thermal_get_temp(void *data, int *temp)return ret; } -static const struct thermal_zone_of_device_ops pmbus_thermal_ops = { +static const struct thermal_zone_device_ops pmbus_thermal_ops = { .get_temp = pmbus_thermal_get_temp, };@@ -1153,8 +1153,8 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data, tdata->sensor = sensor; tdata->pmbus_data = pmbus_data; - tzd =devm_thermal_zone_of_sensor_register (dev, index, tdata, - &pmbus_thermal_ops); + tzd =devm_thermal_of_zone_register (dev, index, tdata, + &pmbus_thermal_ops);/* * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, * so ignore that error but forward any other error. Signature · 1 line
2.25.1
Re: [PATCH v5 26/33] hwmon/drivers/pm_bus: Switch to new of thermal API
Quoted 8 lines · Guenter Roeck
Quoted 7 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.
Quoted 7 lines
Quoted 1 line
Signed-off-by Daniel Lezcano <[email protected]>Subject tag should be something like "hwmon: (pmbus) ...".
Also, from other patches it appears that this would or might result in a registration failure if a thermal zone for the sensor does not exist. This will need to be resolved before the patch is can be applied.
With the subject fixed, shall I add your Acked-by ?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Re: [PATCH v5 26/33] hwmon/drivers/pm_bus: Switch to new of thermal API
Quoted 11 lines · Daniel Lezcano
Quoted 10 lines · Guenter Roeck
Quoted 8 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>
Quoted 8 lines
Quoted 5 lines
Subject tag should be something like "hwmon: (pmbus) ...".
Also, from other patches it appears that this would or might result in a registration failure if a thermal zone for the sensor does not exist. This will need to be resolved before the patch is can be applied.
With the subject fixed, shall I add your Acked-by ?
Yes. With subject fixed:
Thanks,
Guenter
[thermal: thermal/next] hwmon: pm_bus: core: Switch to new of thermal API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 613ed3f67609291c9b757d62f1f6734e40cb60d8 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//613ed3f67609291c9b757d62f1f6734e40cb60d8 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:42 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:38 +02:00
hwmon: pm_bus: core: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/hwmon/pmbus/pmbus_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +5 -5
@@ -1270,9 +1270,9 @@ struct pmbus_thermal_data {struct pmbus_sensor *sensor; }; -static int pmbus_thermal_get_temp (void *data,int *temp) +static int pmbus_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct pmbus_thermal_data *tdata = data; +struct pmbus_thermal_data *tdata = tz->devdata;struct pmbus_sensor *sensor = tdata->sensor;struct pmbus_data *pmbus_data = tdata->pmbus_data;struct i2c_client *client =to_i2c_client (pmbus_data->dev);
@@ -1296,7 +1296,7 @@ static int pmbus_thermal_get_temp(void *data, int *temp)return ret; } -static const struct thermal_zone_of_device_ops pmbus_thermal_ops = { +static const struct thermal_zone_device_ops pmbus_thermal_ops = { .get_temp = pmbus_thermal_get_temp, };
@@ -1314,8 +1314,8 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data, tdata->sensor = sensor; tdata->pmbus_data = pmbus_data; - tzd =devm_thermal_zone_of_sensor_register (dev, index, tdata, - &pmbus_thermal_ops); + tzd =devm_thermal_of_zone_register (dev, index, tdata, + &pmbus_thermal_ops);/* * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, * so ignore that error but forward any other error.
PATCH v5 27/33 hwmon/drivers/core: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/hwmon/hwmon.c | 14 +++++++------- drivers/hwmon/scpi-hwmon.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/hwmon/hwmon.c +7 -7
@@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida);* between hwmon and thermal_sys modules. */ #ifdef CONFIG_THERMAL_OF -static int hwmon_thermal_get_temp (void *data,int *temp) +static int hwmon_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct hwmon_thermal_data *tdata = data; +struct hwmon_thermal_data *tdata = tz->devdata;struct hwmon_device *hwdev =to_hwmon_device (tdata->dev);int ret;long t;
@@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp)return 0 ; } -static int hwmon_thermal_set_trips (void *data,int low,int high) +static int hwmon_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct hwmon_thermal_data *tdata = data; +struct hwmon_thermal_data *tdata = tz->devdata;struct hwmon_device *hwdev =to_hwmon_device (tdata->dev);const struct hwmon_chip_info *chip = hwdev->chip;const struct hwmon_channel_info **info = chip->info;
@@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { +static const struct thermal_zone_device_ops hwmon_thermal_ops = { .get_temp = hwmon_thermal_get_temp, .set_trips = hwmon_thermal_set_trips, };
@@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index) tdata->dev = dev; tdata->index = index; - tzd =devm_thermal_zone_of_sensor_register (dev, index, tdata, - &hwmon_thermal_ops); + tzd =devm_thermal_of_zone_register (dev, index, tdata, + &hwmon_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) != -ENODEV )return PTR_ERR (tzd);
drivers/hwmon/scpi-hwmon.c +7 -7
@@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor) } } -static int scpi_read_temp (void *dev,int *temp) +static int scpi_read_temp (struct thermal_zone_device *tz,int *temp) { -struct scpi_thermal_zone *zone = dev; +struct scpi_thermal_zone *zone = tz->devdata;struct scpi_sensors *scpi_sensors = zone->scpi_sensors;struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
@@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)return sprintf (buf,"%s\n" , sensor->info.name); } -static const struct thermal_zone_of_device_ops scpi_sensor_ops = { +static const struct thermal_zone_device_ops scpi_sensor_ops = { .get_temp = scpi_read_temp, };
@@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev) zone->sensor_id = i; zone->scpi_sensors = scpi_sensors; - z =devm_thermal_zone_of_sensor_register (dev, - sensor->info.sensor_id, - zone, - &scpi_sensor_ops); + z =devm_thermal_of_zone_register (dev, + sensor->info.sensor_id, + zone, + &scpi_sensor_ops);/* * The call to thermal_zone_of_sensor_register returns * an error for sensors that are not associated with
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH v5 27/33] hwmon/drivers/core: Switch to new of thermal API
Quoted 9 lines · Daniel Lezcano
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>Acked-by Guenter Roeck <[email protected]>
Based on other feedback, it apears that with this patch in place the hwmon device fails to register unless it is indeed part of a configured thermal zone (which so far was optional). Given that, I have to withdraw my Acked-by: tag until this problem has been resolved.
Guenter
[thermal: thermal/next] hwmon/drivers/core: Switch to new of thermal API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: e5181331359d9311b3cc7e09d9d1cb2ffe87f602 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//e5181331359d9311b3cc7e09d9d1cb2ffe87f602 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:43 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
hwmon/drivers/core: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/hwmon/hwmon.c | 14 +++++++------- drivers/hwmon/scpi-hwmon.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/hwmon/hwmon.c +7 -7
@@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida);* between hwmon and thermal_sys modules. */ #ifdef CONFIG_THERMAL_OF -static int hwmon_thermal_get_temp (void *data,int *temp) +static int hwmon_thermal_get_temp (struct thermal_zone_device *tz,int *temp) { -struct hwmon_thermal_data *tdata = data; +struct hwmon_thermal_data *tdata = tz->devdata;struct hwmon_device *hwdev =to_hwmon_device (tdata->dev);int ret;long t;
@@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp)return 0 ; } -static int hwmon_thermal_set_trips (void *data,int low,int high) +static int hwmon_thermal_set_trips (struct thermal_zone_device *tz,int low,int high) { -struct hwmon_thermal_data *tdata = data; +struct hwmon_thermal_data *tdata = tz->devdata;struct hwmon_device *hwdev =to_hwmon_device (tdata->dev);const struct hwmon_chip_info *chip = hwdev->chip;const struct hwmon_channel_info **info = chip->info;
@@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high)return 0 ; } -static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { +static const struct thermal_zone_device_ops hwmon_thermal_ops = { .get_temp = hwmon_thermal_get_temp, .set_trips = hwmon_thermal_set_trips, };
@@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index) tdata->dev = dev; tdata->index = index; - tzd =devm_thermal_zone_of_sensor_register (dev, index, tdata, - &hwmon_thermal_ops); + tzd =devm_thermal_of_zone_register (dev, index, tdata, + &hwmon_thermal_ops);if (IS_ERR (tzd)) {if (PTR_ERR (tzd) != -ENODEV )return PTR_ERR (tzd);
drivers/hwmon/scpi-hwmon.c +7 -7
@@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor) } } -static int scpi_read_temp (void *dev,int *temp) +static int scpi_read_temp (struct thermal_zone_device *tz,int *temp) { -struct scpi_thermal_zone *zone = dev; +struct scpi_thermal_zone *zone = tz->devdata;struct scpi_sensors *scpi_sensors = zone->scpi_sensors;struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
@@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)return sprintf (buf,"%s\n" , sensor->info.name); } -static const struct thermal_zone_of_device_ops scpi_sensor_ops = { +static const struct thermal_zone_device_ops scpi_sensor_ops = { .get_temp = scpi_read_temp, };
@@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev) zone->sensor_id = i; zone->scpi_sensors = scpi_sensors; - z =devm_thermal_zone_of_sensor_register (dev, - sensor->info.sensor_id, - zone, - &scpi_sensor_ops); + z =devm_thermal_of_zone_register (dev, + sensor->info.sensor_id, + zone, + &scpi_sensor_ops);/* * The call to thermal_zone_of_sensor_register returns * an error for sensors that are not associated with
PATCH v5 28/33 iio/drivers/sun4i_gpadc: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +6 -8
@@ -412,9 +412,9 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)return 0 ; } -static int sun4i_gpadc_get_temp (void *data,int *temp) +static int sun4i_gpadc_get_temp (struct thermal_zone_device *tz,int *temp) { -struct sun4i_gpadc_iio *info = data; +struct sun4i_gpadc_iio *info = tz->devdata;int val, scale, offset;if (sun4i_gpadc_temp_read (info->indio_dev, &val))
@@ -428,7 +428,7 @@ static int sun4i_gpadc_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { +static const struct thermal_zone_device_ops sun4i_ts_tz_ops = { .get_temp = &sun4i_gpadc_get_temp, };
@@ -637,9 +637,9 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);if (IS_ENABLED (CONFIG_THERMAL_OF )) { - info->tzd =thermal_zone_of_sensor_register (info->sensor_device, -0 , info, - &sun4i_ts_tz_ops); + info->tzd =devm_thermal_of_zone_register (info->sensor_device, +0 , info, + &sun4i_ts_tz_ops);/* * Do not fail driver probing when failing to register in * thermal because no thermal DT node is found.
@@ -681,8 +681,6 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)if (!IS_ENABLED (CONFIG_THERMAL_OF ))return 0 ; -thermal_zone_of_sensor_unregister (info->sensor_device, info->tzd); -if (!info->no_irq)iio_map_array_unregister (indio_dev);
Signature · 1 line
2.25.1
Re: [PATCH v5 28/33] iio/drivers/sun4i_gpadc: Switch to new of thermal API
Dne petek, 05. avgust 2022 ob 00:43:44 CEST je Daniel Lezcano napisal(a):
Quoted 9 lines
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>Acked-by Jonathan Cameron <[email protected]>
Best regards,
Jernej
[thermal: thermal/next] iio/drivers/sun4i_gpadc: Switch to new of thermal API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: de15b8403fa9872cb626a52651b257089b34f5d2 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//de15b8403fa9872cb626a52651b257089b34f5d2 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:44 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
iio/drivers/sun4i_gpadc: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +6 -8
@@ -412,9 +412,9 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)return 0 ; } -static int sun4i_gpadc_get_temp (void *data,int *temp) +static int sun4i_gpadc_get_temp (struct thermal_zone_device *tz,int *temp) { -struct sun4i_gpadc_iio *info = data; +struct sun4i_gpadc_iio *info = tz->devdata;int val, scale, offset;if (sun4i_gpadc_temp_read (info->indio_dev, &val))
@@ -428,7 +428,7 @@ static int sun4i_gpadc_get_temp(void *data, int *temp)return 0 ; } -static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { +static const struct thermal_zone_device_ops sun4i_ts_tz_ops = { .get_temp = &sun4i_gpadc_get_temp, };
@@ -637,9 +637,9 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);if (IS_ENABLED (CONFIG_THERMAL_OF )) { - info->tzd =thermal_zone_of_sensor_register (info->sensor_device, -0 , info, - &sun4i_ts_tz_ops); + info->tzd =devm_thermal_of_zone_register (info->sensor_device, +0 , info, + &sun4i_ts_tz_ops);/* * Do not fail driver probing when failing to register in * thermal because no thermal DT node is found.
@@ -681,8 +681,6 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)if (!IS_ENABLED (CONFIG_THERMAL_OF ))return 0 ; -thermal_zone_of_sensor_unregister (info->sensor_device, info->tzd); -if (!info->no_irq)iio_map_array_unregister (indio_dev);
PATCH v5 29/33 Input: sun4i-ts - switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/input/touchscreen/sun4i-ts.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/input/touchscreen/sun4i-ts.c +5 -5
@@ -192,12 +192,12 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)return 0 ; } -static int sun4i_get_tz_temp (void *data,int *temp) +static int sun4i_get_tz_temp (struct thermal_zone_device *tz,int *temp) { -return sun4i_get_temp (data, temp); +return sun4i_get_temp (tz->devdata, temp); } -static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { +static const struct thermal_zone_device_ops sun4i_ts_tz_ops = { .get_temp = sun4i_get_tz_temp, };
@@ -356,8 +356,8 @@ static int sun4i_ts_probe(struct platform_device *pdev)if (IS_ERR (hwmon))return PTR_ERR (hwmon); - thermal =devm_thermal_zone_of_sensor_register (ts->dev,0 , ts, - &sun4i_ts_tz_ops); + thermal =devm_thermal_of_zone_register (ts->dev,0 , ts, + &sun4i_ts_tz_ops);if (IS_ERR (thermal))return PTR_ERR (thermal);
Signature · 1 line
2.25.1
Re: [PATCH v5 29/33] Input: sun4i-ts - switch to new of thermal API
Dne petek, 05. avgust 2022 ob 00:43:45 CEST je Daniel Lezcano napisal(a):
Quoted 9 lines
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the
thermal_zone_device_opsformat and use the new API to register the thermal zone with these generic ops.Signed-off-by Daniel Lezcano <[email protected]>Acked-by Dmitry Torokhov <[email protected]>
Best regards,
Jernej
[thermal: thermal/next] Input: sun4i-ts - switch to new of thermal API
In reply to Daniel LezcanoThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: ad662b1d606515a048cef06c025dfb150cebaa8d Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//ad662b1d606515a048cef06c025dfb150cebaa8d Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:45 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
Input: sun4i-ts - switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/input/touchscreen/sun4i-ts.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/input/touchscreen/sun4i-ts.c +5 -5
@@ -192,12 +192,12 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)return 0 ; } -static int sun4i_get_tz_temp (void *data,int *temp) +static int sun4i_get_tz_temp (struct thermal_zone_device *tz,int *temp) { -return sun4i_get_temp (data, temp); +return sun4i_get_temp (tz->devdata, temp); } -static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = { +static const struct thermal_zone_device_ops sun4i_ts_tz_ops = { .get_temp = sun4i_get_tz_temp, };
@@ -356,8 +356,8 @@ static int sun4i_ts_probe(struct platform_device *pdev)if (IS_ERR (hwmon))return PTR_ERR (hwmon); - thermal =devm_thermal_zone_of_sensor_register (ts->dev,0 , ts, - &sun4i_ts_tz_ops); + thermal =devm_thermal_of_zone_register (ts->dev,0 , ts, + &sun4i_ts_tz_ops);if (IS_ERR (thermal))return PTR_ERR (thermal);
PATCH v5 30/33 regulator/drivers/max8976: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/regulator/max8973-regulator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/max8973-regulator.c +5 -5
@@ -447,9 +447,9 @@ static int max8973_init_dcdc(struct max8973_chip *max,return ret; } -static int max8973_thermal_read_temp (void *data,int *temp) +static int max8973_thermal_read_temp (struct thermal_zone_device *tz,int *temp) { -struct max8973_chip *mchip = data; +struct max8973_chip *mchip = tz->devdata;unsigned int val;int ret;
@@ -478,7 +478,7 @@ static irqreturn_t max8973_thermal_irq(int irq, void *data)return IRQ_HANDLED ; } -static const struct thermal_zone_of_device_ops max77621_tz_ops = { +static const struct thermal_zone_device_ops max77621_tz_ops = { .get_temp = max8973_thermal_read_temp, };
@@ -492,8 +492,8 @@ static int max8973_thermal_init(struct max8973_chip *mchip)if (mchip->id !=MAX77621 )return 0 ; - tzd =devm_thermal_zone_of_sensor_register (mchip->dev,0 , mchip, - &max77621_tz_ops); + tzd =devm_thermal_of_zone_register (mchip->dev,0 , mchip, + &max77621_tz_ops);if (IS_ERR (tzd)) { ret =PTR_ERR (tzd); dev_err(mchip->dev, "Failed to register thermal sensor: %d\n",
Signature · 1 line
2.25.1
[thermal: thermal/next] regulator/drivers/max8976: Switch to new of thermal API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 826855ff5746d0f98877eaa4a438abc4e7b58fd5 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//826855ff5746d0f98877eaa4a438abc4e7b58fd5 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:46 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
regulator/drivers/max8976: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/regulator/max8973-regulator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/max8973-regulator.c +5 -5
@@ -434,9 +434,9 @@ static int max8973_init_dcdc(struct max8973_chip *max,return ret; } -static int max8973_thermal_read_temp (void *data,int *temp) +static int max8973_thermal_read_temp (struct thermal_zone_device *tz,int *temp) { -struct max8973_chip *mchip = data; +struct max8973_chip *mchip = tz->devdata;unsigned int val;int ret;
@@ -465,7 +465,7 @@ static irqreturn_t max8973_thermal_irq(int irq, void *data)return IRQ_HANDLED ; } -static const struct thermal_zone_of_device_ops max77621_tz_ops = { +static const struct thermal_zone_device_ops max77621_tz_ops = { .get_temp = max8973_thermal_read_temp, };
@@ -479,8 +479,8 @@ static int max8973_thermal_init(struct max8973_chip *mchip)if (mchip->id !=MAX77621 )return 0 ; - tzd =devm_thermal_zone_of_sensor_register (mchip->dev,0 , mchip, - &max77621_tz_ops); + tzd =devm_thermal_of_zone_register (mchip->dev,0 , mchip, + &max77621_tz_ops);if (IS_ERR (tzd)) { ret =PTR_ERR (tzd); dev_err(mchip->dev, "Failed to register thermal sensor: %d\n",
PATCH v5 31/33 thermal/drivers/samsung: Switch to new of thermal API
In reply to Daniel LezcanoThe thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/samsung/exynos_tmu.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +10 -14
@@ -650,9 +650,9 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)writel (con, data->base +EXYNOS_TMU_REG_CONTROL ); } -static int exynos_get_temp (void *p,int *temp) +static int exynos_get_temp (struct thermal_zone_device *tz,int *temp) { -struct exynos_tmu_data *data = p; +struct exynos_tmu_data *data = tz->devdata;int value, ret =0 ;if (!data || !data->tmu_read)
@@ -728,9 +728,9 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,writel (val, data->base + emul_con); } -static int exynos_tmu_set_emulation (void *drv_data,int temp) +static int exynos_tmu_set_emulation (struct thermal_zone_device *tz,int temp) { -struct exynos_tmu_data *data = drv_data; +struct exynos_tmu_data *data = tz->devdata;int ret = -EINVAL ;if (data->soc ==SOC_ARCH_EXYNOS4210 )
@@ -750,7 +750,7 @@ static int exynos_tmu_set_emulation(void *drv_data, int temp) }#else #define exynos4412_tmu_set_emulation NULL -static int exynos_tmu_set_emulation (void *drv_data,int temp) +static int exynos_tmu_set_emulation (struct thermal_zone_device *tz,int temp) {return -EINVAL ; }#endif /* CONFIG_THERMAL_EMULATION */
@@ -997,7 +997,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)return 0 ; } -static const struct thermal_zone_of_device_ops exynos_sensor_ops = { +static const struct thermal_zone_device_ops exynos_sensor_ops = { .get_temp = exynos_get_temp, .set_emul_temp = exynos_tmu_set_emulation, };
@@ -1091,8 +1091,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)* data->tzd must be registered before calling exynos_tmu_initialize(), * requesting irq and calling exynos_tmu_control(). */ - data->tzd =thermal_zone_of_sensor_register (&pdev->dev,0 , data, - &exynos_sensor_ops); + data->tzd =devm_thermal_of_zone_register (&pdev->dev,0 , data, + &exynos_sensor_ops);if (IS_ERR (data->tzd)) { ret =PTR_ERR (data->tzd);if (ret != -EPROBE_DEFER )
@@ -1104,21 +1104,19 @@ static int exynos_tmu_probe(struct platform_device *pdev) ret =exynos_tmu_initialize (pdev);if (ret) {dev_err (&pdev->dev,"Failed to initialize TMU\n" ); - goto err_thermal; + goto err_sclk; } ret =devm_request_irq (&pdev->dev, data->irq, exynos_tmu_irq,IRQF_TRIGGER_RISING |IRQF_SHARED ,dev_name (&pdev->dev), data);if (ret) {dev_err (&pdev->dev,"Failed to request irq: %d\n" , data->irq); - goto err_thermal; + goto err_sclk; }exynos_tmu_control (pdev, true);return 0 ; -err_thermal: -thermal_zone_of_sensor_unregister (&pdev->dev, data->tzd); err_sclk:clk_disable_unprepare (data->sclk); err_clk:
@@ -1136,9 +1134,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)static int exynos_tmu_remove (struct platform_device *pdev) {struct exynos_tmu_data *data =platform_get_drvdata (pdev); -struct thermal_zone_device *tzd = data->tzd; -thermal_zone_of_sensor_unregister (&pdev->dev, tzd);exynos_tmu_control (pdev, false);clk_disable_unprepare (data->sclk);
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/drivers/samsung: Switch to new of thermal API
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 7ea98f70c73ea37d379a76a69fa71653382a1724 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//7ea98f70c73ea37d379a76a69fa71653382a1724 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:47 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
thermal/drivers/samsung: Switch to new of thermal API
The thermal OF code has a new API allowing to migrate the OF initialization to a simpler approach. The ops are no longer device tree specific and are the generic ones provided by the core code.
Convert the ops to the thermal_zone_device_ops format and use the new API to register the thermal zone with these generic ops.
--- drivers/thermal/samsung/exynos_tmu.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/thermal/samsung/exynos_tmu.c +10 -14
@@ -650,9 +650,9 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)writel (con, data->base +EXYNOS_TMU_REG_CONTROL ); } -static int exynos_get_temp (void *p,int *temp) +static int exynos_get_temp (struct thermal_zone_device *tz,int *temp) { -struct exynos_tmu_data *data = p; +struct exynos_tmu_data *data = tz->devdata;int value, ret =0 ;if (!data || !data->tmu_read)
@@ -728,9 +728,9 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,writel (val, data->base + emul_con); } -static int exynos_tmu_set_emulation (void *drv_data,int temp) +static int exynos_tmu_set_emulation (struct thermal_zone_device *tz,int temp) { -struct exynos_tmu_data *data = drv_data; +struct exynos_tmu_data *data = tz->devdata;int ret = -EINVAL ;if (data->soc ==SOC_ARCH_EXYNOS4210 )
@@ -750,7 +750,7 @@ out: }#else #define exynos4412_tmu_set_emulation NULL -static int exynos_tmu_set_emulation (void *drv_data,int temp) +static int exynos_tmu_set_emulation (struct thermal_zone_device *tz,int temp) {return -EINVAL ; }#endif /* CONFIG_THERMAL_EMULATION */
@@ -997,7 +997,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)return 0 ; } -static const struct thermal_zone_of_device_ops exynos_sensor_ops = { +static const struct thermal_zone_device_ops exynos_sensor_ops = { .get_temp = exynos_get_temp, .set_emul_temp = exynos_tmu_set_emulation, };
@@ -1091,8 +1091,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)* data->tzd must be registered before calling exynos_tmu_initialize(), * requesting irq and calling exynos_tmu_control(). */ - data->tzd =thermal_zone_of_sensor_register (&pdev->dev,0 , data, - &exynos_sensor_ops); + data->tzd =devm_thermal_of_zone_register (&pdev->dev,0 , data, + &exynos_sensor_ops);if (IS_ERR (data->tzd)) { ret =PTR_ERR (data->tzd);if (ret != -EPROBE_DEFER )
@@ -1104,21 +1104,19 @@ static int exynos_tmu_probe(struct platform_device *pdev) ret =exynos_tmu_initialize (pdev);if (ret) {dev_err (&pdev->dev,"Failed to initialize TMU\n" ); - goto err_thermal; + goto err_sclk; } ret =devm_request_irq (&pdev->dev, data->irq, exynos_tmu_irq,IRQF_TRIGGER_RISING |IRQF_SHARED ,dev_name (&pdev->dev), data);if (ret) {dev_err (&pdev->dev,"Failed to request irq: %d\n" , data->irq); - goto err_thermal; + goto err_sclk; }exynos_tmu_control (pdev, true);return 0 ; -err_thermal: -thermal_zone_of_sensor_unregister (&pdev->dev, data->tzd); err_sclk:clk_disable_unprepare (data->sclk); err_clk:
@@ -1136,9 +1134,7 @@ err_sensor:static int exynos_tmu_remove (struct platform_device *pdev) {struct exynos_tmu_data *data =platform_get_drvdata (pdev); -struct thermal_zone_device *tzd = data->tzd; -thermal_zone_of_sensor_unregister (&pdev->dev, tzd);exynos_tmu_control (pdev, false);clk_disable_unprepare (data->sclk);
PATCH v5 32/33 thermal/core: Move set_trip_temp ops to the sysfs code
In reply to Daniel LezcanoGiven the trip points can be set in the thermal zone structure, there is no need of a specific OF function to do that. Move the code in the place where it is generic, in the sysfs set_trip_temp storing function.
--- drivers/thermal/thermal_of.c | 23 ----------------------- drivers/thermal/thermal_sysfs.c | 5 ++++- 2 files changed, 4 insertions(+), 24 deletions(-)
drivers/thermal/thermal_of.c +0 -23
@@ -288,28 +288,6 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,return 0 ; } -static int of_thermal_set_trip_temp (struct thermal_zone_device *tz,int trip, -int temp) -{ -struct __thermal_zone *data = tz->devdata; - -if (trip >= tz->num_trips || trip <0 ) -return -EDOM ; - -if (data->ops && data->ops->set_trip_temp) { -int ret; - - ret = data->ops->set_trip_temp (data->sensor_data, trip, temp); -if (ret) -return ret; - } - -/* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].temperature = temp; - -return 0 ; -} -static int of_thermal_get_trip_hyst (struct thermal_zone_device *tz,int trip,int *hyst) {
@@ -350,7 +328,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,static struct thermal_zone_device_ops of_thermal_ops = { .get_trip_type = of_thermal_get_trip_type, .get_trip_temp = of_thermal_get_trip_temp, - .set_trip_temp = of_thermal_set_trip_temp, .get_trip_hyst = of_thermal_get_trip_hyst, .set_trip_hyst = of_thermal_set_trip_hyst, .get_crit_temp = of_thermal_get_crit_temp,
drivers/thermal/thermal_sysfs.c +4 -1
@@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,int temperature, hyst =0 ;enum thermal_trip_type type; -if (!tz->ops->set_trip_temp) +if (!tz->ops->set_trip_temp && !tz->trips)return -EPERM ;if (sscanf (attr->attr.name,"trip_point_%d_temp" , &trip) !=1 )
@@ -128,6 +128,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,if (ret)return ret; +if (tz->trips) + tz->trips[trip].temperature = temperature; +if (tz->ops->get_trip_hyst) { ret = tz->ops->get_trip_hyst (tz, trip, &hyst);if (ret)
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/core: Move set_trip_temp ops to the sysfs code
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 9326167058e8a5b93179f19fc0368f5324a1f628 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//9326167058e8a5b93179f19fc0368f5324a1f628 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:48 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
thermal/core: Move set_trip_temp ops to the sysfs code
Given the trip points can be set in the thermal zone structure, there is no need of a specific OF function to do that. Move the code in the place where it is generic, in the sysfs set_trip_temp storing function.
--- drivers/thermal/thermal_of.c | 23 ----------------------- drivers/thermal/thermal_sysfs.c | 5 ++++- 2 files changed, 4 insertions(+), 24 deletions(-)
drivers/thermal/thermal_of.c +0 -23
@@ -288,28 +288,6 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,return 0 ; } -static int of_thermal_set_trip_temp (struct thermal_zone_device *tz,int trip, -int temp) -{ -struct __thermal_zone *data = tz->devdata; - -if (trip >= tz->num_trips || trip <0 ) -return -EDOM ; - -if (data->ops && data->ops->set_trip_temp) { -int ret; - - ret = data->ops->set_trip_temp (data->sensor_data, trip, temp); -if (ret) -return ret; - } - -/* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].temperature = temp; - -return 0 ; -} -static int of_thermal_get_trip_hyst (struct thermal_zone_device *tz,int trip,int *hyst) {
@@ -350,7 +328,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,static struct thermal_zone_device_ops of_thermal_ops = { .get_trip_type = of_thermal_get_trip_type, .get_trip_temp = of_thermal_get_trip_temp, - .set_trip_temp = of_thermal_set_trip_temp, .get_trip_hyst = of_thermal_get_trip_hyst, .set_trip_hyst = of_thermal_set_trip_hyst, .get_crit_temp = of_thermal_get_crit_temp,
drivers/thermal/thermal_sysfs.c +4 -1
@@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,int temperature, hyst =0 ;enum thermal_trip_type type; -if (!tz->ops->set_trip_temp) +if (!tz->ops->set_trip_temp && !tz->trips)return -EPERM ;if (sscanf (attr->attr.name,"trip_point_%d_temp" , &trip) !=1 )
@@ -128,6 +128,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,if (ret)return ret; +if (tz->trips) + tz->trips[trip].temperature = temperature; +if (tz->ops->get_trip_hyst) { ret = tz->ops->get_trip_hyst (tz, trip, &hyst);if (ret)
PATCH v5 33/33 thermal/of: Remove old OF code
In reply to Daniel LezcanoAll the drivers are converted to the new OF API, remove the old OF code.
--- drivers/thermal/thermal_core.h | 2 - drivers/thermal/thermal_of.c | 810 +-------------------------------- include/linux/thermal.h | 77 +--- 3 files changed, 16 insertions(+), 873 deletions(-)
drivers/thermal/thermal_core.h +0 -2
@@ -135,13 +135,11 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,/* device tree support */ #ifdef CONFIG_THERMAL_OF -int of_parse_thermal_zones (void );int of_thermal_get_ntrips (struct thermal_zone_device *);bool of_thermal_is_trip_valid (struct thermal_zone_device *,int );const struct thermal_trip *of_thermal_get_trip_points (struct thermal_zone_device *);#else -static inline int of_parse_thermal_zones (void ) {return 0 ; }static inline int of_thermal_get_ntrips (struct thermal_zone_device *tz) {return 0 ;
drivers/thermal/thermal_of.c +1 -809
852 lines not on this page · raw message
include/linux/thermal.h +15 -62
109 lines not on this page · raw message
Signature · 1 line
2.25.1
[thermal: thermal/next] thermal/of: Remove old OF code
The following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: f59ac19b7f44cab23df84810e2da5f57bdd3a7e7 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//f59ac19b7f44cab23df84810e2da5f57bdd3a7e7 Author: Daniel Lezcano <[email protected]> AuthorDate: Fri, 05 Aug 2022 00:43:49 +02:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Wed, 17 Aug 2022 14:09:39 +02:00
thermal/of: Remove old OF code
All the drivers are converted to the new OF API, remove the old OF code.
--- drivers/thermal/thermal_core.h | 2 +- drivers/thermal/thermal_of.c | 810 +-------------------------------- include/linux/thermal.h | 77 +--- 3 files changed, 16 insertions(+), 873 deletions(-)
drivers/thermal/thermal_core.h +0 -2
@@ -135,13 +135,11 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,/* device tree support */ #ifdef CONFIG_THERMAL_OF -int of_parse_thermal_zones (void );int of_thermal_get_ntrips (struct thermal_zone_device *);bool of_thermal_is_trip_valid (struct thermal_zone_device *,int );const struct thermal_trip *of_thermal_get_trip_points (struct thermal_zone_device *);#else -static inline int of_parse_thermal_zones (void ) {return 0 ; }static inline int of_thermal_get_ntrips (struct thermal_zone_device *tz) {return 0 ;
drivers/thermal/thermal_of.c +1 -809
852 lines not on this page · raw message
include/linux/thermal.h +15 -62
109 lines not on this page · raw message
Hi,
Quoted 13 lines
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
Quoted 7 lines
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
I haven't looked closely yet, but this series is breaking two of my boards.
There seems to be one mistake within the new thermal code:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2 [ 2.048010] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 2.054128] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 2.060607] devm_thermal_of_zone_release:707 res=ffff002002377180 [ 2.067044] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 2.075003] Mem abort info: [ 2.077805] ESR = 0x0000000096000004 [ 2.081562] EC = 0x25: DABT (current EL), IL = 32 bits [ 2.086893] SET = 0, FnV = 0 [ 2.089955] EA = 0, S1PTW = 0 [ 2.093100] FSC = 0x04: level 0 translation fault [ 2.097993] Data abort info: [ 2.100876] ISV = 0, ISS = 0x00000004 [ 2.104724] CM = 0, WnR = 0 [ 2.107698] [01adadadadadad88] address between user and kernel address ranges [ 2.114863] Internal error: Oops: 96000004 [#1] SMP [ 2.119754] Modules linked in: [ 2.122815] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00078-ga957a15f74fc-dirty #1694 [ 2.132504] Hardware name: Kontron KBox A-230-LS (DT) [ 2.137568] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.144554] pc : kfree+0x5c/0x3c0 [ 2.147885] lr : thermal_of_zone_unregister+0x34/0x54 [ 2.152954] sp : ffff80000a22bab0 [ 2.156274] x29: ffff80000a22bab0 x28: 0000000000000000 x27: ffff800009960464 [ 2.163438] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.170601] x23: ffff800009ab9008 x22: ffff800008d0d684 x21: 01adadadadadad80 [ 2.177763] x20: 6b6b6b6b6b6b6b6b x19: ffff002002335000 x18: 00000000fffffffb [ 2.184925] x17: ffff800008d0d67c x16: ffff800008d072b4 x15: ffff800008d0c6c4 [ 2.192087] x14: ffff800008d0c34c x13: ffff8000088d5034 x12: ffff8000088d46d4 [ 2.199248] x11: ffff8000088d4624 x10: 0000000000000000 x9 : ffff800008d0d684 [ 2.206410] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.213572] x5 : ffff80000a22b940 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.220733] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.227895] Call trace: [ 2.230342] kfree+0x5c/0x3c0 [ 2.233318] thermal_of_zone_unregister+0x34/0x54 [ 2.238036] devm_thermal_of_zone_release+0x44/0x54 [ 2.242931] release_nodes+0x64/0xd0 [ 2.246516] devres_release_all+0xbc/0x350 [ 2.250623] device_unbind_cleanup+0x20/0x70 [ 2.254905] really_probe+0x1a0/0x2e4 [ 2.258577] __driver_probe_device+0x80/0xec [ 2.262859] driver_probe_device+0x44/0x130 [ 2.267055] __driver_attach+0x104/0x1b4 [ 2.270989] bus_for_each_dev+0x7c/0xe0 [ 2.274834] driver_attach+0x30/0x40 [ 2.278418] bus_add_driver+0x160/0x210 [ 2.281900] hub 1-1:1.0: USB hub found [ 2.282264] driver_register+0x84/0x140 [ 2.286109] hub 1-1:1.0: 7 ports detected [ 2.289859] __platform_driver_register+0x34/0x40 [ 2.289867] qoriq_tmu_init+0x28/0x34 [ 2.302258] do_one_initcall+0x50/0x250 [ 2.306104] kernel_init_freeable+0x278/0x31c [ 2.310474] kernel_init+0x30/0x140 [ 2.313972] ret_from_fork+0x10/0x20 [ 2.317559] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.323672] ---[ end trace 0000000000000000 ]--- [ 2.328317] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.335999] SMP: stopping secondary CPUs [ 2.339932] Kernel Offset: disabled [ 2.343425] CPU features: 0x2000,0800f021,00001086 [ 2.348229] Memory Limit: none [ 2.351289] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
This was seen a sl28 board (arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
On my second board (arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:
[ 6.292819] thermal_sys: Unable to find thermal zones description [ 6.298872] thermal_sys: Failed to find thermal zone for hwmon id=0 [ 6.305375] lan966x-hwmon e2010180.hwmon: error -EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22
Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
Let me know if I can help testing changes.
-michael
Hi Michael,
Quoted 99 lines · Michael Walle
Hi,
Quoted 13 lines
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
Quoted 7 lines
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
I haven't looked closely yet, but this series is breaking two of my boards.
There seems to be one mistake within the new thermal code:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2 [ 2.048010] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 2.054128] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 2.060607] devm_thermal_of_zone_release:707 res=ffff002002377180 [ 2.067044] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 2.075003] Mem abort info: [ 2.077805] ESR = 0x0000000096000004 [ 2.081562] EC = 0x25: DABT (current EL), IL = 32 bits [ 2.086893] SET = 0, FnV = 0 [ 2.089955] EA = 0, S1PTW = 0 [ 2.093100] FSC = 0x04: level 0 translation fault [ 2.097993] Data abort info: [ 2.100876] ISV = 0, ISS = 0x00000004 [ 2.104724] CM = 0, WnR = 0 [ 2.107698] [01adadadadadad88] address between user and kernel address ranges [ 2.114863] Internal error: Oops: 96000004 [#1] SMP [ 2.119754] Modules linked in: [ 2.122815] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00078-ga957a15f74fc-dirty #1694 [ 2.132504] Hardware name: Kontron KBox A-230-LS (DT) [ 2.137568] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.144554] pc : kfree+0x5c/0x3c0 [ 2.147885] lr : thermal_of_zone_unregister+0x34/0x54 [ 2.152954] sp : ffff80000a22bab0 [ 2.156274] x29: ffff80000a22bab0 x28: 0000000000000000 x27: ffff800009960464 [ 2.163438] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.170601] x23: ffff800009ab9008 x22: ffff800008d0d684 x21: 01adadadadadad80 [ 2.177763] x20: 6b6b6b6b6b6b6b6b x19: ffff002002335000 x18: 00000000fffffffb [ 2.184925] x17: ffff800008d0d67c x16: ffff800008d072b4 x15: ffff800008d0c6c4 [ 2.192087] x14: ffff800008d0c34c x13: ffff8000088d5034 x12: ffff8000088d46d4 [ 2.199248] x11: ffff8000088d4624 x10: 0000000000000000 x9 : ffff800008d0d684 [ 2.206410] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.213572] x5 : ffff80000a22b940 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.220733] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.227895] Call trace: [ 2.230342] kfree+0x5c/0x3c0 [ 2.233318] thermal_of_zone_unregister+0x34/0x54 [ 2.238036] devm_thermal_of_zone_release+0x44/0x54 [ 2.242931] release_nodes+0x64/0xd0 [ 2.246516] devres_release_all+0xbc/0x350 [ 2.250623] device_unbind_cleanup+0x20/0x70 [ 2.254905] really_probe+0x1a0/0x2e4 [ 2.258577] __driver_probe_device+0x80/0xec [ 2.262859] driver_probe_device+0x44/0x130 [ 2.267055] __driver_attach+0x104/0x1b4 [ 2.270989] bus_for_each_dev+0x7c/0xe0 [ 2.274834] driver_attach+0x30/0x40 [ 2.278418] bus_add_driver+0x160/0x210 [ 2.281900] hub 1-1:1.0: USB hub found [ 2.282264] driver_register+0x84/0x140 [ 2.286109] hub 1-1:1.0: 7 ports detected [ 2.289859] __platform_driver_register+0x34/0x40 [ 2.289867] qoriq_tmu_init+0x28/0x34 [ 2.302258] do_one_initcall+0x50/0x250 [ 2.306104] kernel_init_freeable+0x278/0x31c [ 2.310474] kernel_init+0x30/0x140 [ 2.313972] ret_from_fork+0x10/0x20 [ 2.317559] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.323672] ---[ end trace 0000000000000000 ]--- [ 2.328317] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.335999] SMP: stopping secondary CPUs [ 2.339932] Kernel Offset: disabled [ 2.343425] CPU features: 0x2000,0800f021,00001086 [ 2.348229] Memory Limit: none [ 2.351289] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---This was seen a sl28 board (
arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Thanks for reporting, I'll investigate the issues you are reporting.
There is no need to update any device tree file. The code does not change the bindings, it is a rewrite of the implementation supposed to be without impact on the existing bindings, thus the existing device tree descriptions.
Why are you saying there are missing trip points ? The dts shows trip points for 'core-cluster' and 'ddr-controller' ?
Quoted 8 lines
On my second board (
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:[ 6.292819] thermal_sys: Unable to find thermal zones description [ 6.298872] thermal_sys: Failed to find thermal zone for hwmon id=0 [ 6.305375] lan966x-hwmon e2010180.hwmon: error -EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22
Interesting ...
Quoted 6 lines
Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
Let me know if I can help testing changes.
Yes, definitively, thanks for proposing
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Hi Daniel,
Am 2022-08-08 12:21, schrieb Daniel Lezcano:
Quoted 106 lines · Michael Walle
Quoted 98 lines
Quoted 13 lines
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
Quoted 7 lines
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
I haven't looked closely yet, but this series is breaking two of my boards.
There seems to be one mistake within the new thermal code:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2 [ 2.048010] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 2.054128] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 2.060607] devm_thermal_of_zone_release:707 res=ffff002002377180 [ 2.067044] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 2.075003] Mem abort info: [ 2.077805] ESR = 0x0000000096000004 [ 2.081562] EC = 0x25: DABT (current EL), IL = 32 bits [ 2.086893] SET = 0, FnV = 0 [ 2.089955] EA = 0, S1PTW = 0 [ 2.093100] FSC = 0x04: level 0 translation fault [ 2.097993] Data abort info: [ 2.100876] ISV = 0, ISS = 0x00000004 [ 2.104724] CM = 0, WnR = 0 [ 2.107698] [01adadadadadad88] address between user and kernel address ranges [ 2.114863] Internal error: Oops: 96000004 [#1] SMP [ 2.119754] Modules linked in: [ 2.122815] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00078-ga957a15f74fc-dirty #1694 [ 2.132504] Hardware name: Kontron KBox A-230-LS (DT) [ 2.137568] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.144554] pc : kfree+0x5c/0x3c0 [ 2.147885] lr : thermal_of_zone_unregister+0x34/0x54 [ 2.152954] sp : ffff80000a22bab0 [ 2.156274] x29: ffff80000a22bab0 x28: 0000000000000000 x27: ffff800009960464 [ 2.163438] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.170601] x23: ffff800009ab9008 x22: ffff800008d0d684 x21: 01adadadadadad80 [ 2.177763] x20: 6b6b6b6b6b6b6b6b x19: ffff002002335000 x18: 00000000fffffffb [ 2.184925] x17: ffff800008d0d67c x16: ffff800008d072b4 x15: ffff800008d0c6c4 [ 2.192087] x14: ffff800008d0c34c x13: ffff8000088d5034 x12: ffff8000088d46d4 [ 2.199248] x11: ffff8000088d4624 x10: 0000000000000000 x9 : ffff800008d0d684 [ 2.206410] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.213572] x5 : ffff80000a22b940 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.220733] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.227895] Call trace: [ 2.230342] kfree+0x5c/0x3c0 [ 2.233318] thermal_of_zone_unregister+0x34/0x54 [ 2.238036] devm_thermal_of_zone_release+0x44/0x54 [ 2.242931] release_nodes+0x64/0xd0 [ 2.246516] devres_release_all+0xbc/0x350 [ 2.250623] device_unbind_cleanup+0x20/0x70 [ 2.254905] really_probe+0x1a0/0x2e4 [ 2.258577] __driver_probe_device+0x80/0xec [ 2.262859] driver_probe_device+0x44/0x130 [ 2.267055] __driver_attach+0x104/0x1b4 [ 2.270989] bus_for_each_dev+0x7c/0xe0 [ 2.274834] driver_attach+0x30/0x40 [ 2.278418] bus_add_driver+0x160/0x210 [ 2.281900] hub 1-1:1.0: USB hub found [ 2.282264] driver_register+0x84/0x140 [ 2.286109] hub 1-1:1.0: 7 ports detected [ 2.289859] __platform_driver_register+0x34/0x40 [ 2.289867] qoriq_tmu_init+0x28/0x34 [ 2.302258] do_one_initcall+0x50/0x250 [ 2.306104] kernel_init_freeable+0x278/0x31c [ 2.310474] kernel_init+0x30/0x140 [ 2.313972] ret_from_fork+0x10/0x20 [ 2.317559] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.323672] ---[ end trace 0000000000000000 ]--- [ 2.328317] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.335999] SMP: stopping secondary CPUs [ 2.339932] Kernel Offset: disabled [ 2.343425] CPU features: 0x2000,0800f021,00001086 [ 2.348229] Memory Limit: none [ 2.351289] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---This was seen a sl28 board (
arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Thanks for reporting, I'll investigate the issues you are reporting.
Quoted 7 lines
There is no need to update any device tree file. The code does not change the bindings, it is a rewrite of the implementation supposed to be without impact on the existing bindings, thus the existing device tree descriptions.
Why are you saying there are missing trip points ? The dts shows trip points for 'core-cluster' and 'ddr-controller' ?
You are right. I've just looked at the error message:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2
So maybe the code just don't find em.
-michael
Quoted 1 line · Michael Walle
Hi Daniel,
[ ... ]
Quoted 1 line
Quoted 1 line
Quoted 1 line
There seems to be one mistake within the new thermal code:
[ ... ]
Quoted 20 lines
Quoted 12 lines
Quoted 9 lines
This was seen a sl28 board (
arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Thanks for reporting, I'll investigate the issues you are reporting.
Quoted 7 lines
There is no need to update any device tree file. The code does not change the bindings, it is a rewrite of the implementation supposed to be without impact on the existing bindings, thus the existing device tree descriptions.
Why are you saying there are missing trip points ? The dts shows trip points for 'core-cluster' and 'ddr-controller' ?
Quoted 7 lines
You are right. I've just looked at the error message:
[ 2.030452]
thermal_sys: Failed to find 'trips' node
[ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434]thermal_sys: Failed to find trip points for tmu id=2So maybe the code just don't find em.
For the board it seems there is no definition for tmu with id 2
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Guenter Roeck
maintainerQuoted 100 lines · Michael Walle
Hi,
Quoted 13 lines
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
Quoted 7 lines
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
I haven't looked closely yet, but this series is breaking two of my boards.
There seems to be one mistake within the new thermal code:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2 [ 2.048010] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 2.054128] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 2.060607] devm_thermal_of_zone_release:707 res=ffff002002377180 [ 2.067044] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 2.075003] Mem abort info: [ 2.077805] ESR = 0x0000000096000004 [ 2.081562] EC = 0x25: DABT (current EL), IL = 32 bits [ 2.086893] SET = 0, FnV = 0 [ 2.089955] EA = 0, S1PTW = 0 [ 2.093100] FSC = 0x04: level 0 translation fault [ 2.097993] Data abort info: [ 2.100876] ISV = 0, ISS = 0x00000004 [ 2.104724] CM = 0, WnR = 0 [ 2.107698] [01adadadadadad88] address between user and kernel address ranges [ 2.114863] Internal error: Oops: 96000004 [#1] SMP [ 2.119754] Modules linked in: [ 2.122815] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00078-ga957a15f74fc-dirty #1694 [ 2.132504] Hardware name: Kontron KBox A-230-LS (DT) [ 2.137568] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.144554] pc : kfree+0x5c/0x3c0 [ 2.147885] lr : thermal_of_zone_unregister+0x34/0x54 [ 2.152954] sp : ffff80000a22bab0 [ 2.156274] x29: ffff80000a22bab0 x28: 0000000000000000 x27: ffff800009960464 [ 2.163438] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.170601] x23: ffff800009ab9008 x22: ffff800008d0d684 x21: 01adadadadadad80 [ 2.177763] x20: 6b6b6b6b6b6b6b6b x19: ffff002002335000 x18: 00000000fffffffb [ 2.184925] x17: ffff800008d0d67c x16: ffff800008d072b4 x15: ffff800008d0c6c4 [ 2.192087] x14: ffff800008d0c34c x13: ffff8000088d5034 x12: ffff8000088d46d4 [ 2.199248] x11: ffff8000088d4624 x10: 0000000000000000 x9 : ffff800008d0d684 [ 2.206410] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.213572] x5 : ffff80000a22b940 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.220733] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.227895] Call trace: [ 2.230342] kfree+0x5c/0x3c0 [ 2.233318] thermal_of_zone_unregister+0x34/0x54 [ 2.238036] devm_thermal_of_zone_release+0x44/0x54 [ 2.242931] release_nodes+0x64/0xd0 [ 2.246516] devres_release_all+0xbc/0x350 [ 2.250623] device_unbind_cleanup+0x20/0x70 [ 2.254905] really_probe+0x1a0/0x2e4 [ 2.258577] __driver_probe_device+0x80/0xec [ 2.262859] driver_probe_device+0x44/0x130 [ 2.267055] __driver_attach+0x104/0x1b4 [ 2.270989] bus_for_each_dev+0x7c/0xe0 [ 2.274834] driver_attach+0x30/0x40 [ 2.278418] bus_add_driver+0x160/0x210 [ 2.281900] hub 1-1:1.0: USB hub found [ 2.282264] driver_register+0x84/0x140 [ 2.286109] hub 1-1:1.0: 7 ports detected [ 2.289859] __platform_driver_register+0x34/0x40 [ 2.289867] qoriq_tmu_init+0x28/0x34 [ 2.302258] do_one_initcall+0x50/0x250 [ 2.306104] kernel_init_freeable+0x278/0x31c [ 2.310474] kernel_init+0x30/0x140 [ 2.313972] ret_from_fork+0x10/0x20 [ 2.317559] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.323672] ---[ end trace 0000000000000000 ]--- [ 2.328317] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.335999] SMP: stopping secondary CPUs [ 2.339932] Kernel Offset: disabled [ 2.343425] CPU features: 0x2000,0800f021,00001086 [ 2.348229] Memory Limit: none [ 2.351289] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---This was seen a sl28 board (
arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists. This would make the whole concept of having the hwmon core register thermal zone sensors impossible. I have no idea how this is expected to work now, but there is an apparent flaw in the logic. That means I withdraw my
Acked-by: for the hwmon patches in this series until it is guaranteed that hwmon registration does not fail as above if there is no thermal zone associated with a sensor.
Quoted 5 lines
On my second board (
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:
Quoted 9 lines
[ 6.292819] thermal_sys: Unable to find thermal zones description [ 6.298872] thermal_sys: Failed to find thermal zone for hwmon id=0 [ 6.305375] lan966x-hwmon e2010180.hwmon: error -EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
That would work for this board, but not for all other boards where a sensor tries to register with the thermal subsystem but there is no thermal zone defined for it.
Guenter
Hi Guenter,
On 08/08/2022 12:26, Guenter Roeck wrote:
[ ... ]
Quoted 7 lines
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists.
Probably missing something but if the thermal zone is not described, the hwmon driver won't initialize. And except if I'm wrong, that was already the case before these changes, no?
Quoted 3 lines
This
would make the whole concept of having the hwmon core register thermal zone sensors impossible.
No, only the way the thermal OF is implemented changed. No functional changes. So AFAICT, you can still create thermal zones with the hwmon.
Quoted 5 lines
I have no idea how this is expected to work now,
but there is an apparent flaw in the logic. That means I withdraw my
Acked-by: for the hwmon patches in this series until it is guaranteed that hwmon registration does not fail as above if there is no thermal zone associated with a sensor.
If the thermal zone creation fails with -ENODEV, then it is no considered as an error when creating the hwmon [1]
The function [devm]_thermal_zone_of_sensor_register() checks if there is a thermal zone description, if not it bails out with -ENODEV [2]
Otherwise it checks all the thermal zones if the device passed as parameter matches a sensor in the thermal zone [3][4]
If there is no match, then it returns -ENODEV which is the default error code [5]
My understanding is there is no thermal zone creation if there is no description in the device tree for such a device in the thermal zone.
The issue we had here was the confusing error message when -ENODEV (before was -EINVAL) is returning while before the code was silently continuing without creating the thermal zone.
We are talking here about what is in under CONFIG_THERMAL_OF in the hwmon code path. The rest is untouched.
Am I missing something?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Guenter Roeck
maintainerQuoted 11 lines · Daniel Lezcano
Hi Guenter,
On 08/08/2022 12:26, Guenter Roeck wrote:
[ ... ]
Quoted 5 lines
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Quoted 5 lines
Quoted 2 lines
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists.
Probably missing something but if the thermal zone is not described, the hwmon driver won't initialize. And except if I'm wrong, that was already the case before these changes, no?
In the hwmon source (you point to it below):
if (IS_ERR(tzd)) {
if (PTR_ERR(tzd) != -ENODEV)
return PTR_ERR(tzd);
dev_info(dev, "temp%d_input not attached to any thermal zone\n",
index + 1);
devm_kfree(dev, tdata);
return 0;
}That contradicts "if the thermal zone is not described, the hwmon driver won't initialize". Now I must be missing something, since you mention that yourself below, and your new patch series fixes the problem, at least AFAICS. Confused.
Guenter
Quoted 40 lines
Quoted 3 lines
This
would make the whole concept of having the hwmon core register thermal zone sensors impossible.No, only the way the thermal OF is implemented changed. No functional changes. So AFAICT, you can still create thermal zones with the hwmon.
Quoted 5 lines
I have no idea how this is expected to work now,
but there is an apparent flaw in the logic. That means I withdraw my
Acked-by: for the hwmon patches in this series until it is guaranteed that hwmon registration does not fail as above if there is no thermal zone associated with a sensor.If the thermal zone creation fails with
-ENODEV, then it is no considered as an error when creating the hwmon [1]The function [devm]_thermal_zone_of_sensor_register() checks if there is a thermal zone description, if not it bails out with
-ENODEV[2]Otherwise it checks all the thermal zones if the device passed as parameter matches a sensor in the thermal zone [3][4]
If there is no match, then it returns
-ENODEVwhich is the default error code [5]My understanding is there is no thermal zone creation if there is no description in the device tree for such a device in the thermal zone.
The issue we had here was the confusing error message when
-ENODEV(before was-EINVAL) is returning while before the code was silently continuing without creating the thermal zone.We are talking here about what is in under
CONFIG_THERMAL_OFin the hwmon code path. The rest is untouched.Am I missing something?
Quoted 30 lines · Guenter Roeck
Quoted 11 lines · Daniel Lezcano
Hi Guenter,
On 08/08/2022 12:26, Guenter Roeck wrote:
[ ... ]
Quoted 5 lines
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Quoted 5 lines
Quoted 2 lines
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists.
Probably missing something but if the thermal zone is not described, the hwmon driver won't initialize. And except if I'm wrong, that was already the case before these changes, no?
In the hwmon source (you point to it below):
if (
IS_ERR(tzd)) {
if (PTR_ERR(tzd)!=-ENODEV)
returnPTR_ERR(tzd);
dev_info(dev, "temp%d_input not attached to any thermal
zone\n",
index + 1);
devm_kfree(dev, tdata);
return 0;
}
Quoted 3 lines
That contradicts "if the thermal zone is not described, the hwmon driver won't initialize". Now I must be missing something, since you mention that yourself below, and your new patch series fixes the problem, at least AFAICS. Confused.
Sorry for not being clear. Let me try to explain it differently.
The function hwmon_thermal_add_sensor() is calling:
Without "[PATCH v5 00/33] New thermal OF code":
-----------------------------------------------
devm_thermal_zone_of_sensor_register(dev, index, ...);
If there is no thermal zone description or the 'dev' does not belong to any thermal zone then -ENODEV is returned -> OK and the hwmon thermal zone is _not_ created
With "[PATCH v5 00/33] New thermal OF code":
--------------------------------------------
devm_thermal_of_zone_register(dev, index, ...);
If there is no thermal zone description or the 'dev' does not belong to any thermal zone then *-EINVAL* is returned -> NOK, error message, and hwmon thermal zone is _not_ created
With "[PATCH v5 00/33] New thermal OF code" + fixes:
----------------------------------------------------
devm_thermal_of_zone_register(dev, index, ...);
If there is no thermal zone description or the 'dev' does not belong to any thermal zone then *-ENODEV* is returned -> OK and the hwmon thermal zone is _not_ created
Quoting your initial message:
"It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists. This would make the whole concept of having the hwmon core register thermal zone sensors impossible [...]"
The thermal zone must be described if the OF registering function variant is used. Except I'm wrong that was already the case before the changes.
Otherwise, nothing prevents a hwmon to register itself with the core code, that will create the thermal zone.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Hi Guenter,
Quoted 1 line · Guenter Roeck
On Mon, Aug 08, 2022 at 11:42:16AM +0200, Michael Walle wrote:
[ ... ]
Quoted 8 lines
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists. This would make the whole concept of having the hwmon core register thermal zone sensors impossible. I have no idea how this is expected to work now, but there is an apparent flaw in the logic. That means I withdraw my
Acked-by: for the hwmon patches in this series until it is guaranteed that hwmon registration does not fail as above if there is no thermal zone associated with a sensor.
I tried to figure out where we are not in sync and I suspect there is a misunderstanding from my side of your initial statement.
I understood you meant the thermal zone can not be created with the hwmon if there is no thermal zone description and that was the case before.
But actually, I suspect I misunderstood and you meant if the thermal OF registration fails, the hwmon creation fails for the hwmon subsystem, and before the changes it was created anyway.
Is that correct ?
If yes, the change -EINVAL --> -ENODEV fixes the issue, shall I consider in this case your Acked-by ?
Thanks
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Guenter Roeck
maintainerQuoted 17 lines · Daniel Lezcano
Hi Guenter,
Quoted 1 line · Guenter Roeck
On Mon, Aug 08, 2022 at 11:42:16AM +0200, Michael Walle wrote:
[ ... ]
Quoted 8 lines
It would also mean that all hwmon drivers registering a thermal zone sensor would fail to register unless such a thermal zone actually exists. This would make the whole concept of having the hwmon core register thermal zone sensors impossible. I have no idea how this is expected to work now, but there is an apparent flaw in the logic. That means I withdraw my
Acked-by: for the hwmon patches in this series until it is guaranteed that hwmon registration does not fail as above if there is no thermal zone associated with a sensor.
Quoted 8 lines
I tried to figure out where we are not in sync and I suspect there is a misunderstanding from my side of your initial statement.
I understood you meant the thermal zone can not be created with the hwmon if there is no thermal zone description and that was the case before.
But actually, I suspect I misunderstood and you meant if the thermal OF registration fails, the hwmon creation fails for the hwmon subsystem, and before the changes it was created anyway.
Is that correct ?
Yes, that is what I meant.
Quoted 2 lines
If yes, the change
-EINVAL-->-ENODEVfixes the issue, shall I consider in this case your Acked-by ?
Yes.
Thanks,
Guenter
Quoted 3 lines
Thanks
-- Daniel
Quoted 100 lines · Michael Walle
Hi,
Quoted 13 lines
The following changes are depending on:
which are present in the thermal/linux-next branch:
https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/log/?h=thermal/linux-next
The series introduces a new thermal OF code. The patch description gives a detailed explanation of the changes. Basically we write new OF parsing functions, we migrate all the users of the old thermal OF API to the new one and then we finish by removing the old OF code.
Quoted 7 lines
That is the second step to rework the thermal OF code. More patches will come after that to remove the duplication of the trip definitions in the different drivers which will result in more code duplication removed and consolidation of the core thermal framework.
Thanks for those who tested the series on their platform and investigated the regression with the disabled by default thermal zones.
I haven't looked closely yet, but this series is breaking two of my boards.
There seems to be one mistake within the new thermal code:
[ 2.030452] thermal_sys: Failed to find 'trips' node [ 2.033664] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.035434] thermal_sys: Failed to find trip points for tmu id=2 [ 2.048010] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 2.054128] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 2.060607] devm_thermal_of_zone_release:707 res=ffff002002377180 [ 2.067044] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 2.075003] Mem abort info: [ 2.077805] ESR = 0x0000000096000004 [ 2.081562] EC = 0x25: DABT (current EL), IL = 32 bits [ 2.086893] SET = 0, FnV = 0 [ 2.089955] EA = 0, S1PTW = 0 [ 2.093100] FSC = 0x04: level 0 translation fault [ 2.097993] Data abort info: [ 2.100876] ISV = 0, ISS = 0x00000004 [ 2.104724] CM = 0, WnR = 0 [ 2.107698] [01adadadadadad88] address between user and kernel address ranges [ 2.114863] Internal error: Oops: 96000004 [#1] SMP [ 2.119754] Modules linked in: [ 2.122815] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00078-ga957a15f74fc-dirty #1694 [ 2.132504] Hardware name: Kontron KBox A-230-LS (DT) [ 2.137568] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.144554] pc : kfree+0x5c/0x3c0 [ 2.147885] lr : thermal_of_zone_unregister+0x34/0x54 [ 2.152954] sp : ffff80000a22bab0 [ 2.156274] x29: ffff80000a22bab0 x28: 0000000000000000 x27: ffff800009960464 [ 2.163438] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.170601] x23: ffff800009ab9008 x22: ffff800008d0d684 x21: 01adadadadadad80 [ 2.177763] x20: 6b6b6b6b6b6b6b6b x19: ffff002002335000 x18: 00000000fffffffb [ 2.184925] x17: ffff800008d0d67c x16: ffff800008d072b4 x15: ffff800008d0c6c4 [ 2.192087] x14: ffff800008d0c34c x13: ffff8000088d5034 x12: ffff8000088d46d4 [ 2.199248] x11: ffff8000088d4624 x10: 0000000000000000 x9 : ffff800008d0d684 [ 2.206410] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.213572] x5 : ffff80000a22b940 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.220733] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.227895] Call trace: [ 2.230342] kfree+0x5c/0x3c0 [ 2.233318] thermal_of_zone_unregister+0x34/0x54 [ 2.238036] devm_thermal_of_zone_release+0x44/0x54 [ 2.242931] release_nodes+0x64/0xd0 [ 2.246516] devres_release_all+0xbc/0x350 [ 2.250623] device_unbind_cleanup+0x20/0x70 [ 2.254905] really_probe+0x1a0/0x2e4 [ 2.258577] __driver_probe_device+0x80/0xec [ 2.262859] driver_probe_device+0x44/0x130 [ 2.267055] __driver_attach+0x104/0x1b4 [ 2.270989] bus_for_each_dev+0x7c/0xe0 [ 2.274834] driver_attach+0x30/0x40 [ 2.278418] bus_add_driver+0x160/0x210 [ 2.281900] hub 1-1:1.0: USB hub found [ 2.282264] driver_register+0x84/0x140 [ 2.286109] hub 1-1:1.0: 7 ports detected [ 2.289859] __platform_driver_register+0x34/0x40 [ 2.289867] qoriq_tmu_init+0x28/0x34 [ 2.302258] do_one_initcall+0x50/0x250 [ 2.306104] kernel_init_freeable+0x278/0x31c [ 2.310474] kernel_init+0x30/0x140 [ 2.313972] ret_from_fork+0x10/0x20 [ 2.317559] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.323672] ---[ end trace 0000000000000000 ]--- [ 2.328317] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.335999] SMP: stopping secondary CPUs [ 2.339932] Kernel Offset: disabled [ 2.343425] CPU features: 0x2000,0800f021,00001086 [ 2.348229] Memory Limit: none [ 2.351289] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---This was seen a sl28 board (
arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-kbox-a-230-ls.dts). The same board in the KernelCI also have some more information:
https://lavalab.kontron.com/scheduler/job/151900#L1162
Quoted 4 lines
But I guess even if that is fixed, the driver will not probe due to the missing trip points? Are they now mandatory? Does it mean we'd need to update our device trees? But that will then mean older devices trees don't work anymore.
Does this fix solves this first issue ?
https://lore.kernel.org/all/YvDzovkMCQecPDjz@kili/
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Hi Daniel,
Am 2022-08-08 15:09, schrieb Daniel Lezcano:
Quoted 3 lines
Does this fix solves this first issue ?
Unfortunately not, it is still the same:
[ 1.915140] thermal_sys: Failed to find thermal zone for tmu id=2 [ 1.921279] qoriq_thermal 1f80000.tmu: Failed to register sensors [ 1.927395] qoriq_thermal: probe of 1f80000.tmu failed with error -22 [ 1.934189] Unable to handle kernel paging request at virtual address 01adadadadadad88 [ 1.942146] Mem abort info: [ 1.944948] ESR = 0x0000000096000004 [ 1.948708] EC = 0x25: DABT (current EL), IL = 32 bits [ 1.954042] SET = 0, FnV = 0 [ 1.957107] EA = 0, S1PTW = 0 [ 1.960253] FSC = 0x04: level 0 translation fault [ 1.965147] Data abort info: [ 1.968030] ISV = 0, ISS = 0x00000004 [ 1.971878] CM = 0, WnR = 0 [ 1.974852] [01adadadadadad88] address between user and kernel address ranges [ 1.982016] Internal error: Oops: 96000004 [#1] SMP [ 1.986907] Modules linked in: [ 1.989969] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00080-g1c46f44502e0 #1697 [ 1.999135] Hardware name: Kontron KBox A-230-LS (DT) [ 2.004199] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.011185] pc : kfree+0x5c/0x3c0 [ 2.014516] lr : devm_thermal_of_zone_release+0x38/0x60 [ 2.019761] sp : ffff80000a22bad0 [ 2.023081] x29: ffff80000a22bad0 x28: 0000000000000000 x27: ffff800009960464 [ 2.030245] x26: ffff800009a16960 x25: 0000000000000006 x24: ffff800009f09a40 [ 2.037407] x23: ffff800009ab9008 x22: ffff800008d0eea8 x21: 01adadadadadad80 [ 2.044569] x20: 6b6b6b6b6b6b6b6b x19: ffff00200232b800 x18: 00000000fffffffb [ 2.051731] x17: ffff800008d0eea0 x16: ffff800008d07d44 x15: ffff800008d0d154 [ 2.056647] usb 1-1: new high-speed USB device number 2 using xhci-hcd [ 2.058893] x14: ffff800008d0cddc x13: ffff8000088d1c2c x12: ffff8000088d5034 [ 2.072597] x11: ffff8000088d46d4 x10: 0000000000000000 x9 : ffff800008d0eea8 [ 2.079759] x8 : ffff002000b1a158 x7 : bbbbbbbbbbbbbbbb x6 : ffff80000a0f53b8 [ 2.086921] x5 : ffff80000a22b960 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.094082] x2 : fffffc0000000000 x1 : ffff002000838040 x0 : 01adb1adadadad80 [ 2.101244] Call trace: [ 2.103692] kfree+0x5c/0x3c0 [ 2.106666] devm_thermal_of_zone_release+0x38/0x60 [ 2.111561] release_nodes+0x64/0xd0 [ 2.115146] devres_release_all+0xbc/0x350 [ 2.119253] device_unbind_cleanup+0x20/0x70 [ 2.123536] really_probe+0x1a0/0x2e4 [ 2.127208] __driver_probe_device+0x80/0xec [ 2.131490] driver_probe_device+0x44/0x130 [ 2.135685] __driver_attach+0x104/0x1b4 [ 2.139619] bus_for_each_dev+0x7c/0xe0 [ 2.143465] driver_attach+0x30/0x40 [ 2.147048] bus_add_driver+0x160/0x210 [ 2.150894] driver_register+0x84/0x140 [ 2.154741] __platform_driver_register+0x34/0x40 [ 2.159461] qoriq_tmu_init+0x28/0x34 [ 2.163133] do_one_initcall+0x50/0x250 [ 2.166979] kernel_init_freeable+0x278/0x31c [ 2.171349] kernel_init+0x30/0x140 [ 2.174847] ret_from_fork+0x10/0x20 [ 2.178433] Code: b25657e2 d34cfc00 d37ae400 8b020015 (f94006a1) [ 2.184546] ---[ end trace 0000000000000000 ]--- [ 2.189188] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.196869] SMP: stopping secondary CPUs [ 2.200803] Kernel Offset: disabled [ 2.204296] CPU features: 0x2000,0800f021,00001086 [ 2.209100] Memory Limit: none [ 2.212158] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
-michael
Quoted 8 lines · Michael Walle
Hi Daniel,
Am 2022-08-08 15:09, schrieb Daniel Lezcano:
Quoted 3 lines
Does this fix solves this first issue ?
Unfortunately not, it is still the same:
Ok, thanks for testing
Quoted 64 lines
[ 1.915140]
thermal_sys: Failed to find thermal zone for tmu id=2
[ 1.921279]qoriq_thermal1f80000.tmu: Failed to register sensors
[ 1.927395]qoriq_thermal: probe of 1f80000.tmu failed with error -22
[ 1.934189] Unable to handle kernel paging request at virtual address01adadadadadad88[ 1.942146] Mem abort info:
[ 1.944948] ESR =0x0000000096000004
[ 1.948708] EC =0x25: DABT (current EL), IL = 32 bits
[ 1.954042] SET = 0, FnV = 0
[ 1.957107] EA = 0, S1PTW = 0
[ 1.960253] FSC =0x04: level 0 translation fault
[ 1.965147] Data abort info:
[ 1.968030] ISV = 0, ISS =0x00000004
[ 1.971878] CM = 0, WnR = 0
[ 1.974852] [01adadadadadad88] address between user and kernel address ranges
[ 1.982016] Internal error: Oops: 96000004 [#1] SMP
[ 1.986907] Modules linked in:
[ 1.989969] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-next-20220808-00080-g1c46f44502e0 #1697 [ 1.999135] Hardware name: Kontron KBox A-230-LS (DT)
[ 2.004199] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 2.011185] pc :kfree+0x5c/0x3c0
[ 2.014516] lr :devm_thermal_of_zone_release+0x38/0x60
[ 2.019761] sp :ffff80000a22bad0
[ 2.023081] x29:ffff80000a22bad0x28: 0000000000000000 x27:ffff800009960464
[ 2.030245] x26:ffff800009a16960x25: 0000000000000006 x24:ffff800009f09a40
[ 2.037407] x23:ffff800009ab9008x22:ffff800008d0eea8x21:01adadadadadad80
[ 2.044569] x20:6b6b6b6b6b6b6b6bx19:ffff00200232b800x18:00000000fffffffb
[ 2.051731] x17:ffff800008d0eea0x16:ffff800008d07d44x15:ffff800008d0d154
[ 2.056647] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[ 2.058893] x14:ffff800008d0cddcx13:ffff8000088d1c2cx12:ffff8000088d5034
[ 2.072597] x11:ffff8000088d46d4x10: 0000000000000000 x9 :ffff800008d0eea8
[ 2.079759] x8 :ffff002000b1a158x7 : bbbbbbbbbbbbbbbb x6 :ffff80000a0f53b8
[ 2.086921] x5 :ffff80000a22b960x4 : 0000000000000000 x3 : 0000000000000000
[ 2.094082] x2 :fffffc0000000000x1 :ffff002000838040x0 :01adb1adadadad80
[ 2.101244] Call trace:
[ 2.103692]kfree+0x5c/0x3c0
[ 2.106666]devm_thermal_of_zone_release+0x38/0x60
[ 2.111561]release_nodes+0x64/0xd0
[ 2.115146]devres_release_all+0xbc/0x350
[ 2.119253]device_unbind_cleanup+0x20/0x70
[ 2.123536]really_probe+0x1a0/0x2e4
[ 2.127208]__driver_probe_device+0x80/0xec
[ 2.131490]driver_probe_device+0x44/0x130
[ 2.135685]__driver_attach+0x104/0x1b4
[ 2.139619]bus_for_each_dev+0x7c/0xe0
[ 2.143465]driver_attach+0x30/0x40
[ 2.147048]bus_add_driver+0x160/0x210
[ 2.150894]driver_register+0x84/0x140
[ 2.154741]__platform_driver_register+0x34/0x40
[ 2.159461]qoriq_tmu_init+0x28/0x34
[ 2.163133]do_one_initcall+0x50/0x250
[ 2.166979]kernel_init_freeable+0x278/0x31c
[ 2.171349]kernel_init+0x30/0x140
[ 2.174847]ret_from_fork+0x10/0x20
[ 2.178433] Code:b25657e2d34cfc00d37ae4008b020015(f94006a1)
[ 2.184546] ---[ end trace 0000000000000000 ]---
[ 2.189188] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 2.196869] SMP: stopping secondary CPUs
[ 2.200803] Kernel Offset: disabled
[ 2.204296] CPU features: 0x2000,0800f021,00001086
[ 2.209100] Memory Limit: none
[ 2.212158] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]----michael
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
On 08/08/2022 11:42, Michael Walle wrote:
[ ... ]
Quoted 4 lines
On my second board (
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:
Quoted 8 lines
[ 6.292819] thermal_sys: Unable to find thermal zones description [ 6.298872] thermal_sys: Failed to find thermal zone for hwmon id=0 [ 6.305375] lan966x-hwmon e2010180.hwmon: error -EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
Logically with the fixes I've send these errors should have gone. Just a pr_info should appear "... not attached to any thermal zone".
If I'm correct, without or with the changes (new thermal OF code + fixes), the hwmon message is the same and the hwmon thermal zone is not created. So no regression hopefully.
Is it possible to check that?
[ ... ]
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Hi Daniel,
Am 2022-08-09 10:23, schrieb Daniel Lezcano:
Quoted 13 lines
Quoted 4 lines
On my second board (
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:Quoted 8 lines
[ 6.292819] thermal_sys: Unable to find thermal zones description [ 6.298872] thermal_sys: Failed to find thermal zone for hwmon id=0 [ 6.305375] lan966x-hwmon e2010180.hwmon: error -EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
Quoted 8 lines
Logically with the fixes I've send these errors should have gone. Just a
pr_infoshould appear "... not attached to any thermal zone".If I'm correct, without or with the changes (new thermal OF code + fixes), the hwmon message is the same and the hwmon thermal zone is not created. So no regression hopefully.
Is it possible to check that?
Yes, I'm no more seeing any error messages and the device is probed successfully. Both on the kswitch board as well as on the sl28 board.
Thanks,
-michael
Hi Michael,
Quoted 22 lines · Michael Walle
Hi Daniel, >
Am 2022-08-09 10:23, schrieb Daniel Lezcano:Quoted 20 lines
Quoted 4 lines
On my second board (
arch/arm/boot/dts/lan966x-kontron-kswitch-d10-mmt-6g-2gs.dts). I get the following error:Quoted 8 lines
[ 6.292819]
thermal_sys: Unable to find thermal zones description
[ 6.298872]thermal_sys: Failed to find thermal zone for hwmon id=0
[ 6.305375] lan966x-hwmon e2010180.hwmon: error-EINVAL: failed to register hwmon device [ 6.313508] lan966x-hwmon: probe of e2010180.hwmon failed with error -22Again, is there seems to be something missing in the device tree. For this board a device tree change should be easily doable, as it is still in development.
Logically with the fixes I've send these errors should have gone. Just a
pr_infoshould appear "... not attached to any thermal zone".If I'm correct, without or with the changes (new thermal OF code + fixes), the hwmon message is the same and the hwmon thermal zone is not created. So no regression hopefully.
Quoted 5 lines
Quoted 1 line
Is it possible to check that?
Yes, I'm no more seeing any error messages and the device is probed successfully. Both on the kswitch board as well as on the sl28 board.
Great! thanks for testing
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog