[55/57] staging: comedi: drivers: ni_mio_common: Move 'range_ni_E_ao_ext' to where it is used
diff mbox series

Message ID 20210414181129.1628598-56-lee.jones@linaro.org
State New, archived
Headers show
Series
  • Rid W=1 warnings from Staging
Related show

Commit Message

Lee Jones April 14, 2021, 6:11 p.m. UTC
... and mark it as __maybe_unused since not all users of the
header file reference it.

Fixes the following W=1 kernel build warning(s):

 drivers/staging/comedi/drivers/ni_mio_common.c:163:35: warning: ‘range_ni_E_ao_ext’ defined but not used [-Wunused-const-variable=]

Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: "David A. Schleef" <ds@schleef.org>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Cc: Truxton Fulton <trux@truxton.com>
Cc: linux-staging@lists.linux.dev
Cc: linux-pwm@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 9 ---------
 drivers/staging/comedi/drivers/ni_stc.h        | 9 ++++++++-
 2 files changed, 8 insertions(+), 10 deletions(-)

Comments

Uwe Kleine-König April 15, 2021, 6:55 a.m. UTC | #1
Hello Lee,

nitpick: You move range_ni_E_ao_ext to the header. However that header
doesn't use range_ni_E_ao_ext, so the subject is technically wrong.

