netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CONFIG_PM=n slim: drivers/net/*
@ 2006-08-12  0:46 Alexey Dobriyan
  2006-08-12  1:49 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey Dobriyan @ 2006-08-12  0:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Garzik, netdev

Compile out dead code for CONFIG_PM=n users.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 drivers/net/amd8111e.c |   10 +++++++++-
 drivers/net/b44.c      |    4 ++++
 drivers/net/bnx2.c     |    4 ++++
 drivers/net/tg3.c      |    4 ++++
 4 files changed, 21 insertions(+), 1 deletion(-)

--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1769,6 +1769,8 @@ static void amd8111e_vlan_rx_kill_vid(st
 	spin_unlock_irq(&lp->lock);
 }
 #endif
+
+#ifdef CONFIG_PM
 static int amd8111e_enable_magicpkt(struct amd8111e_priv* lp)
 {
 	writel( VAL1|MPPLBA, lp->mmio + CMD3);
@@ -1789,6 +1791,8 @@ static int amd8111e_enable_link_change(s
 	readl(lp->mmio + CMD7);
 	return 0;
 }	
+#endif
+
 /* This function is called when a packet transmission fails to complete within a  resonable period, on the assumption that an interrupts have been failed or the  interface is locked up. This function will reinitialize the hardware */
 
 static void amd8111e_tx_timeout(struct net_device *dev)
@@ -1804,6 +1808,8 @@ static void amd8111e_tx_timeout(struct n
 	if(!err)
 		netif_wake_queue(dev);
 }
+
+#ifdef CONFIG_PM
 static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state)
 {	
 	struct net_device *dev = pci_get_drvdata(pci_dev);
@@ -1873,7 +1879,7 @@ static int amd8111e_resume(struct pci_de
 
 	return 0;
 }
-
+#endif
 
 static void __devexit amd8111e_remove_one(struct pci_dev *pdev)
 {
@@ -2152,8 +2158,10 @@ static struct pci_driver amd8111e_driver
 	.id_table	= amd8111e_pci_tbl,
 	.probe		= amd8111e_probe_one,
 	.remove		= __devexit_p(amd8111e_remove_one),
+#ifdef CONFIG_PM
 	.suspend	= amd8111e_suspend,
 	.resume		= amd8111e_resume
+#endif
 };
 
 static int __init amd8111e_init(void)
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -2279,6 +2279,7 @@ static void __devexit b44_remove_one(str
 	pci_set_drvdata(pdev, NULL);
 }
 
+#ifdef CONFIG_PM
 static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
@@ -2336,14 +2337,17 @@ static int b44_resume(struct pci_dev *pd
 	netif_wake_queue(dev);
 	return 0;
 }
+#endif
 
 static struct pci_driver b44_driver = {
 	.name		= DRV_MODULE_NAME,
 	.id_table	= b44_pci_tbl,
 	.probe		= b44_init_one,
 	.remove		= __devexit_p(b44_remove_one),
+#ifdef CONFIG_PM
         .suspend        = b44_suspend,
         .resume         = b44_resume,
+#endif
 };
 
 static int __init b44_init(void)
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -5962,6 +5962,7 @@ bnx2_remove_one(struct pci_dev *pdev)
 	pci_set_drvdata(pdev, NULL);
 }
 
+#ifdef CONFIG_PM
 static int
 bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
 {
@@ -6003,14 +6004,17 @@ bnx2_resume(struct pci_dev *pdev)
 	bnx2_netif_start(bp);
 	return 0;
 }
+#endif
 
 static struct pci_driver bnx2_pci_driver = {
 	.name		= DRV_MODULE_NAME,
 	.id_table	= bnx2_pci_tbl,
 	.probe		= bnx2_init_one,
 	.remove		= __devexit_p(bnx2_remove_one),
+#ifdef CONFIG_PM
 	.suspend	= bnx2_suspend,
 	.resume		= bnx2_resume,
+#endif
 };
 
 static int __init bnx2_init(void)
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -11722,6 +11722,7 @@ static void __devexit tg3_remove_one(str
 	}
 }
 
+#ifdef CONFIG_PM
 static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
@@ -11802,14 +11803,17 @@ out:
 
 	return err;
 }
+#endif
 
 static struct pci_driver tg3_driver = {
 	.name		= DRV_MODULE_NAME,
 	.id_table	= tg3_pci_tbl,
 	.probe		= tg3_init_one,
 	.remove		= __devexit_p(tg3_remove_one),
+#ifdef CONFIG_PM
 	.suspend	= tg3_suspend,
 	.resume		= tg3_resume
+#endif
 };
 
 static int __init tg3_init(void)


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

* Re: [PATCH] CONFIG_PM=n slim: drivers/net/*
  2006-08-12  0:46 [PATCH] CONFIG_PM=n slim: drivers/net/* Alexey Dobriyan
@ 2006-08-12  1:49 ` Andrew Morton
  2006-08-12  2:30   ` Alexey Dobriyan
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-08-12  1:49 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Jeff Garzik, netdev

On Sat, 12 Aug 2006 04:46:23 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:

> +#ifdef CONFIG_PM
>  static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state)
>  {	
>  	struct net_device *dev = pci_get_drvdata(pci_dev);
> @@ -1873,7 +1879,7 @@ static int amd8111e_resume(struct pci_de
>  
>  	return 0;
>  }
> -
> +#endif
>  
>  static void __devexit amd8111e_remove_one(struct pci_dev *pdev)
>  {
> @@ -2152,8 +2158,10 @@ static struct pci_driver amd8111e_driver
>  	.id_table	= amd8111e_pci_tbl,
>  	.probe		= amd8111e_probe_one,
>  	.remove		= __devexit_p(amd8111e_remove_one),
> +#ifdef CONFIG_PM
>  	.suspend	= amd8111e_suspend,
>  	.resume		= amd8111e_resume
> +#endif
>  };

The preferred way is

#ifdef CONFIG_PM
static int amd8111e_suspend(...)
{
}
#else
#define amd8111e_suspend NULL
#define amd8111e_resume NULL
#endif

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

* Re: [PATCH] CONFIG_PM=n slim: drivers/net/*
  2006-08-12  1:49 ` Andrew Morton
@ 2006-08-12  2:30   ` Alexey Dobriyan
  2006-08-12  2:49     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey Dobriyan @ 2006-08-12  2:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Garzik, netdev

On Fri, Aug 11, 2006 at 06:49:43PM -0700, Andrew Morton wrote:
> On Sat, 12 Aug 2006 04:46:23 +0400
> Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> > +#ifdef CONFIG_PM
> >  static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state)
> >  {
> >  	struct net_device *dev = pci_get_drvdata(pci_dev);
> > @@ -1873,7 +1879,7 @@ static int amd8111e_resume(struct pci_de
> >
> >  	return 0;
> >  }
> > -
> > +#endif
> >
> >  static void __devexit amd8111e_remove_one(struct pci_dev *pdev)
> >  {
> > @@ -2152,8 +2158,10 @@ static struct pci_driver amd8111e_driver
> >  	.id_table	= amd8111e_pci_tbl,
> >  	.probe		= amd8111e_probe_one,
> >  	.remove		= __devexit_p(amd8111e_remove_one),
> > +#ifdef CONFIG_PM
> >  	.suspend	= amd8111e_suspend,
> >  	.resume		= amd8111e_resume
> > +#endif
> >  };
>
> The preferred way is
>
> #ifdef CONFIG_PM
> static int amd8111e_suspend(...)
> {
> }
> #else
> #define amd8111e_suspend NULL
> #define amd8111e_resume NULL
> #endif

Plenty of drivers already use first variant. Also this won't allow

	struct pci_driver {
		...
	#ifdef CONFIG_PM
		int (*suspend)(...);
		int (*resume)(...);
	#endif
		...
	};

which is good for a) space savings in CONFIG_PM=n case, and
b) making drivers care about CONFIG_PM=n users hard way aka compilation
failure.


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

* Re: [PATCH] CONFIG_PM=n slim: drivers/net/*
  2006-08-12  2:30   ` Alexey Dobriyan
@ 2006-08-12  2:49     ` Andrew Morton
  2006-08-12 17:06       ` Roland Dreier
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2006-08-12  2:49 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Jeff Garzik, netdev

On Sat, 12 Aug 2006 06:30:14 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:

> On Fri, Aug 11, 2006 at 06:49:43PM -0700, Andrew Morton wrote:
> > On Sat, 12 Aug 2006 04:46:23 +0400
> > Alexey Dobriyan <adobriyan@gmail.com> wrote:
> >
> > > +#ifdef CONFIG_PM
> > >  static int amd8111e_suspend(struct pci_dev *pci_dev, pm_message_t state)
> > >  {
> > >  	struct net_device *dev = pci_get_drvdata(pci_dev);
> > > @@ -1873,7 +1879,7 @@ static int amd8111e_resume(struct pci_de
> > >
> > >  	return 0;
> > >  }
> > > -
> > > +#endif
> > >
> > >  static void __devexit amd8111e_remove_one(struct pci_dev *pdev)
> > >  {
> > > @@ -2152,8 +2158,10 @@ static struct pci_driver amd8111e_driver
> > >  	.id_table	= amd8111e_pci_tbl,
> > >  	.probe		= amd8111e_probe_one,
> > >  	.remove		= __devexit_p(amd8111e_remove_one),
> > > +#ifdef CONFIG_PM
> > >  	.suspend	= amd8111e_suspend,
> > >  	.resume		= amd8111e_resume
> > > +#endif
> > >  };
> >
> > The preferred way is
> >
> > #ifdef CONFIG_PM
> > static int amd8111e_suspend(...)
> > {
> > }
> > #else
> > #define amd8111e_suspend NULL
> > #define amd8111e_resume NULL
> > #endif
> 
> Plenty of drivers already use first variant.

That can be fixed.

> Also this won't allow
> 
> 	struct pci_driver {
> 		...
> 	#ifdef CONFIG_PM
> 		int (*suspend)(...);
> 		int (*resume)(...);
> 	#endif
> 		...
> 	};
> 
> which is good for a) space savings in CONFIG_PM=n case, and
> b) making drivers care about CONFIG_PM=n users hard way aka compilation
> failure.

eh?  Both versions will generate identical code.

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

* Re: [PATCH] CONFIG_PM=n slim: drivers/net/*
  2006-08-12  2:49     ` Andrew Morton
@ 2006-08-12 17:06       ` Roland Dreier
  2006-08-12 18:39         ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2006-08-12 17:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Alexey Dobriyan, Jeff Garzik, netdev

 > > Also this won't allow
 > > 
 > > 	struct pci_driver {
 > > 		...
 > > 	#ifdef CONFIG_PM
 > > 		int (*suspend)(...);
 > > 		int (*resume)(...);
 > > 	#endif
 > > 		...
 > > 	};
 > > 
 > > which is good for a) space savings in CONFIG_PM=n case, and
 > > b) making drivers care about CONFIG_PM=n users hard way aka compilation
 > > failure.
 > 
 > eh?  Both versions will generate identical code.

I think his point was that by #ifdef-ing out the assignment to
.suspend/.resume, then the actual suspend/resume members of struct
pci_driver could be removed in the CONFIG_PM=n case -- which would
shrink sizeof (struct pci_driver).

 - R.

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

* Re: [PATCH] CONFIG_PM=n slim: drivers/net/*
  2006-08-12 17:06       ` Roland Dreier
@ 2006-08-12 18:39         ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2006-08-12 18:39 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Alexey Dobriyan, Jeff Garzik, netdev

On Sat, 12 Aug 2006 10:06:29 -0700
Roland Dreier <rdreier@cisco.com> wrote:

>  > > Also this won't allow
>  > > 
>  > > 	struct pci_driver {
>  > > 		...
>  > > 	#ifdef CONFIG_PM
>  > > 		int (*suspend)(...);
>  > > 		int (*resume)(...);
>  > > 	#endif
>  > > 		...
>  > > 	};
>  > > 
>  > > which is good for a) space savings in CONFIG_PM=n case, and
>  > > b) making drivers care about CONFIG_PM=n users hard way aka compilation
>  > > failure.
>  > 
>  > eh?  Both versions will generate identical code.
> 
> I think his point was that by #ifdef-ing out the assignment to
> .suspend/.resume, then the actual suspend/resume members of struct
> pci_driver could be removed in the CONFIG_PM=n case -- which would
> shrink sizeof (struct pci_driver).
> 

OIC.  Yes, that would be useful.

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

end of thread, other threads:[~2006-08-12 18:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-12  0:46 [PATCH] CONFIG_PM=n slim: drivers/net/* Alexey Dobriyan
2006-08-12  1:49 ` Andrew Morton
2006-08-12  2:30   ` Alexey Dobriyan
2006-08-12  2:49     ` Andrew Morton
2006-08-12 17:06       ` Roland Dreier
2006-08-12 18:39         ` Andrew Morton

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).