diff mbox series

[5/6] thermal: core: introduce tz_disabled() helper function

Message ID 20200430063229.6182-6-rui.zhang@intel.com (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show
Series thermal: improve handling of disabled thermal zone | expand

Commit Message

Zhang Rui April 30, 2020, 6:32 a.m. UTC
Rename should_stop_polling() to tz_disabled(), and make it global.
Because there are platform thermal drivers which also need this.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/thermal_core.c | 17 ++++++++---------
 include/linux/thermal.h        |  2 ++
 2 files changed, 10 insertions(+), 9 deletions(-)

Comments

Bartlomiej Zolnierkiewicz May 4, 2020, 7:09 a.m. UTC | #1
On 4/30/20 8:32 AM, Zhang Rui wrote:
> Rename should_stop_polling() to tz_disabled(), and make it global.
> Because there are platform thermal drivers which also need this.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/thermal/thermal_core.c | 17 ++++++++---------
>  include/linux/thermal.h        |  2 ++
>  2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 5f7a867..1cd5d5d0 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -305,16 +305,9 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
>  		cancel_delayed_work(&tz->poll_queue);
>  }
>  
> -static inline bool should_stop_polling(struct thermal_zone_device *tz)
> -{
> -	return thermal_zone_device_get_mode(tz) == THERMAL_DEVICE_DISABLED;
> -}
> -
>  static void monitor_thermal_zone(struct thermal_zone_device *tz)
>  {
> -	bool stop;
> -
> -	stop = should_stop_polling(tz);
> +	bool stop = tz_disabled(tz);
>  
>  	mutex_lock(&tz->lock);
>  
> @@ -502,12 +495,18 @@ int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_set_mode);
>  
> +bool tz_disabled(struct thermal_zone_device *tz)
> +{
> +	return thermal_zone_device_get_mode(tz) == THERMAL_DEVICE_DISABLED;
> +}
> +EXPORT_SYMBOL(tz_disabled);

Is there actual reason to not make it _GPL?

[ all other thermal core functionality seems to be _GPL anyway ]

Otherwise the patch looks fine:

Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> +
>  void thermal_zone_device_update(struct thermal_zone_device *tz,
>  				enum thermal_notify_event event)
>  {
>  	int count;
>  
> -	if (should_stop_polling(tz))
> +	if (tz_disabled(tz))
>  		goto update_polling;
>  
>  	if (atomic_read(&in_suspend))
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index a87fbaf..0bc62ee 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -479,4 +479,6 @@ static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
>  	return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED);
>  }
>  
> +bool tz_disabled(struct thermal_zone_device *tz);
> +
>  #endif /* __THERMAL_H__ */
>
Zhang Rui May 12, 2020, 1:59 a.m. UTC | #2
On Mon, 2020-05-04 at 09:09 +0200, Bartlomiej Zolnierkiewicz wrote:
> On 4/30/20 8:32 AM, Zhang Rui wrote:
> > Rename should_stop_polling() to tz_disabled(), and make it global.
> > Because there are platform thermal drivers which also need this.
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/thermal/thermal_core.c | 17 ++++++++---------
> >  include/linux/thermal.h        |  2 ++
> >  2 files changed, 10 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/thermal/thermal_core.c
> > b/drivers/thermal/thermal_core.c
> > index 5f7a867..1cd5d5d0 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -305,16 +305,9 @@ static void
> > thermal_zone_device_set_polling(struct thermal_zone_device *tz,
> >  		cancel_delayed_work(&tz->poll_queue);
> >  }
> >  
> > -static inline bool should_stop_polling(struct thermal_zone_device
> > *tz)
> > -{
> > -	return thermal_zone_device_get_mode(tz) ==
> > THERMAL_DEVICE_DISABLED;
> > -}
> > -
> >  static void monitor_thermal_zone(struct thermal_zone_device *tz)
> >  {
> > -	bool stop;
> > -
> > -	stop = should_stop_polling(tz);
> > +	bool stop = tz_disabled(tz);
> >  
> >  	mutex_lock(&tz->lock);
> >  
> > @@ -502,12 +495,18 @@ int thermal_zone_device_set_mode(struct
> > thermal_zone_device *tz,
> >  }
> >  EXPORT_SYMBOL_GPL(thermal_zone_device_set_mode);
> >  
> > +bool tz_disabled(struct thermal_zone_device *tz)
> > +{
> > +	return thermal_zone_device_get_mode(tz) ==
> > THERMAL_DEVICE_DISABLED;
> > +}
> > +EXPORT_SYMBOL(tz_disabled);
> 
> Is there actual reason to not make it _GPL?
> 
> [ all other thermal core functionality seems to be _GPL anyway ]

Thanks for catching this, will fix in next version.
> 
> Otherwise the patch looks fine:
> 
> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

thanks for the review.

-Rui
> 
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> 
> > +
> >  void thermal_zone_device_update(struct thermal_zone_device *tz,
> >  				enum thermal_notify_event event)
> >  {
> >  	int count;
> >  
> > -	if (should_stop_polling(tz))
> > +	if (tz_disabled(tz))
> >  		goto update_polling;
> >  
> >  	if (atomic_read(&in_suspend))
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index a87fbaf..0bc62ee 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -479,4 +479,6 @@ static inline int
> > thermal_zone_device_disable(struct thermal_zone_device *tz)
> >  	return thermal_zone_device_set_mode(tz,
> > THERMAL_DEVICE_DISABLED);
> >  }
> >  
> > +bool tz_disabled(struct thermal_zone_device *tz);
> > +
> >  #endif /* __THERMAL_H__ */
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 5f7a867..1cd5d5d0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -305,16 +305,9 @@  static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
 		cancel_delayed_work(&tz->poll_queue);
 }
 
-static inline bool should_stop_polling(struct thermal_zone_device *tz)
-{
-	return thermal_zone_device_get_mode(tz) == THERMAL_DEVICE_DISABLED;
-}
-
 static void monitor_thermal_zone(struct thermal_zone_device *tz)
 {
-	bool stop;
-
-	stop = should_stop_polling(tz);
+	bool stop = tz_disabled(tz);
 
 	mutex_lock(&tz->lock);
 
@@ -502,12 +495,18 @@  int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_set_mode);
 
+bool tz_disabled(struct thermal_zone_device *tz)
+{
+	return thermal_zone_device_get_mode(tz) == THERMAL_DEVICE_DISABLED;
+}
+EXPORT_SYMBOL(tz_disabled);
+
 void thermal_zone_device_update(struct thermal_zone_device *tz,
 				enum thermal_notify_event event)
 {
 	int count;
 
-	if (should_stop_polling(tz))
+	if (tz_disabled(tz))
 		goto update_polling;
 
 	if (atomic_read(&in_suspend))
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index a87fbaf..0bc62ee 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -479,4 +479,6 @@  static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
 	return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED);
 }
 
+bool tz_disabled(struct thermal_zone_device *tz);
+
 #endif /* __THERMAL_H__ */