On Wed, Apr 14, 2021 at 07:11:27PM +0100, Lee Jones wrote:
> ... and mark it as __maybe_unused since not all users of the
> header file reference it.
> 
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/staging/comedi/drivers/ni_mio_common.c:163:35: warning: ‘range_ni_E_ao_ext’ defined but not used [-Wunused-const-variable=]
> 
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: "David A. Schleef" <ds@schleef.org>
> Cc: Mori Hess <fmhess@users.sourceforge.net>
> Cc: Truxton Fulton <trux@truxton.com>
> Cc: linux-staging@lists.linux.dev
> Cc: linux-pwm@vger.kernel.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/staging/comedi/drivers/ni_mio_common.c | 9 ---------
>  drivers/staging/comedi/drivers/ni_stc.h        | 9 ++++++++-
>  2 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
> index 4f80a4991f953..37615b4e2c10d 100644
> --- a/drivers/staging/comedi/drivers/ni_mio_common.c
> +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
> @@ -160,15 +160,6 @@ static const struct comedi_lrange range_ni_M_ai_628x = {
>  	}
>  };
>  
> -static const struct comedi_lrange range_ni_E_ao_ext = {
> -	4, {
> -		BIP_RANGE(10),
> -		UNI_RANGE(10),
> -		RANGE_ext(-1, 1),
> -		RANGE_ext(0, 1)
> -	}
> -};
> -
>  static const struct comedi_lrange *const ni_range_lkup[] = {
>  	[ai_gain_16] = &range_ni_E_ai,
>  	[ai_gain_8] = &range_ni_E_ai_limited,
> diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
> index fbc0b753a0f59..0822e65f709dd 100644
> --- a/drivers/staging/comedi/drivers/ni_stc.h
> +++ b/drivers/staging/comedi/drivers/ni_stc.h
> @@ -1137,6 +1137,13 @@ struct ni_private {
>  	u8 rgout0_usage;
>  };
>  
> -static const struct comedi_lrange range_ni_E_ao_ext;
> +static const struct comedi_lrange __maybe_unused range_ni_E_ao_ext = {
> +	4, {
> +		BIP_RANGE(10),
> +		UNI_RANGE(10),
> +		RANGE_ext(-1, 1),
> +		RANGE_ext(0, 1)
> +	}
> +};

I think a downside of this solution is that range_ni_E_ao_ext might be
duplicated in the object files. (Ditto for the status quo BTW.)

I think the right approach to fix the compiler warning and the
duplication is to declare range_ni_E_ao_ext external in the header and
keep the definition in ni_mio_common.c.

Best regards
Uwe
Lee Jones April 15, 2021, 8:34 a.m. UTC | #2
On Thu, 15 Apr 2021, Uwe Kleine-König wrote:

> Hello Lee,
> 
> nitpick: You move range_ni_E_ao_ext to the header. However that header
> doesn't use range_ni_E_ao_ext, so the subject is technically wrong.

It's implicitly used by the users of the header.

But I know what you mean.

I'll see if I can make the subject line a little more clear.

> On Wed, Apr 14, 2021 at 07:11:27PM +0100, Lee Jones wrote:
> > ... and mark it as __maybe_unused since not all users of the
> > header file reference it.
> > 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/staging/comedi/drivers/ni_mio_common.c:163:35: warning: ‘range_ni_E_ao_ext’ defined but not used [-Wunused-const-variable=]
> > 
> > Cc: Ian Abbott <abbotti@mev.co.uk>
> > Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Cc: "David A. Schleef" <ds@schleef.org>
> > Cc: Mori Hess <fmhess@users.sourceforge.net>
> > Cc: Truxton Fulton <trux@truxton.com>
> > Cc: linux-staging@lists.linux.dev
> > Cc: linux-pwm@vger.kernel.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/staging/comedi/drivers/ni_mio_common.c | 9 ---------
> >  drivers/staging/comedi/drivers/ni_stc.h        | 9 ++++++++-
> >  2 files changed, 8 insertions(+), 10 deletions(-)
Ian Abbott April 15, 2021, 9:39 a.m. UTC | #3
On 14/04/2021 19:11, Lee Jones wrote:
> ... and mark it as __maybe_unused since not all users of the
> header file reference it.
> 
> Fixes the following W=1 kernel build warning(s):
> 
>   drivers/staging/comedi/drivers/ni_mio_common.c:163:35: warning: ‘range_ni_E_ao_ext’ defined but not used [-Wunused-const-variable=]
> 
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: "David A. Schleef" <ds@schleef.org>
> Cc: Mori Hess <fmhess@users.sourceforge.net>
> Cc: Truxton Fulton <trux@truxton.com>
> Cc: linux-staging@lists.linux.dev
> Cc: linux-pwm@vger.kernel.org
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>   drivers/staging/comedi/drivers/ni_mio_common.c | 9 ---------
>   drivers/staging/comedi/drivers/ni_stc.h        | 9 ++++++++-
>   2 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
> index 4f80a4991f953..37615b4e2c10d 100644
> --- a/drivers/staging/comedi/drivers/ni_mio_common.c
> +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
> @@ -160,15 +160,6 @@ static const struct comedi_lrange range_ni_M_ai_628x = {
>   	}
>   };
>   
> -static const struct comedi_lrange range_ni_E_ao_ext = {
> -	4, {
> -		BIP_RANGE(10),
> -		UNI_RANGE(10),
> -		RANGE_ext(-1, 1),
> -		RANGE_ext(0, 1)
> -	}
> -};
> -
>   static const struct comedi_lrange *const ni_range_lkup[] = {
>   	[ai_gain_16] = &range_ni_E_ai,
>   	[ai_gain_8] = &range_ni_E_ai_limited,
> diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
> index fbc0b753a0f59..0822e65f709dd 100644
> --- a/drivers/staging/comedi/drivers/ni_stc.h
> +++ b/drivers/staging/comedi/drivers/ni_stc.h
> @@ -1137,6 +1137,13 @@ struct ni_private {
>   	u8 rgout0_usage;
>   };
>   
> -static const struct comedi_lrange range_ni_E_ao_ext;
> +static const struct comedi_lrange __maybe_unused range_ni_E_ao_ext = {
> +	4, {
> +		BIP_RANGE(10),
> +		UNI_RANGE(10),
> +		RANGE_ext(-1, 1),
> +		RANGE_ext(0, 1)
> +	}
> +};
>   
>   #endif /* _COMEDI_NI_STC_H */
> 

I think it is better where it is for now with its fellow struct 
comedi_lrange variables, but feel free to mark it as __maybe_unused.

(Really, the #include "ni_mio_common.c" mess needs sorting out sometime.)
Lee Jones April 15, 2021, 9:54 a.m. UTC | #4
On Thu, 15 Apr 2021, Ian Abbott wrote:

> On 14/04/2021 19:11, Lee Jones wrote:
> > ... and mark it as __maybe_unused since not all users of the
> > header file reference it.
> > 
> > Fixes the following W=1 kernel build warning(s):
> > 
> >   drivers/staging/comedi/drivers/ni_mio_common.c:163:35: warning: ‘range_ni_E_ao_ext’ defined but not used [-Wunused-const-variable=]
> > 
> > Cc: Ian Abbott <abbotti@mev.co.uk>
> > Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Cc: "David A. Schleef" <ds@schleef.org>
> > Cc: Mori Hess <fmhess@users.sourceforge.net>
> > Cc: Truxton Fulton <trux@truxton.com>
> > Cc: linux-staging@lists.linux.dev
> > Cc: linux-pwm@vger.kernel.org
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >   drivers/staging/comedi/drivers/ni_mio_common.c | 9 ---------
> >   drivers/staging/comedi/drivers/ni_stc.h        | 9 ++++++++-
> >   2 files changed, 8 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
> > index 4f80a4991f953..37615b4e2c10d 100644
> > --- a/drivers/staging/comedi/drivers/ni_mio_common.c
> > +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
> > @@ -160,15 +160,6 @@ static const struct comedi_lrange range_ni_M_ai_628x = {
> >   	}
> >   };
> > -static const struct comedi_lrange range_ni_E_ao_ext = {
> > -	4, {
> > -		BIP_RANGE(10),
> > -		UNI_RANGE(10),
> > -		RANGE_ext(-1, 1),
> > -		RANGE_ext(0, 1)
> > -	}
> > -};
> > -
> >   static const struct comedi_lrange *const ni_range_lkup[] = {
> >   	[ai_gain_16] = &range_ni_E_ai,
> >   	[ai_gain_8] = &range_ni_E_ai_limited,
> > diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
> > index fbc0b753a0f59..0822e65f709dd 100644
> > --- a/drivers/staging/comedi/drivers/ni_stc.h
> > +++ b/drivers/staging/comedi/drivers/ni_stc.h
> > @@ -1137,6 +1137,13 @@ struct ni_private {
> >   	u8 rgout0_usage;
> >   };
> > -static const struct comedi_lrange range_ni_E_ao_ext;
> > +static const struct comedi_lrange __maybe_unused range_ni_E_ao_ext = {
> > +	4, {
> > +		BIP_RANGE(10),
> > +		UNI_RANGE(10),
> > +		RANGE_ext(-1, 1),
> > +		RANGE_ext(0, 1)
> > +	}
> > +};
> >   #endif /* _COMEDI_NI_STC_H */
> > 
> 
> I think it is better where it is for now with its fellow struct
> comedi_lrange variables, but feel free to mark it as __maybe_unused.

Can do.  Will fix.

> (Really, the #include "ni_mio_common.c" mess needs sorting out sometime.)

Patch
diff mbox series

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index 4f80a4991f953..37615b4e2c10d 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -160,15 +160,6 @@  static const struct comedi_lrange range_ni_M_ai_628x = {
 	}
 };
 
-static const struct comedi_lrange range_ni_E_ao_ext = {
-	4, {
-		BIP_RANGE(10),
-		UNI_RANGE(10),
-		RANGE_ext(-1, 1),
-		RANGE_ext(0, 1)
-	}
-};
-
 static const struct comedi_lrange *const ni_range_lkup[] = {
 	[ai_gain_16] = &range_ni_E_ai,
 	[ai_gain_8] = &range_ni_E_ai_limited,
diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
index fbc0b753a0f59..0822e65f709dd 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -1137,6 +1137,13 @@  struct ni_private {
 	u8 rgout0_usage;
 };
 
-static const struct comedi_lrange range_ni_E_ao_ext;
+static const struct comedi_lrange __maybe_unused range_ni_E_ao_ext = {
+	4, {
+		BIP_RANGE(10),
+		UNI_RANGE(10),
+		RANGE_ext(-1, 1),
+		RANGE_ext(0, 1)
+	}
+};
 
 #endif /* _COMEDI_NI_STC_H */