diff mbox

[PATCHv2,03/14] Thermal: Add get trend, get instance API's to thermal_sys

Message ID 1346041706-29642-4-git-send-email-durgadoss.r@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

durgadoss.r@intel.com Aug. 27, 2012, 4:28 a.m. UTC
This patch adds the following API's to thermal_sys.c, that
can be used by other Thermal drivers.
 * get_tz_trend: obtain the trend of the given thermal zone
 * get_thermal_instance: obtain the instance corresponding
   to the given tz, cdev and the trip point.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
---
 drivers/thermal/thermal_sys.c |   40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/thermal.h       |    4 ++++
 2 files changed, 44 insertions(+)

Comments

Zhang, Rui Aug. 27, 2012, 8:11 a.m. UTC | #1
> -----Original Message-----
> From: R, Durgadoss
> Sent: Monday, August 27, 2012 7:28 AM
> To: lenb@kernel.org; Zhang, Rui
> Cc: linux-acpi@vger.kernel.org; eduardo.valentin@ti.com; R, Durgadoss
> Subject: [PATCHv2 03/14] Thermal: Add get trend, get instance API's to
> thermal_sys
> Importance: High
> 
> This patch adds the following API's to thermal_sys.c, that can be used
> by other Thermal drivers.
>  * get_tz_trend: obtain the trend of the given thermal zone
>  * get_thermal_instance: obtain the instance corresponding
>    to the given tz, cdev and the trip point.
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
>  drivers/thermal/thermal_sys.c |   40
> ++++++++++++++++++++++++++++++++++++++++
>  include/linux/thermal.h       |    4 ++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_sys.c
> b/drivers/thermal/thermal_sys.c index 0e71b00..5e141b5 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -82,6 +82,46 @@ static void release_idr(struct idr *idr, struct
> mutex *lock, int id)
>  		mutex_unlock(lock);
>  }
> 
> +int get_tz_trend(struct thermal_zone_device *tz, int trip) {
> +	enum thermal_trend trend;
> +
> +	if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend))
> {
> +		if (tz->temperature > tz->last_temperature)
> +			trend = THERMAL_TREND_RAISING;
> +		else if (tz->temperature < tz->last_temperature)
> +			trend = THERMAL_TREND_DROPPING;
> +		else
> +			trend = THERMAL_TREND_STABLE;
> +	}
> +
> +	return trend;
> +}
> +EXPORT_SYMBOL(get_tz_trend);
> +
> +struct thermal_instance *get_thermal_instance(struct
> thermal_zone_device *tz,
> +			struct thermal_cooling_device *cdev, int trip) {
> +	struct thermal_instance *pos = NULL;
> +	struct thermal_instance *target_instance = NULL;
> +
> +	mutex_lock(&tz->lock);
> +	mutex_lock(&cdev->lock);
> +
> +	list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
> +		if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev)
> {
> +			target_instance = pos;
> +			break;
> +		}
> +	}
> +
> +	mutex_unlock(&cdev->lock);
> +	mutex_unlock(&tz->lock);
> +
> +	return target_instance;
> +}
> +EXPORT_SYMBOL(get_thermal_instance);
> +
>  /* sys I/F for thermal zone */
> 
>  #define to_thermal_zone(_dev) \
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h index
> 8611e3e..32af124 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -185,6 +185,10 @@ struct thermal_cooling_device
> *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);  void
> thermal_cooling_device_unregister(struct thermal_cooling_device *);
> 
> +int get_tz_trend(struct thermal_zone_device *, int); struct

Coding style.

Thanks,
rui
> +thermal_instance *get_thermal_instance(struct thermal_zone_device *,
> +		struct thermal_cooling_device *, int);
> +
>  #ifdef CONFIG_NET
>  extern int thermal_generate_netlink_event(u32 orig, enum events event);
> #else
> --
> 1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
durgadoss.r@intel.com Aug. 27, 2012, 8:47 a.m. UTC | #2
Hi Rui,

> >
> > +int get_tz_trend(struct thermal_zone_device *tz, int trip) {
> > +	enum thermal_trend trend;
> > +
> > +	if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend))
> > {
> > +		if (tz->temperature > tz->last_temperature)
> > +			trend = THERMAL_TREND_RAISING;
> > +		else if (tz->temperature < tz->last_temperature)
> > +			trend = THERMAL_TREND_DROPPING;
> > +		else
> > +			trend = THERMAL_TREND_STABLE;
> > +	}
> > +
> > +	return trend;
> > +}
> > +EXPORT_SYMBOL(get_tz_trend);
> > +
> > +struct thermal_instance *get_thermal_instance(struct
> > thermal_zone_device *tz,
> > +			struct thermal_cooling_device *cdev, int trip) {
> > +	struct thermal_instance *pos = NULL;
> > +	struct thermal_instance *target_instance = NULL;
> > +
> > +	mutex_lock(&tz->lock);
> > +	mutex_lock(&cdev->lock);
> > +
> > +	list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
> > +		if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev)
> > {
> > +			target_instance = pos;
> > +			break;
> > +		}
> > +	}
> > +
> > +	mutex_unlock(&cdev->lock);
> > +	mutex_unlock(&tz->lock);
> > +
> > +	return target_instance;
> > +}
> > +EXPORT_SYMBOL(get_thermal_instance);
> > +
> >  /* sys I/F for thermal zone */
> >
> >  #define to_thermal_zone(_dev) \
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h index
> > 8611e3e..32af124 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -185,6 +185,10 @@ struct thermal_cooling_device
> > *thermal_cooling_device_register(char *, void *,
> >  		const struct thermal_cooling_device_ops *);  void
> > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> >
> > +int get_tz_trend(struct thermal_zone_device *, int); struct
> 
> Coding style.

Not sure what you meant here. Checkpatch did not complain either.

Thanks,
Durga

> 
> Thanks,
> rui
> > +thermal_instance *get_thermal_instance(struct thermal_zone_device *,
> > +		struct thermal_cooling_device *, int);
> > +
> >  #ifdef CONFIG_NET
> >  extern int thermal_generate_netlink_event(u32 orig, enum events
> event);
> > #else
> > --
> > 1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Rui Aug. 27, 2012, 9:19 a.m. UTC | #3
> -----Original Message-----
> From: R, Durgadoss
> Sent: Monday, August 27, 2012 11:47 AM
> To: Zhang, Rui; lenb@kernel.org
> Cc: linux-acpi@vger.kernel.org; eduardo.valentin@ti.com
> Subject: RE: [PATCHv2 03/14] Thermal: Add get trend, get instance API's
> to thermal_sys
> Importance: High
> 
> Hi Rui,
> 
> > >
> > > +int get_tz_trend(struct thermal_zone_device *tz, int trip) {
> > > +	enum thermal_trend trend;
> > > +
> > > +	if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend))
> > > {
> > > +		if (tz->temperature > tz->last_temperature)
> > > +			trend = THERMAL_TREND_RAISING;
> > > +		else if (tz->temperature < tz->last_temperature)
> > > +			trend = THERMAL_TREND_DROPPING;
> > > +		else
> > > +			trend = THERMAL_TREND_STABLE;
> > > +	}
> > > +
> > > +	return trend;
> > > +}
> > > +EXPORT_SYMBOL(get_tz_trend);
> > > +
> > > +struct thermal_instance *get_thermal_instance(struct
> > > thermal_zone_device *tz,
> > > +			struct thermal_cooling_device *cdev, int trip) {
> > > +	struct thermal_instance *pos = NULL;
> > > +	struct thermal_instance *target_instance = NULL;
> > > +
> > > +	mutex_lock(&tz->lock);
> > > +	mutex_lock(&cdev->lock);
> > > +
> > > +	list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
> > > +		if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev)
> > > {
> > > +			target_instance = pos;
> > > +			break;
> > > +		}
> > > +	}
> > > +
> > > +	mutex_unlock(&cdev->lock);
> > > +	mutex_unlock(&tz->lock);
> > > +
> > > +	return target_instance;
> > > +}
> > > +EXPORT_SYMBOL(get_thermal_instance);
> > > +
> > >  /* sys I/F for thermal zone */
> > >
> > >  #define to_thermal_zone(_dev) \
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index
> > > 8611e3e..32af124 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -185,6 +185,10 @@ struct thermal_cooling_device
> > > *thermal_cooling_device_register(char *, void *,
> > >  		const struct thermal_cooling_device_ops *);  void
> > > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> > >
> > > +int get_tz_trend(struct thermal_zone_device *, int); struct
> >
> > Coding style.
> 
> Not sure what you meant here. Checkpatch did not complain either.
> 
you should start a new line before "struct".

