diff mbox

[V4,01/13] Thermal: Introduce multiple cooling states support

Message ID 1343292083-2047-2-git-send-email-rui.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Rui July 26, 2012, 8:41 a.m. UTC
This is because general active cooling devices, like fans,
may have multiple speeds, which can be mapped to different cooling states.

Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/thermal_sys.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Eduardo Valentin Aug. 8, 2012, 12:02 p.m. UTC | #1
Hello Rui,

On Thu, Jul 26, 2012 at 11:41 AM, Zhang Rui <rui.zhang@intel.com> wrote:
> This is because general active cooling devices, like fans,
> may have multiple speeds, which can be mapped to different cooling states.
>
> Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>

> ---
>  drivers/thermal/thermal_sys.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 2d7a9fe..05f42cd 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
>         enum thermal_trip_type trip_type;
>         struct thermal_cooling_device_instance *instance;
>         struct thermal_cooling_device *cdev;
> +       unsigned long cur_state, max_state;
>
>         mutex_lock(&tz->lock);
>
> @@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
>
>                                 cdev = instance->cdev;
>
> +                               cdev->ops->get_cur_state(cdev, &cur_state);
> +                               cdev->ops->get_max_state(cdev, &max_state);
> +
>                                 if (temp >= trip_temp)
> -                                       cdev->ops->set_cur_state(cdev, 1);
> +                                       cur_state = cur_state < max_state ?
> +                                               (cur_state + 1) : max_state;
>                                 else
> -                                       cdev->ops->set_cur_state(cdev, 0);
> +                                       cur_state = cur_state > 0 ?
> +                                               (cur_state - 1) : 0;
> +
> +                               cdev->ops->set_cur_state(cdev, cur_state);
>                         }
>                         break;
>                 case THERMAL_TRIP_PASSIVE:
> --
> 1.7.9.5
>
Zhang Rui Aug. 9, 2012, 12:58 a.m. UTC | #2
On ?, 2012-08-08 at 15:02 +0300, Valentin, Eduardo wrote:
> Hello Rui,
> 
> On Thu, Jul 26, 2012 at 11:41 AM, Zhang Rui <rui.zhang@intel.com> wrote:
> > This is because general active cooling devices, like fans,
> > may have multiple speeds, which can be mapped to different cooling states.
> >
> > Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> 
> Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
> 
thanks!

-rui
> > ---
> >  drivers/thermal/thermal_sys.c |   12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > index 2d7a9fe..05f42cd 100644
> > --- a/drivers/thermal/thermal_sys.c
> > +++ b/drivers/thermal/thermal_sys.c
> > @@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
> >         enum thermal_trip_type trip_type;
> >         struct thermal_cooling_device_instance *instance;
> >         struct thermal_cooling_device *cdev;
> > +       unsigned long cur_state, max_state;
> >
> >         mutex_lock(&tz->lock);
> >
> > @@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
> >
> >                                 cdev = instance->cdev;
> >
> > +                               cdev->ops->get_cur_state(cdev, &cur_state);
> > +                               cdev->ops->get_max_state(cdev, &max_state);
> > +
> >                                 if (temp >= trip_temp)
> > -                                       cdev->ops->set_cur_state(cdev, 1);
> > +                                       cur_state = cur_state < max_state ?
> > +                                               (cur_state + 1) : max_state;
> >                                 else
> > -                                       cdev->ops->set_cur_state(cdev, 0);
> > +                                       cur_state = cur_state > 0 ?
> > +                                               (cur_state - 1) : 0;
> > +
> > +                               cdev->ops->set_cur_state(cdev, cur_state);
> >                         }
> >                         break;
> >                 case THERMAL_TRIP_PASSIVE:
> > --
> > 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
diff mbox

Patch

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 2d7a9fe..05f42cd 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1059,6 +1059,7 @@  void thermal_zone_device_update(struct thermal_zone_device *tz)
 	enum thermal_trip_type trip_type;
 	struct thermal_cooling_device_instance *instance;
 	struct thermal_cooling_device *cdev;
+	unsigned long cur_state, max_state;
 
 	mutex_lock(&tz->lock);
 
@@ -1098,10 +1099,17 @@  void thermal_zone_device_update(struct thermal_zone_device *tz)
 
 				cdev = instance->cdev;
 
+				cdev->ops->get_cur_state(cdev, &cur_state);
+				cdev->ops->get_max_state(cdev, &max_state);
+
 				if (temp >= trip_temp)
-					cdev->ops->set_cur_state(cdev, 1);
+					cur_state = cur_state < max_state ?
+						(cur_state + 1) : max_state;
 				else
-					cdev->ops->set_cur_state(cdev, 0);
+					cur_state = cur_state > 0 ?
+						(cur_state - 1) : 0;
+
+				cdev->ops->set_cur_state(cdev, cur_state);
 			}
 			break;
 		case THERMAL_TRIP_PASSIVE: