830-v6.4-12-thermal-hwmon-Use-the-right-device-for-devm_thermal_.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. From cc9c60e9cfeeac45d63361fa8c085c43c4bdfe3a Mon Sep 17 00:00:00 2001
  2. From: Daniel Lezcano <[email protected]>
  3. Date: Wed, 1 Mar 2023 21:14:36 +0100
  4. Subject: [PATCH 08/42] thermal/hwmon: Use the right device for
  5. devm_thermal_add_hwmon_sysfs()
  6. The devres variant of thermal_add_hwmon_sysfs() only takes the thermal
  7. zone structure pointer as parameter.
  8. Actually, it uses the tz->device to add it in the devres list.
  9. It is preferable to use the device registering the thermal zone
  10. instead of the thermal zone device itself. That prevents the driver
  11. accessing the thermal zone structure internals and it is from my POV
  12. more correct regarding how devm_ is used.
  13. [skipped imx thermal which did not apply cleanly and irrelevant on
  14. mediatek target]
  15. Signed-off-by: Daniel Lezcano <[email protected]>
  16. Acked-by: Martin Blumenstingl <[email protected]> #amlogic_thermal
  17. Acked-by: Jernej Skrabec <[email protected]> #sun8i_thermal
  18. Reviewed-by: AngeloGioacchino Del Regno <[email protected]> #MediaTek auxadc
  19. Signed-off-by: Rafael J. Wysocki <[email protected]>
  20. ---
  21. drivers/thermal/amlogic_thermal.c | 2 +-
  22. drivers/thermal/imx_sc_thermal.c | 2 +-
  23. drivers/thermal/k3_bandgap.c | 2 +-
  24. drivers/thermal/mediatek/auxadc_thermal.c | 2 +-
  25. drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
  26. drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 2 +-
  27. drivers/thermal/qcom/tsens.c | 2 +-
  28. drivers/thermal/qoriq_thermal.c | 2 +-
  29. drivers/thermal/sun8i_thermal.c | 2 +-
  30. drivers/thermal/tegra/tegra30-tsensor.c | 2 +-
  31. drivers/thermal/thermal_hwmon.c | 4 ++--
  32. drivers/thermal/thermal_hwmon.h | 4 ++--
  33. drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
  34. 13 files changed, 15 insertions(+), 15 deletions(-)
  35. --- a/drivers/thermal/amlogic_thermal.c
  36. +++ b/drivers/thermal/amlogic_thermal.c
  37. @@ -286,7 +286,7 @@ static int amlogic_thermal_probe(struct
  38. return ret;
  39. }
  40. - if (devm_thermal_add_hwmon_sysfs(pdata->tzd))
  41. + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd))
  42. dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");
  43. ret = amlogic_thermal_initialize(pdata);
  44. --- a/drivers/thermal/imx_sc_thermal.c
  45. +++ b/drivers/thermal/imx_sc_thermal.c
  46. @@ -120,7 +120,7 @@ static int imx_sc_thermal_probe(struct p
  47. return ret;
  48. }
  49. - if (devm_thermal_add_hwmon_sysfs(sensor->tzd))
  50. + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd))
  51. dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
  52. }
  53. --- a/drivers/thermal/k3_bandgap.c
  54. +++ b/drivers/thermal/k3_bandgap.c
  55. @@ -222,7 +222,7 @@ static int k3_bandgap_probe(struct platf
  56. goto err_alloc;
  57. }
  58. - if (devm_thermal_add_hwmon_sysfs(data[id].tzd))
  59. + if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd))
  60. dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
  61. }
  62. --- a/drivers/thermal/mediatek/auxadc_thermal.c
  63. +++ b/drivers/thermal/mediatek/auxadc_thermal.c
  64. @@ -1210,7 +1210,7 @@ static int mtk_thermal_probe(struct plat
  65. goto err_disable_clk_peri_therm;
  66. }
  67. - ret = devm_thermal_add_hwmon_sysfs(tzdev);
  68. + ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
  69. if (ret)
  70. dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
  71. --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
  72. +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
  73. @@ -688,7 +688,7 @@ static int adc_tm5_register_tzd(struct a
  74. return PTR_ERR(tzd);
  75. }
  76. adc_tm->channels[i].tzd = tzd;
  77. - if (devm_thermal_add_hwmon_sysfs(tzd))
  78. + if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd))
  79. dev_warn(adc_tm->dev,
  80. "Failed to add hwmon sysfs attributes\n");
  81. }
  82. --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
  83. +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
  84. @@ -460,7 +460,7 @@ static int qpnp_tm_probe(struct platform
  85. return ret;
  86. }
  87. - if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))
  88. + if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))
  89. dev_warn(&pdev->dev,
  90. "Failed to add hwmon sysfs attributes\n");
  91. --- a/drivers/thermal/qcom/tsens.c
  92. +++ b/drivers/thermal/qcom/tsens.c
  93. @@ -1056,7 +1056,7 @@ static int tsens_register(struct tsens_p
  94. if (priv->ops->enable)
  95. priv->ops->enable(priv, i);
  96. - if (devm_thermal_add_hwmon_sysfs(tzd))
  97. + if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))
  98. dev_warn(priv->dev,
  99. "Failed to add hwmon sysfs attributes\n");
  100. }
  101. --- a/drivers/thermal/qoriq_thermal.c
  102. +++ b/drivers/thermal/qoriq_thermal.c
  103. @@ -158,7 +158,7 @@ static int qoriq_tmu_register_tmu_zone(s
  104. return ret;
  105. }
  106. - if (devm_thermal_add_hwmon_sysfs(tzd))
  107. + if (devm_thermal_add_hwmon_sysfs(dev, tzd))
  108. dev_warn(dev,
  109. "Failed to add hwmon sysfs attributes\n");
  110. --- a/drivers/thermal/sun8i_thermal.c
  111. +++ b/drivers/thermal/sun8i_thermal.c
  112. @@ -468,7 +468,7 @@ static int sun8i_ths_register(struct ths
  113. if (IS_ERR(tmdev->sensor[i].tzd))
  114. return PTR_ERR(tmdev->sensor[i].tzd);
  115. - if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
  116. + if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))
  117. dev_warn(tmdev->dev,
  118. "Failed to add hwmon sysfs attributes\n");
  119. }
  120. --- a/drivers/thermal/tegra/tegra30-tsensor.c
  121. +++ b/drivers/thermal/tegra/tegra30-tsensor.c
  122. @@ -530,7 +530,7 @@ static int tegra_tsensor_register_channe
  123. return 0;
  124. }
  125. - if (devm_thermal_add_hwmon_sysfs(tsc->tzd))
  126. + if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd))
  127. dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n");
  128. return 0;
  129. --- a/drivers/thermal/thermal_hwmon.c
  130. +++ b/drivers/thermal/thermal_hwmon.c
  131. @@ -255,7 +255,7 @@ static void devm_thermal_hwmon_release(s
  132. thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
  133. }
  134. -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
  135. +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
  136. {
  137. struct thermal_zone_device **ptr;
  138. int ret;
  139. @@ -272,7 +272,7 @@ int devm_thermal_add_hwmon_sysfs(struct
  140. }
  141. *ptr = tz;
  142. - devres_add(&tz->device, ptr);
  143. + devres_add(dev, ptr);
  144. return ret;
  145. }
  146. --- a/drivers/thermal/thermal_hwmon.h
  147. +++ b/drivers/thermal/thermal_hwmon.h
  148. @@ -17,7 +17,7 @@
  149. #ifdef CONFIG_THERMAL_HWMON
  150. int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
  151. -int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
  152. +int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz);
  153. void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz);
  154. #else
  155. static inline int
  156. @@ -27,7 +27,7 @@ thermal_add_hwmon_sysfs(struct thermal_z
  157. }
  158. static inline int
  159. -devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
  160. +devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
  161. {
  162. return 0;
  163. }
  164. --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
  165. +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
  166. @@ -182,7 +182,7 @@ int ti_thermal_expose_sensor(struct ti_b
  167. ti_bandgap_set_sensor_data(bgp, id, data);
  168. ti_bandgap_write_update_interval(bgp, data->sensor_id, interval);
  169. - if (devm_thermal_add_hwmon_sysfs(data->ti_thermal))
  170. + if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal))
  171. dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n");
  172. return 0;