Re: [2/9] thermal: exynos: Add support for instance based register/unregister
Hi Eduardo, On Fri, Apr 12, 2013 at 1:39 AM, Eduardo Valentin eduardo.valen...@ti.com wrote: Hey Amit, On 26-03-2013 07:33, Amit Daniel Kachhap wrote: This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone varibale with device data s/varibale/variable ok type mistake :) member of thermal_zone_device. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com I understand the idea of your patch but I also see that you do at least to major changes. One is to set the thermal_device.devdata. The second is to split your internal reference private_data into driver_data and pzone_data. Is it possible to split this patch into two, one per modification? So it is easier to review your changes? yes agreed..the kind of patch restructuring suggested by you makes sense. --- drivers/thermal/exynos_thermal.c | 65 ++--- 1 files changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 1cd7837..dc9b91b 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -148,7 +148,8 @@ struct thermal_sensor_conf { int (*write_emul_temp)(void *drv_data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; - void *private_data; + void *driver_data; + void *pzone_data; }; struct exynos_thermal_zone { @@ -161,14 +162,14 @@ struct exynos_thermal_zone { bool bind; }; -static struct exynos_thermal_zone *th_zone; -static void exynos_unregister_thermal(void); +static void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf); static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf); /* Get mode callback functions for thermal zone */ static int exynos_get_mode(struct thermal_zone_device *thermal, enum thermal_device_mode *mode) { + struct exynos_thermal_zone *th_zone = thermal-devdata; if (th_zone) *mode = th_zone-mode; return 0; @@ -178,25 +179,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal, static int exynos_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { - if (!th_zone-therm_dev) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (!th_zone) { pr_notice(thermal zone not registered\n); return 0; } - mutex_lock(th_zone-therm_dev-lock); + mutex_lock(thermal-lock); if (mode == THERMAL_DEVICE_ENABLED !th_zone-sensor_conf-trip_data.trigger_falling) - th_zone-therm_dev-polling_delay = IDLE_INTERVAL; + thermal-polling_delay = IDLE_INTERVAL; else - th_zone-therm_dev-polling_delay = 0; + thermal-polling_delay = 0; - mutex_unlock(th_zone-therm_dev-lock); + mutex_unlock(thermal-lock); th_zone-mode = mode; - thermal_zone_device_update(th_zone-therm_dev); + thermal_zone_device_update(thermal); pr_info(thermal polling set for duration=%d msec\n, - th_zone-therm_dev-polling_delay); + thermal-polling_delay); return 0; } @@ -223,6 +225,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (trip GET_TRIP(MONITOR_ZONE) || trip GET_TRIP(PANIC_ZONE)) return -EINVAL; @@ -269,6 +273,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, { int ret = 0, i, tab_size, level; struct freq_clip_table *tab_ptr, *clip_data; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; tab_ptr = (struct freq_clip_table *)data-cooling_data.freq_data; @@ -315,6 +320,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { int ret = 0, i, tab_size; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; if (th_zone-bind == false) @@ -357,13 +363,14 @@ static int exynos_unbind(struct thermal_zone_device *thermal, static int exynos_get_temp(struct thermal_zone_device *thermal, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; void *data; if (!th_zone-sensor_conf) {
Re: [2/9] thermal: exynos: Add support for instance based register/unregister
Hey Amit, On 26-03-2013 07:33, Amit Daniel Kachhap wrote: This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone varibale with device data s/varibale/variable member of thermal_zone_device. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com I understand the idea of your patch but I also see that you do at least to major changes. One is to set the thermal_device.devdata. The second is to split your internal reference private_data into driver_data and pzone_data. Is it possible to split this patch into two, one per modification? So it is easier to review your changes? --- drivers/thermal/exynos_thermal.c | 65 ++--- 1 files changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 1cd7837..dc9b91b 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -148,7 +148,8 @@ struct thermal_sensor_conf { int (*write_emul_temp)(void *drv_data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; - void *private_data; + void *driver_data; + void *pzone_data; }; struct exynos_thermal_zone { @@ -161,14 +162,14 @@ struct exynos_thermal_zone { bool bind; }; -static struct exynos_thermal_zone *th_zone; -static void exynos_unregister_thermal(void); +static void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf); static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf); /* Get mode callback functions for thermal zone */ static int exynos_get_mode(struct thermal_zone_device *thermal, enum thermal_device_mode *mode) { + struct exynos_thermal_zone *th_zone = thermal-devdata; if (th_zone) *mode = th_zone-mode; return 0; @@ -178,25 +179,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal, static int exynos_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { - if (!th_zone-therm_dev) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (!th_zone) { pr_notice(thermal zone not registered\n); return 0; } - mutex_lock(th_zone-therm_dev-lock); + mutex_lock(thermal-lock); if (mode == THERMAL_DEVICE_ENABLED !th_zone-sensor_conf-trip_data.trigger_falling) - th_zone-therm_dev-polling_delay = IDLE_INTERVAL; + thermal-polling_delay = IDLE_INTERVAL; else - th_zone-therm_dev-polling_delay = 0; + thermal-polling_delay = 0; - mutex_unlock(th_zone-therm_dev-lock); + mutex_unlock(thermal-lock); th_zone-mode = mode; - thermal_zone_device_update(th_zone-therm_dev); + thermal_zone_device_update(thermal); pr_info(thermal polling set for duration=%d msec\n, - th_zone-therm_dev-polling_delay); + thermal-polling_delay); return 0; } @@ -223,6 +225,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (trip GET_TRIP(MONITOR_ZONE) || trip GET_TRIP(PANIC_ZONE)) return -EINVAL; @@ -269,6 +273,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, { int ret = 0, i, tab_size, level; struct freq_clip_table *tab_ptr, *clip_data; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; tab_ptr = (struct freq_clip_table *)data-cooling_data.freq_data; @@ -315,6 +320,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { int ret = 0, i, tab_size; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; if (th_zone-bind == false) @@ -357,13 +363,14 @@ static int exynos_unbind(struct thermal_zone_device *thermal, static int exynos_get_temp(struct thermal_zone_device *thermal, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; void *data; if (!th_zone-sensor_conf) { pr_info(Temperature sensor not initialised\n); return -EINVAL; } - data = th_zone-sensor_conf-private_data; + data = th_zone-sensor_conf-driver_data; *temp = th_zone-sensor_conf-read_temperature(data); /* convert the temperature into millicelsius */
[PATCH 2/9] thermal: exynos: Add support for instance based register/unregister
This code modifies the thermal driver to have multiple thermal zone support by replacing the global thermal zone varibale with device data member of thermal_zone_device. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/thermal/exynos_thermal.c | 65 ++--- 1 files changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 1cd7837..dc9b91b 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -148,7 +148,8 @@ struct thermal_sensor_conf { int (*write_emul_temp)(void *drv_data, unsigned long temp); struct thermal_trip_point_conf trip_data; struct thermal_cooling_conf cooling_data; - void *private_data; + void *driver_data; + void *pzone_data; }; struct exynos_thermal_zone { @@ -161,14 +162,14 @@ struct exynos_thermal_zone { bool bind; }; -static struct exynos_thermal_zone *th_zone; -static void exynos_unregister_thermal(void); +static void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf); static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf); /* Get mode callback functions for thermal zone */ static int exynos_get_mode(struct thermal_zone_device *thermal, enum thermal_device_mode *mode) { + struct exynos_thermal_zone *th_zone = thermal-devdata; if (th_zone) *mode = th_zone-mode; return 0; @@ -178,25 +179,26 @@ static int exynos_get_mode(struct thermal_zone_device *thermal, static int exynos_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { - if (!th_zone-therm_dev) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (!th_zone) { pr_notice(thermal zone not registered\n); return 0; } - mutex_lock(th_zone-therm_dev-lock); + mutex_lock(thermal-lock); if (mode == THERMAL_DEVICE_ENABLED !th_zone-sensor_conf-trip_data.trigger_falling) - th_zone-therm_dev-polling_delay = IDLE_INTERVAL; + thermal-polling_delay = IDLE_INTERVAL; else - th_zone-therm_dev-polling_delay = 0; + thermal-polling_delay = 0; - mutex_unlock(th_zone-therm_dev-lock); + mutex_unlock(thermal-lock); th_zone-mode = mode; - thermal_zone_device_update(th_zone-therm_dev); + thermal_zone_device_update(thermal); pr_info(thermal polling set for duration=%d msec\n, - th_zone-therm_dev-polling_delay); + thermal-polling_delay); return 0; } @@ -223,6 +225,8 @@ static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; + if (trip GET_TRIP(MONITOR_ZONE) || trip GET_TRIP(PANIC_ZONE)) return -EINVAL; @@ -269,6 +273,7 @@ static int exynos_bind(struct thermal_zone_device *thermal, { int ret = 0, i, tab_size, level; struct freq_clip_table *tab_ptr, *clip_data; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; tab_ptr = (struct freq_clip_table *)data-cooling_data.freq_data; @@ -315,6 +320,7 @@ static int exynos_unbind(struct thermal_zone_device *thermal, struct thermal_cooling_device *cdev) { int ret = 0, i, tab_size; + struct exynos_thermal_zone *th_zone = thermal-devdata; struct thermal_sensor_conf *data = th_zone-sensor_conf; if (th_zone-bind == false) @@ -357,13 +363,14 @@ static int exynos_unbind(struct thermal_zone_device *thermal, static int exynos_get_temp(struct thermal_zone_device *thermal, unsigned long *temp) { + struct exynos_thermal_zone *th_zone = thermal-devdata; void *data; if (!th_zone-sensor_conf) { pr_info(Temperature sensor not initialised\n); return -EINVAL; } - data = th_zone-sensor_conf-private_data; + data = th_zone-sensor_conf-driver_data; *temp = th_zone-sensor_conf-read_temperature(data); /* convert the temperature into millicelsius */ *temp = *temp * MCELSIUS; @@ -376,12 +383,13 @@ static int exynos_set_emul_temp(struct thermal_zone_device *thermal, { void *data; int ret = -EINVAL; + struct exynos_thermal_zone *th_zone = thermal-devdata; if (!th_zone-sensor_conf) { pr_info(Temperature sensor not initialised\n); return -EINVAL; } - data = th_zone-sensor_conf-private_data; +