linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled
@ 2020-06-02  9:12 Serge Semin
  2020-06-02 14:07 ` Guenter Roeck
  2020-06-03  0:07 ` [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused Serge Semin
  0 siblings, 2 replies; 5+ messages in thread
From: Serge Semin @ 2020-06-02  9:12 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck
  Cc: Serge Semin, Serge Semin, kbuild test robot, Maxim Kaurkin,
	Alexey Malahov, linux-hwmon, linux-kernel

Clang-based kernel building with W=1 warns that some static const
variables are unused:

drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
static const struct pvt_poly poly_temp_to_N = {
                             ^
drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
static const struct pvt_poly poly_volt_to_N = {
                             ^

Indeed these polynomials are utilized only when the PVT sensor alarms are
enabled. In that case they are used to convert the temperature and
voltage alarm limits from normal quantities (Volts and degree Celsius) to
the sensor data representation N = [0, 1023]. Otherwise when alarms are
disabled the driver only does the detected data conversion to the human
readable form and doesn't need that polynomials defined. So let's declare
the Temp-to-N and Volt-to-N polynomials only if the PVT alarms are
switched on at compile-time.

Note gcc with W=1 doesn't notice the problem.

Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
---
 drivers/hwmon/bt1-pvt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
index 1a9772fb1f73..1a5212c04549 100644
--- a/drivers/hwmon/bt1-pvt.c
+++ b/drivers/hwmon/bt1-pvt.c
@@ -64,6 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
  *     48380,
  * where T = [-48380, 147438] mC and N = [0, 1023].
  */
+#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
 static const struct pvt_poly poly_temp_to_N = {
 	.total_divider = 10000,
 	.terms = {
@@ -74,6 +75,7 @@ static const struct pvt_poly poly_temp_to_N = {
 		{0, 1720400, 1, 1}
 	}
 };
+#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
 
 static const struct pvt_poly poly_N_to_temp = {
 	.total_divider = 1,
@@ -96,6 +98,7 @@ static const struct pvt_poly poly_N_to_temp = {
  * N = (18658e-3*V - 11572) / 10,
  * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
  */
+#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
 static const struct pvt_poly poly_volt_to_N = {
 	.total_divider = 10,
 	.terms = {
@@ -103,6 +106,7 @@ static const struct pvt_poly poly_volt_to_N = {
 		{0, -11572, 1, 1}
 	}
 };
+#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
 
 static const struct pvt_poly poly_N_to_volt = {
 	.total_divider = 10,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled
  2020-06-02  9:12 [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled Serge Semin
@ 2020-06-02 14:07 ` Guenter Roeck
  2020-06-02 23:33   ` Serge Semin
  2020-06-03  0:07 ` [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused Serge Semin
  1 sibling, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2020-06-02 14:07 UTC (permalink / raw)
  To: Serge Semin
  Cc: Jean Delvare, Serge Semin, kbuild test robot, Maxim Kaurkin,
	Alexey Malahov, linux-hwmon, linux-kernel

On Tue, Jun 02, 2020 at 12:12:19PM +0300, Serge Semin wrote:
> Clang-based kernel building with W=1 warns that some static const
> variables are unused:
> 
> drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_temp_to_N = {
>                              ^
> drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_volt_to_N = {
>                              ^
> 
> Indeed these polynomials are utilized only when the PVT sensor alarms are
> enabled. In that case they are used to convert the temperature and
> voltage alarm limits from normal quantities (Volts and degree Celsius) to
> the sensor data representation N = [0, 1023]. Otherwise when alarms are
> disabled the driver only does the detected data conversion to the human
> readable form and doesn't need that polynomials defined. So let's declare
> the Temp-to-N and Volt-to-N polynomials only if the PVT alarms are
> switched on at compile-time.
> 
> Note gcc with W=1 doesn't notice the problem.
> 
> Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>

I don't really like the added #if. Can you use __maybe_unused instead ?

Thanks,
Guenter

> ---
>  drivers/hwmon/bt1-pvt.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
> index 1a9772fb1f73..1a5212c04549 100644
> --- a/drivers/hwmon/bt1-pvt.c
> +++ b/drivers/hwmon/bt1-pvt.c
> @@ -64,6 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
>   *     48380,
>   * where T = [-48380, 147438] mC and N = [0, 1023].
>   */
> +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
>  static const struct pvt_poly poly_temp_to_N = {
>  	.total_divider = 10000,
>  	.terms = {
> @@ -74,6 +75,7 @@ static const struct pvt_poly poly_temp_to_N = {
>  		{0, 1720400, 1, 1}
>  	}
>  };
> +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
>  
>  static const struct pvt_poly poly_N_to_temp = {
>  	.total_divider = 1,
> @@ -96,6 +98,7 @@ static const struct pvt_poly poly_N_to_temp = {
>   * N = (18658e-3*V - 11572) / 10,
>   * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
>   */
> +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
>  static const struct pvt_poly poly_volt_to_N = {
>  	.total_divider = 10,
>  	.terms = {
> @@ -103,6 +106,7 @@ static const struct pvt_poly poly_volt_to_N = {
>  		{0, -11572, 1, 1}
>  	}
>  };
> +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
>  
>  static const struct pvt_poly poly_N_to_volt = {
>  	.total_divider = 10,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled
  2020-06-02 14:07 ` Guenter Roeck
@ 2020-06-02 23:33   ` Serge Semin
  0 siblings, 0 replies; 5+ messages in thread
From: Serge Semin @ 2020-06-02 23:33 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Serge Semin, Jean Delvare, kbuild test robot, Maxim Kaurkin,
	Alexey Malahov, linux-hwmon, linux-kernel

On Tue, Jun 02, 2020 at 07:07:46AM -0700, Guenter Roeck wrote:
> On Tue, Jun 02, 2020 at 12:12:19PM +0300, Serge Semin wrote:
> > Clang-based kernel building with W=1 warns that some static const
> > variables are unused:
> > 
> > drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
> > static const struct pvt_poly poly_temp_to_N = {
> >                              ^
> > drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
> > static const struct pvt_poly poly_volt_to_N = {
> >                              ^
> > 
> > Indeed these polynomials are utilized only when the PVT sensor alarms are
> > enabled. In that case they are used to convert the temperature and
> > voltage alarm limits from normal quantities (Volts and degree Celsius) to
> > the sensor data representation N = [0, 1023]. Otherwise when alarms are
> > disabled the driver only does the detected data conversion to the human
> > readable form and doesn't need that polynomials defined. So let's declare
> > the Temp-to-N and Volt-to-N polynomials only if the PVT alarms are
> > switched on at compile-time.
> > 
> > Note gcc with W=1 doesn't notice the problem.
> > 
> > Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> > Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
> > Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> 

> I don't really like the added #if. Can you use __maybe_unused instead ?

Ok. __maybe_unused is much better. Thanks for suggestion.

-Sergey

> 
> Thanks,
> Guenter
> 
> > ---
> >  drivers/hwmon/bt1-pvt.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
> > index 1a9772fb1f73..1a5212c04549 100644
> > --- a/drivers/hwmon/bt1-pvt.c
> > +++ b/drivers/hwmon/bt1-pvt.c
> > @@ -64,6 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
> >   *     48380,
> >   * where T = [-48380, 147438] mC and N = [0, 1023].
> >   */
> > +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
> >  static const struct pvt_poly poly_temp_to_N = {
> >  	.total_divider = 10000,
> >  	.terms = {
> > @@ -74,6 +75,7 @@ static const struct pvt_poly poly_temp_to_N = {
> >  		{0, 1720400, 1, 1}
> >  	}
> >  };
> > +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
> >  
> >  static const struct pvt_poly poly_N_to_temp = {
> >  	.total_divider = 1,
> > @@ -96,6 +98,7 @@ static const struct pvt_poly poly_N_to_temp = {
> >   * N = (18658e-3*V - 11572) / 10,
> >   * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
> >   */
> > +#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
> >  static const struct pvt_poly poly_volt_to_N = {
> >  	.total_divider = 10,
> >  	.terms = {
> > @@ -103,6 +106,7 @@ static const struct pvt_poly poly_volt_to_N = {
> >  		{0, -11572, 1, 1}
> >  	}
> >  };
> > +#endif /* CONFIG_SENSORS_BT1_PVT_ALARMS */
> >  
> >  static const struct pvt_poly poly_N_to_volt = {
> >  	.total_divider = 10,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused
  2020-06-02  9:12 [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled Serge Semin
  2020-06-02 14:07 ` Guenter Roeck
@ 2020-06-03  0:07 ` Serge Semin
  2020-06-04 15:30   ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Serge Semin @ 2020-06-03  0:07 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck
  Cc: Serge Semin, Serge Semin, kbuild test robot, Maxim Kaurkin,
	Alexey Malahov, linux-hwmon, linux-kernel

Clang-based kernel building with W=1 warns that some static const
variables are unused:

drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
static const struct pvt_poly poly_temp_to_N = {
                             ^
drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
static const struct pvt_poly poly_volt_to_N = {
                             ^

Indeed these polynomials are utilized only when the PVT sensor alarms are
enabled. In that case they are used to convert the temperature and
voltage alarm limits from normal quantities (Volts and degree Celsius) to
the sensor data representation N = [0, 1023]. Otherwise when alarms are
disabled the driver only does the detected data conversion to the human
readable form and doesn't need that polynomials defined. So let's mark the
Temp-to-N and Volt-to-N polynomials with __maybe_unused attribute.

Note gcc with W=1 doesn't notice the problem.

Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>

---

Link: https://lore.kernel.org/linux-hwmon/20200602091219.24404-1-Sergey.Semin@baikalelectronics.ru
Changelog v2:
- Repalce if-defs with __maybe_unused attribute.
---
 drivers/hwmon/bt1-pvt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
index 1a9772fb1f73..8709b3f54086 100644
--- a/drivers/hwmon/bt1-pvt.c
+++ b/drivers/hwmon/bt1-pvt.c
@@ -64,7 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
  *     48380,
  * where T = [-48380, 147438] mC and N = [0, 1023].
  */
-static const struct pvt_poly poly_temp_to_N = {
+static const struct pvt_poly __maybe_unused poly_temp_to_N = {
 	.total_divider = 10000,
 	.terms = {
 		{4, 18322, 10000, 10000},
@@ -96,7 +96,7 @@ static const struct pvt_poly poly_N_to_temp = {
  * N = (18658e-3*V - 11572) / 10,
  * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
  */
-static const struct pvt_poly poly_volt_to_N = {
+static const struct pvt_poly __maybe_unused poly_volt_to_N = {
 	.total_divider = 10,
 	.terms = {
 		{1, 18658, 1000, 1},
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused
  2020-06-03  0:07 ` [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused Serge Semin
@ 2020-06-04 15:30   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2020-06-04 15:30 UTC (permalink / raw)
  To: Serge Semin
  Cc: Jean Delvare, Serge Semin, kbuild test robot, Maxim Kaurkin,
	Alexey Malahov, linux-hwmon, linux-kernel

On Wed, Jun 03, 2020 at 03:07:53AM +0300, Serge Semin wrote:
> Clang-based kernel building with W=1 warns that some static const
> variables are unused:
> 
> drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_temp_to_N = {
>                              ^
> drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]
> static const struct pvt_poly poly_volt_to_N = {
>                              ^
> 
> Indeed these polynomials are utilized only when the PVT sensor alarms are
> enabled. In that case they are used to convert the temperature and
> voltage alarm limits from normal quantities (Volts and degree Celsius) to
> the sensor data representation N = [0, 1023]. Otherwise when alarms are
> disabled the driver only does the detected data conversion to the human
> readable form and doesn't need that polynomials defined. So let's mark the
> Temp-to-N and Volt-to-N polynomials with __maybe_unused attribute.
> 
> Note gcc with W=1 doesn't notice the problem.
> 
> Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>

Applied.

Thanks,
Guenter

> ---
> 
> Link: https://lore.kernel.org/linux-hwmon/20200602091219.24404-1-Sergey.Semin@baikalelectronics.ru
> Changelog v2:
> - Repalce if-defs with __maybe_unused attribute.
> ---
>  drivers/hwmon/bt1-pvt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c
> index 1a9772fb1f73..8709b3f54086 100644
> --- a/drivers/hwmon/bt1-pvt.c
> +++ b/drivers/hwmon/bt1-pvt.c
> @@ -64,7 +64,7 @@ static const struct pvt_sensor_info pvt_info[] = {
>   *     48380,
>   * where T = [-48380, 147438] mC and N = [0, 1023].
>   */
> -static const struct pvt_poly poly_temp_to_N = {
> +static const struct pvt_poly __maybe_unused poly_temp_to_N = {
>  	.total_divider = 10000,
>  	.terms = {
>  		{4, 18322, 10000, 10000},
> @@ -96,7 +96,7 @@ static const struct pvt_poly poly_N_to_temp = {
>   * N = (18658e-3*V - 11572) / 10,
>   * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
>   */
> -static const struct pvt_poly poly_volt_to_N = {
> +static const struct pvt_poly __maybe_unused poly_volt_to_N = {
>  	.total_divider = 10,
>  	.terms = {
>  		{1, 18658, 1000, 1},

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-04 15:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  9:12 [PATCH] hwmon: bt1-pvt: Declare Temp- and Volt-to-N poly when alarms are enabled Serge Semin
2020-06-02 14:07 ` Guenter Roeck
2020-06-02 23:33   ` Serge Semin
2020-06-03  0:07 ` [PATCH v2] hwmon: bt1-pvt: Define Temp- and Volt-to-N poly as maybe-unused Serge Semin
2020-06-04 15:30   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).