2020-06-26 17:39:34

by Andrzej Pietrasiewicz

[permalink] [raw]
Subject: [PATCH v5 06/11] thermal: Add mode helpers

Prepare for making the drivers not access tzd's private members.

Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>
[EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL]
Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
---
drivers/thermal/thermal_core.c | 53 ++++++++++++++++++++++++++++++++++
include/linux/thermal.h | 13 +++++++++
2 files changed, 66 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 14d3b1b94c4f..3181295075b9 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -459,6 +459,59 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz)
thermal_zone_device_init(tz);
}

+int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
+ enum thermal_device_mode mode)
+{
+ int ret = 0;
+
+ mutex_lock(&tz->lock);
+
+ /* do nothing if mode isn't changing */
+ if (mode == tz->mode) {
+ mutex_unlock(&tz->lock);
+
+ return ret;
+ }
+
+ if (tz->ops->set_mode)
+ ret = tz->ops->set_mode(tz, mode);
+
+ if (!ret)
+ tz->mode = mode;
+
+ mutex_unlock(&tz->lock);
+
+ thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
+
+ return ret;
+}
+
+int thermal_zone_device_enable(struct thermal_zone_device *tz)
+{
+ return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_ENABLED);
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_enable);
+
+int thermal_zone_device_disable(struct thermal_zone_device *tz)
+{
+ return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED);
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_disable);
+
+int thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
+{
+ enum thermal_device_mode mode;
+
+ mutex_lock(&tz->lock);
+
+ mode = tz->mode;
+
+ mutex_unlock(&tz->lock);
+
+ return mode == THERMAL_DEVICE_ENABLED;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_is_enabled);
+
void thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event)
{
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index a808f6fa2777..df013c39ba9b 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -416,6 +416,9 @@ int thermal_zone_get_offset(struct thermal_zone_device *tz);

void thermal_cdev_update(struct thermal_cooling_device *);
void thermal_notify_framework(struct thermal_zone_device *, int);
+int thermal_zone_device_enable(struct thermal_zone_device *tz);
+int thermal_zone_device_disable(struct thermal_zone_device *tz);
+int thermal_zone_device_is_enabled(struct thermal_zone_device *tz);
#else
static inline struct thermal_zone_device *thermal_zone_device_register(
const char *type, int trips, int mask, void *devdata,
@@ -463,6 +466,16 @@ static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
static inline void thermal_notify_framework(struct thermal_zone_device *tz,
int trip)
{ }
+
+static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
+{ return -ENODEV; }
+
+static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
+{ return -ENODEV; }
+
+static inline int
+thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
+{ return -ENODEV; }
#endif /* CONFIG_THERMAL */

#endif /* __THERMAL_H__ */
--
2.17.1


2020-06-26 20:51:50

by kernel test robot

[permalink] [raw]
Subject: [RFC PATCH] thermal: thermal_zone_device_set_mode() can be static


Signed-off-by: kernel test robot <[email protected]>
---
thermal_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 3181295075b9a..f02c57c986f0e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -459,8 +459,8 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz)
thermal_zone_device_init(tz);
}

-int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
- enum thermal_device_mode mode)
+static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
+ enum thermal_device_mode mode)
{
int ret = 0;

2020-06-26 20:52:37

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v5 06/11] thermal: Add mode helpers

Hi Andrzej,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 48778464bb7d346b47157d21ffde2af6b2d39110]

url: https://github.com/0day-ci/linux/commits/Andrzej-Pietrasiewicz/Stop-monitoring-disabled-devices/20200627-013944
base: 48778464bb7d346b47157d21ffde2af6b2d39110
config: x86_64-randconfig-s022-20200624 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-dirty
# save the attached .config to linux build tree
make W=1 C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)

>> drivers/thermal/thermal_core.c:462:5: sparse: sparse: symbol 'thermal_zone_device_set_mode' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (1.08 kB)
.config.gz (29.83 kB)
Download all attachments

2020-06-26 20:56:57

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v5 06/11] thermal: Add mode helpers

Hi Andrzej,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 48778464bb7d346b47157d21ffde2af6b2d39110]

url: https://github.com/0day-ci/linux/commits/Andrzej-Pietrasiewicz/Stop-monitoring-disabled-devices/20200627-013944
base: 48778464bb7d346b47157d21ffde2af6b2d39110
config: arm-imx_v6_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/thermal/thermal_core.c:462:5: warning: no previous prototype for 'thermal_zone_device_set_mode' [-Wmissing-prototypes]
462 | int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/thermal_zone_device_set_mode +462 drivers/thermal/thermal_core.c

461
> 462 int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
463 enum thermal_device_mode mode)
464 {
465 int ret = 0;
466
467 mutex_lock(&tz->lock);
468
469 /* do nothing if mode isn't changing */
470 if (mode == tz->mode) {
471 mutex_unlock(&tz->lock);
472
473 return ret;
474 }
475
476 if (tz->ops->set_mode)
477 ret = tz->ops->set_mode(tz, mode);
478
479 if (!ret)
480 tz->mode = mode;
481
482 mutex_unlock(&tz->lock);
483
484 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
485
486 return ret;
487 }
488

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (1.96 kB)
.config.gz (38.68 kB)
Download all attachments

