diff mbox

phy: SMSC: fix unused warnings when built into kernel

Message ID 1281076034-17390-1-git-send-email-vapier@gentoo.org
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Mike Frysinger Aug. 6, 2010, 6:27 a.m. UTC
If the SMSC phy is not built as a module, we get the warning:
	drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not used

So mark the structure as maybe unused to avoid this.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 drivers/net/phy/smsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Changli Gao Aug. 6, 2010, 6:43 a.m. UTC | #1
On Fri, Aug 6, 2010 at 2:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> If the SMSC phy is not built as a module, we get the warning:
>        drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not used
>
> So mark the structure as maybe unused to avoid this.
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
>  drivers/net/phy/smsc.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index 78fa988..11944ef 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -254,7 +254,7 @@ MODULE_LICENSE("GPL");
>  module_init(smsc_init);
>  module_exit(smsc_exit);
>
> -static struct mdio_device_id smsc_tbl[] = {
> +static __maybe_unused struct mdio_device_id smsc_tbl[] = {
>        { 0x0007c0a0, 0xfffffff0 },
>        { 0x0007c0b0, 0xfffffff0 },
>        { 0x0007c0c0, 0xfffffff0 },

How about adding a #ifdef CONFIG_SMSC_PHY_MODULE clause  around these lines?
Mike Frysinger Aug. 6, 2010, 7:37 a.m. UTC | #2
On Friday, August 06, 2010 02:43:46 Changli Gao wrote:
> On Fri, Aug 6, 2010 at 2:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > If the SMSC phy is not built as a module, we get the warning:
> >        drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not
> > used
> > 
> > So mark the structure as maybe unused to avoid this.
> > 
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > ---
> >  drivers/net/phy/smsc.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> > index 78fa988..11944ef 100644
> > --- a/drivers/net/phy/smsc.c
> > +++ b/drivers/net/phy/smsc.c
> > @@ -254,7 +254,7 @@ MODULE_LICENSE("GPL");
> >  module_init(smsc_init);
> >  module_exit(smsc_exit);
> > 
> > -static struct mdio_device_id smsc_tbl[] = {
> > +static __maybe_unused struct mdio_device_id smsc_tbl[] = {
> >        { 0x0007c0a0, 0xfffffff0 },
> >        { 0x0007c0b0, 0xfffffff0 },
> >        { 0x0007c0c0, 0xfffffff0 },
> 
> How about adding a #ifdef CONFIG_SMSC_PHY_MODULE clause  around these
> lines?
Mike Frysinger Aug. 6, 2010, 7:37 a.m. UTC | #3
On Friday, August 06, 2010 02:43:46 Changli Gao wrote:
> On Fri, Aug 6, 2010 at 2:27 PM, Mike Frysinger wrote:
> > If the SMSC phy is not built as a module, we get the warning:
> >        drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not
> > used
> > 
> > So mark the structure as maybe unused to avoid this.
> > 
> > --- a/drivers/net/phy/smsc.c
> > +++ b/drivers/net/phy/smsc.c
> > @@ -254,7 +254,7 @@ MODULE_LICENSE("GPL");
> >  module_init(smsc_init);
> >  module_exit(smsc_exit);
> > 
> > -static struct mdio_device_id smsc_tbl[] = {
> > +static __maybe_unused struct mdio_device_id smsc_tbl[] = {
> >        { 0x0007c0a0, 0xfffffff0 },
> >        { 0x0007c0b0, 0xfffffff0 },
> >        { 0x0007c0c0, 0xfffffff0 },
> 
> How about adding a #ifdef CONFIG_SMSC_PHY_MODULE clause  around these
> lines?

imo, the less ifdefs the better
-mike
Ben Hutchings Aug. 6, 2010, 12:57 p.m. UTC | #4
On Fri, 2010-08-06 at 14:43 +0800, Changli Gao wrote:
> On Fri, Aug 6, 2010 at 2:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > If the SMSC phy is not built as a module, we get the warning:
> >        drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not used
> >
> > So mark the structure as maybe unused to avoid this.
> >
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > ---
> >  drivers/net/phy/smsc.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> > index 78fa988..11944ef 100644
> > --- a/drivers/net/phy/smsc.c
> > +++ b/drivers/net/phy/smsc.c
> > @@ -254,7 +254,7 @@ MODULE_LICENSE("GPL");
> >  module_init(smsc_init);
> >  module_exit(smsc_exit);
> >
> > -static struct mdio_device_id smsc_tbl[] = {
> > +static __maybe_unused struct mdio_device_id smsc_tbl[] = {
> >        { 0x0007c0a0, 0xfffffff0 },
> >        { 0x0007c0b0, 0xfffffff0 },
> >        { 0x0007c0c0, 0xfffffff0 },
> 
> How about adding a #ifdef CONFIG_SMSC_PHY_MODULE clause  around these lines?

By default, gcc will discard unused variables and functions declared as
static.  So this would not provide any run-time benefit.

Ben.
David Miller Aug. 8, 2010, 6:08 a.m. UTC | #5
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Fri, 06 Aug 2010 13:57:15 +0100

> On Fri, 2010-08-06 at 14:43 +0800, Changli Gao wrote:
>> On Fri, Aug 6, 2010 at 2:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > If the SMSC phy is not built as a module, we get the warning:
>> >        drivers/net/phy/smsc.c:257: warning: 'smsc_tbl' defined but not used
>> >
>> > So mark the structure as maybe unused to avoid this.
>> >
>> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>> > ---
>> >  drivers/net/phy/smsc.c |    2 +-
>> >  1 files changed, 1 insertions(+), 1 deletions(-)
>> >
>> > diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
>> > index 78fa988..11944ef 100644
>> > --- a/drivers/net/phy/smsc.c
>> > +++ b/drivers/net/phy/smsc.c
>> > @@ -254,7 +254,7 @@ MODULE_LICENSE("GPL");
>> >  module_init(smsc_init);
>> >  module_exit(smsc_exit);
>> >
>> > -static struct mdio_device_id smsc_tbl[] = {
>> > +static __maybe_unused struct mdio_device_id smsc_tbl[] = {
>> >        { 0x0007c0a0, 0xfffffff0 },
>> >        { 0x0007c0b0, 0xfffffff0 },
>> >        { 0x0007c0c0, 0xfffffff0 },
>> 
>> How about adding a #ifdef CONFIG_SMSC_PHY_MODULE clause  around these lines?
> 
> By default, gcc will discard unused variables and functions declared as
> static.  So this would not provide any run-time benefit.

We never have to do this for any other module device table, because
usually the table is actually used for the probing.

The MDIO ones are special in that they are only used for assisting in
module probing.

I would suggest that, in light of this, we make MODULE_DEVICE_TABLE()
make a dummy reference to the table.

Otherwise we're likely going going to have to add these ugly tags to
every single PHY driver.

--
To unsubscribe from this list: send the line "unsubscribe netdev" 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/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 78fa988..11944ef 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -254,7 +254,7 @@  MODULE_LICENSE("GPL");
 module_init(smsc_init);
 module_exit(smsc_exit);
 
-static struct mdio_device_id smsc_tbl[] = {
+static __maybe_unused struct mdio_device_id smsc_tbl[] = {
 	{ 0x0007c0a0, 0xfffffff0 },
 	{ 0x0007c0b0, 0xfffffff0 },
 	{ 0x0007c0c0, 0xfffffff0 },