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

thermal: streamline get_trend callbacks

The .get_trend callback in struct thermal_zone_device_ops has
the prototype:
int (*get_trend) (struct thermal_zone_device *, int,
enum thermal_trend *);
whereas the .get_trend callback in struct thermal_zone_of_device_ops
has:
int (*get_trend)(void *, long *);

Streamline both prototypes and add the trip argument to the OF callback
aswell and use enum thermal_trend * instead of an integer pointer.

While the OF prototype may be the better one, this should be decided at
framework level and not on OF level.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: linux-pm@vger.kernel.org
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>

authored by

Sascha Hauer and committed by
Zhang Rui
e78eaf45 826386e7

+16 -37
+1 -15
drivers/thermal/of-thermal.c
··· 202 202 enum thermal_trend *trend) 203 203 { 204 204 struct __thermal_zone *data = tz->devdata; 205 - long dev_trend; 206 - int r; 207 205 208 206 if (!data->ops->get_trend) 209 207 return -EINVAL; 210 208 211 - r = data->ops->get_trend(data->sensor_data, &dev_trend); 212 - if (r) 213 - return r; 214 - 215 - /* TODO: These intervals might have some thresholds, but in core code */ 216 - if (dev_trend > 0) 217 - *trend = THERMAL_TREND_RAISING; 218 - else if (dev_trend < 0) 219 - *trend = THERMAL_TREND_DROPPING; 220 - else 221 - *trend = THERMAL_TREND_STABLE; 222 - 223 - return 0; 209 + return data->ops->get_trend(data->sensor_data, trip, trend); 224 210 } 225 211 226 212 static int of_thermal_bind(struct thermal_zone_device *thermal,
+3 -3
drivers/thermal/qcom/tsens.c
··· 29 29 return tmdev->ops->get_temp(tmdev, s->id, temp); 30 30 } 31 31 32 - static int tsens_get_trend(void *data, long *temp) 32 + static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend) 33 33 { 34 - const struct tsens_sensor *s = data; 34 + const struct tsens_sensor *s = p; 35 35 struct tsens_device *tmdev = s->tmdev; 36 36 37 37 if (tmdev->ops->get_trend) 38 - return tmdev->ops->get_trend(tmdev, s->id, temp); 38 + return tmdev->ops->get_trend(tmdev, s->id, trend); 39 39 40 40 return -ENOTSUPP; 41 41 }
+3 -1
drivers/thermal/qcom/tsens.h
··· 17 17 #define ONE_PT_CALIB2 0x2 18 18 #define TWO_PT_CALIB 0x3 19 19 20 + #include <linux/thermal.h> 21 + 20 22 struct tsens_device; 21 23 22 24 struct tsens_sensor { ··· 52 50 void (*disable)(struct tsens_device *); 53 51 int (*suspend)(struct tsens_device *); 54 52 int (*resume)(struct tsens_device *); 55 - int (*get_trend)(struct tsens_device *, int, long *); 53 + int (*get_trend)(struct tsens_device *, int, enum thermal_trend *); 56 54 }; 57 55 58 56 /**
+8 -17
drivers/thermal/ti-soc-thermal/ti-thermal-common.c
··· 239 239 return 0; 240 240 } 241 241 242 - static int __ti_thermal_get_trend(void *p, long *trend) 242 + static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend) 243 243 { 244 244 struct ti_thermal_data *data = p; 245 245 struct ti_bandgap *bgp; ··· 252 252 if (ret) 253 253 return ret; 254 254 255 - *trend = tr; 256 - 257 - return 0; 258 - } 259 - 260 - /* Get the temperature trend callback functions for thermal zone */ 261 - static int ti_thermal_get_trend(struct thermal_zone_device *thermal, 262 - int trip, enum thermal_trend *trend) 263 - { 264 - int ret; 265 - long tr; 266 - 267 - ret = __ti_thermal_get_trend(thermal->devdata, &tr); 268 - if (ret) 269 - return ret; 270 - 271 255 if (tr > 0) 272 256 *trend = THERMAL_TREND_RAISING; 273 257 else if (tr < 0) ··· 260 276 *trend = THERMAL_TREND_STABLE; 261 277 262 278 return 0; 279 + } 280 + 281 + /* Get the temperature trend callback functions for thermal zone */ 282 + static int ti_thermal_get_trend(struct thermal_zone_device *thermal, 283 + int trip, enum thermal_trend *trend) 284 + { 285 + return __ti_thermal_get_trend(thermal->devdata, trip, trend); 263 286 } 264 287 265 288 /* Get critical temperature callback functions for thermal zone */
+1 -1
include/linux/thermal.h
··· 350 350 */ 351 351 struct thermal_zone_of_device_ops { 352 352 int (*get_temp)(void *, int *); 353 - int (*get_trend)(void *, long *); 353 + int (*get_trend)(void *, int, enum thermal_trend *); 354 354 int (*set_trips)(void *, int, int); 355 355 int (*set_emul_temp)(void *, int); 356 356 int (*set_trip_temp)(void *, int, int);