2020-06-26 23:37:43

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v5 06/11] thermal: Add mode helpers

Hi Andrzej,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 48778464bb7d346b47157d21ffde2af6b2d39110]

url: https://github.com/0day-ci/linux/commits/Andrzej-Pietrasiewicz/Stop-monitoring-disabled-devices/20200627-013944
base: 48778464bb7d346b47157d21ffde2af6b2d39110
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6e11ed52057ffc39941cb2de6d93cae522db4782)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/thermal/thermal_core.c:462:5: warning: no previous prototype for function 'thermal_zone_device_set_mode' [-Wmissing-prototypes]
int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
^
drivers/thermal/thermal_core.c:462:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
^
static
1 warning generated.

vim +/thermal_zone_device_set_mode +462 drivers/thermal/thermal_core.c

461
> 462 int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
463 enum thermal_device_mode mode)
464 {
465 int ret = 0;
466
467 mutex_lock(&tz->lock);
468
469 /* do nothing if mode isn't changing */
470 if (mode == tz->mode) {
471 mutex_unlock(&tz->lock);
472
473 return ret;
474 }
475
476 if (tz->ops->set_mode)
477 ret = tz->ops->set_mode(tz, mode);
478
479 if (!ret)
480 tz->mode = mode;
481
482 mutex_unlock(&tz->lock);
483
484 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
485
486 return ret;
487 }
488

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.35 kB)
.config.gz (73.54 kB)
Download all attachments

2020-06-29 20:47:21

by Amit Kucheria

[permalink] [raw]
Subject: Re: [PATCH v5 06/11] thermal: Add mode helpers

On Fri, Jun 26, 2020 at 11:08 PM Andrzej Pietrasiewicz
<[email protected]> wrote:
>
> Prepare for making the drivers not access tzd's private members.
>
> Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
> Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>
> [EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL]
> Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
> ---
> drivers/thermal/thermal_core.c | 53 ++++++++++++++++++++++++++++++++++
> include/linux/thermal.h | 13 +++++++++
> 2 files changed, 66 insertions(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 14d3b1b94c4f..3181295075b9 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -459,6 +459,59 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz)
> thermal_zone_device_init(tz);
> }
>
> +int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
> + enum thermal_device_mode mode)

Should this be static?

> +{
> + int ret = 0;
> +
> + mutex_lock(&tz->lock);
> +
> + /* do nothing if mode isn't changing */
> + if (mode == tz->mode) {
> + mutex_unlock(&tz->lock);
> +
> + return ret;
> + }
> +
> + if (tz->ops->set_mode)
> + ret = tz->ops->set_mode(tz, mode);
> +
> + if (!ret)
> + tz->mode = mode;
> +
> + mutex_unlock(&tz->lock);
> +
> + thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
> +
> + return ret;
> +}
> +
> +int thermal_zone_device_enable(struct thermal_zone_device *tz)
> +{
> + return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_ENABLED);
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_device_enable);
> +
> +int thermal_zone_device_disable(struct thermal_zone_device *tz)
> +{
> + return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED);
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_device_disable);
> +
> +int thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
> +{
> + enum thermal_device_mode mode;
> +
> + mutex_lock(&tz->lock);
> +
> + mode = tz->mode;
> +
> + mutex_unlock(&tz->lock);
> +
> + return mode == THERMAL_DEVICE_ENABLED;
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_device_is_enabled);
> +
> void thermal_zone_device_update(struct thermal_zone_device *tz,
> enum thermal_notify_event event)
> {
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index a808f6fa2777..df013c39ba9b 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -416,6 +416,9 @@ int thermal_zone_get_offset(struct thermal_zone_device *tz);
>
> void thermal_cdev_update(struct thermal_cooling_device *);
> void thermal_notify_framework(struct thermal_zone_device *, int);
> +int thermal_zone_device_enable(struct thermal_zone_device *tz);
> +int thermal_zone_device_disable(struct thermal_zone_device *tz);
> +int thermal_zone_device_is_enabled(struct thermal_zone_device *tz);
> #else
> static inline struct thermal_zone_device *thermal_zone_device_register(
> const char *type, int trips, int mask, void *devdata,
> @@ -463,6 +466,16 @@ static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> static inline void thermal_notify_framework(struct thermal_zone_device *tz,
> int trip)
> { }
> +
> +static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
> +{ return -ENODEV; }
> +
> +static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
> +{ return -ENODEV; }
> +
> +static inline int
> +thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
> +{ return -ENODEV; }
> #endif /* CONFIG_THERMAL */
>
> #endif /* __THERMAL_H__ */
> --
> 2.17.1
>