Message ID | 1416500488-7232-5-git-send-email-l.majewski@samsung.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Eduardo Valentin |
Headers | show |
On Thu, Nov 20, 2014 at 05:21:28PM +0100, Lukasz Majewski wrote: > Before this change it was only possible to set get_temp() and get_trend() > methods to be used in the common code handling passing parameters via > device tree to "cpu-thermal" CPU thermal zone device. > > Now it is possible to also set emulated value of temperature for debug > purposes. > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> > --- > Changes for v2: > - Rework the emulated temperature setting code to use of_thermal_sensor_ops > structure > --- > drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++ > include/linux/thermal.h | 1 + > 2 files changed, 25 insertions(+) > > diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c > index 33921c5..ad7dc2b 100644 > --- a/drivers/thermal/of-thermal.c > +++ b/drivers/thermal/of-thermal.c > @@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz) > return data->gtrips; > } > > +/** > + * of_thermal_set_emul_temp - function to set emulated temperature > + * > + * @tz: pointer to a thermal zone > + * @temp: temperature to set > + * > + * This function gives the ability to set emulated value of temperature, > + * which is handy for debugging > + * > + * Return: zero on success, error code otherwise > + */ > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, > + unsigned long temp) > +{ > + struct __thermal_zone *data = tz->devdata; > + > + if (!data->ops || !data->ops->set_emul_temp) > + return -EINVAL; > + > + return data->ops->set_emul_temp(data->sensor_data, temp); > +} > + > static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip, > enum thermal_trend *trend) > { > @@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node *zone, > > tzd->ops->get_temp = of_thermal_get_temp; > tzd->ops->get_trend = of_thermal_get_trend; > + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; > mutex_unlock(&tzd->lock); > > return tzd; > @@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev, > mutex_lock(&tzd->lock); > tzd->ops->get_temp = NULL; > tzd->ops->get_trend = NULL; > + tzd->ops->set_emul_temp = NULL; > > tz->ops = NULL; > tz->sensor_data = NULL; > diff --git a/include/linux/thermal.h b/include/linux/thermal.h > index 88d7249..5eb9d44 100644 > --- a/include/linux/thermal.h > +++ b/include/linux/thermal.h > @@ -301,6 +301,7 @@ struct thermal_genl_event { > struct thermal_zone_of_device_ops { > int (*get_temp)(void *, long *); > int (*get_trend)(void *, long *); > + int (*set_emul_temp)(void *, unsigned long); Please add it in the list of Optional functions in the comment above this struct. Apart from that: Acked-by: Eduardo Valentin <edubezval@gmail.com> > }; > > /** > -- > 2.0.0.rc2 >
Hi Eduardo, > On Thu, Nov 20, 2014 at 05:21:28PM +0100, Lukasz Majewski wrote: > > Before this change it was only possible to set get_temp() and > > get_trend() methods to be used in the common code handling passing > > parameters via device tree to "cpu-thermal" CPU thermal zone device. > > > > Now it is possible to also set emulated value of temperature for > > debug purposes. > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> > > --- > > Changes for v2: > > - Rework the emulated temperature setting code to use > > of_thermal_sensor_ops structure > > --- > > drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++ > > include/linux/thermal.h | 1 + > > 2 files changed, 25 insertions(+) > > > > diff --git a/drivers/thermal/of-thermal.c > > b/drivers/thermal/of-thermal.c index 33921c5..ad7dc2b 100644 > > --- a/drivers/thermal/of-thermal.c > > +++ b/drivers/thermal/of-thermal.c > > @@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct > > thermal_zone_device *tz) return data->gtrips; > > } > > > > +/** > > + * of_thermal_set_emul_temp - function to set emulated temperature > > + * > > + * @tz: pointer to a thermal zone > > + * @temp: temperature to set > > + * > > + * This function gives the ability to set emulated value of > > temperature, > > + * which is handy for debugging > > + * > > + * Return: zero on success, error code otherwise > > + */ > > +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, > > + unsigned long temp) > > +{ > > + struct __thermal_zone *data = tz->devdata; > > + > > + if (!data->ops || !data->ops->set_emul_temp) > > + return -EINVAL; > > + > > + return data->ops->set_emul_temp(data->sensor_data, temp); > > +} > > + > > static int of_thermal_get_trend(struct thermal_zone_device *tz, > > int trip, enum thermal_trend *trend) > > { > > @@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node > > *zone, > > tzd->ops->get_temp = of_thermal_get_temp; > > tzd->ops->get_trend = of_thermal_get_trend; > > + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; > > mutex_unlock(&tzd->lock); > > > > return tzd; > > @@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct > > device *dev, mutex_lock(&tzd->lock); > > tzd->ops->get_temp = NULL; > > tzd->ops->get_trend = NULL; > > + tzd->ops->set_emul_temp = NULL; > > > > tz->ops = NULL; > > tz->sensor_data = NULL; > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h > > index 88d7249..5eb9d44 100644 > > --- a/include/linux/thermal.h > > +++ b/include/linux/thermal.h > > @@ -301,6 +301,7 @@ struct thermal_genl_event { > > struct thermal_zone_of_device_ops { > > int (*get_temp)(void *, long *); > > int (*get_trend)(void *, long *); > > + int (*set_emul_temp)(void *, unsigned long); > > Please add it in the list of Optional functions in the comment above > this struct. I will add proper comment to struct thermal_zone_of_device_ops comment. > > Apart from that: > > > Acked-by: Eduardo Valentin <edubezval@gmail.com> > > > > }; > > > > /** > > -- > > 2.0.0.rc2 > >
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 33921c5..ad7dc2b 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -174,6 +174,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz) return data->gtrips; } +/** + * of_thermal_set_emul_temp - function to set emulated temperature + * + * @tz: pointer to a thermal zone + * @temp: temperature to set + * + * This function gives the ability to set emulated value of temperature, + * which is handy for debugging + * + * Return: zero on success, error code otherwise + */ +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, + unsigned long temp) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data->ops || !data->ops->set_emul_temp) + return -EINVAL; + + return data->ops->set_emul_temp(data->sensor_data, temp); +} + static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend) { @@ -405,6 +427,7 @@ thermal_zone_of_add_sensor(struct device_node *zone, tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; mutex_unlock(&tzd->lock); return tzd; @@ -533,6 +556,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev, mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL; tzd->ops->get_trend = NULL; + tzd->ops->set_emul_temp = NULL; tz->ops = NULL; tz->sensor_data = NULL; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 88d7249..5eb9d44 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -301,6 +301,7 @@ struct thermal_genl_event { struct thermal_zone_of_device_ops { int (*get_temp)(void *, long *); int (*get_trend)(void *, long *); + int (*set_emul_temp)(void *, unsigned long); }; /**
Before this change it was only possible to set get_temp() and get_trend() methods to be used in the common code handling passing parameters via device tree to "cpu-thermal" CPU thermal zone device. Now it is possible to also set emulated value of temperature for debug purposes. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> --- Changes for v2: - Rework the emulated temperature setting code to use of_thermal_sensor_ops structure --- drivers/thermal/of-thermal.c | 24 ++++++++++++++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 25 insertions(+)