Thanks,
rui

> Thanks,
> Durga
> 
> >
> > Thanks,
> > rui
> > > +thermal_instance *get_thermal_instance(struct thermal_zone_device
> *,
> > > +		struct thermal_cooling_device *, int);
> > > +
> > >  #ifdef CONFIG_NET
> > >  extern int thermal_generate_netlink_event(u32 orig, enum events
> > event);
> > > #else
> > > --
> > > 1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
durgadoss.r@intel.com Aug. 27, 2012, 9:24 a.m. UTC | #4
Hi Rui,

> > index
> > > > 8611e3e..32af124 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -185,6 +185,10 @@ struct thermal_cooling_device
> > > > *thermal_cooling_device_register(char *, void *,
> > > >  		const struct thermal_cooling_device_ops *);  void
> > > > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> > > >
> > > > +int get_tz_trend(struct thermal_zone_device *, int); struct
> > >
> > > Coding style.
> >
> > Not sure what you meant here. Checkpatch did not complain either.
> >
> you should start a new line before "struct".

Agreed :-) But in the actual patch it is that way,
I think it is your mailer which is playing things here :-)
Kindly check..

Thanks,
Durga
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 0e71b00..5e141b5 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -82,6 +82,46 @@  static void release_idr(struct idr *idr, struct mutex *lock, int id)
 		mutex_unlock(lock);
 }
 
+int get_tz_trend(struct thermal_zone_device *tz, int trip)
+{
+	enum thermal_trend trend;
+
+	if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
+		if (tz->temperature > tz->last_temperature)
+			trend = THERMAL_TREND_RAISING;
+		else if (tz->temperature < tz->last_temperature)
+			trend = THERMAL_TREND_DROPPING;
+		else
+			trend = THERMAL_TREND_STABLE;
+	}
+
+	return trend;
+}
+EXPORT_SYMBOL(get_tz_trend);
+
+struct thermal_instance *get_thermal_instance(struct thermal_zone_device *tz,
+			struct thermal_cooling_device *cdev, int trip)
+{
+	struct thermal_instance *pos = NULL;
+	struct thermal_instance *target_instance = NULL;
+
+	mutex_lock(&tz->lock);
+	mutex_lock(&cdev->lock);
+
+	list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+		if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
+			target_instance = pos;
+			break;
+		}
+	}
+
+	mutex_unlock(&cdev->lock);
+	mutex_unlock(&tz->lock);
+
+	return target_instance;
+}
+EXPORT_SYMBOL(get_thermal_instance);
+
 /* sys I/F for thermal zone */
 
 #define to_thermal_zone(_dev) \
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 8611e3e..32af124 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -185,6 +185,10 @@  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 
+int get_tz_trend(struct thermal_zone_device *, int);
+struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
+		struct thermal_cooling_device *, int);
+
 #ifdef CONFIG_NET
 extern int thermal_generate_netlink_event(u32 orig, enum events event);
 #else