netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: nigel@nigel.suspend2.net
Cc: Pavel Machek <pavel@ucw.cz>, linux-pm <linux-pm@lists.osdl.org>,
	netdev@vger.kernel.org, Valerie Henson <val@nmt.edu>,
	Peer Chen <peer.chen@uli.com.tw>
Subject: Re: [RFC][PATCH] Add suspend and resume support to uli526x
Date: Mon, 4 Jun 2007 23:31:03 +0200	[thread overview]
Message-ID: <200706042331.03933.rjw@sisk.pl> (raw)
In-Reply-To: <1180991794.4356.31.camel@nigel.suspend2.net>

Hi,

On Monday, 4 June 2007 23:16, Nigel Cunningham wrote:
> Hi.
> 
> On Mon, 2007-06-04 at 15:49 +0200, Rafael J. Wysocki wrote:
> > On Monday, 4 June 2007 13:11, Pavel Machek wrote:
> > > > From: Rafael J. Wysocki <rjw@sisk.pl>
> > > > 
> > > > Add suspend/resume support to the uli526x network driver (tested on x86_64,
> > > > with 'Ethernet controller: ALi Corporation M5263 Ethernet Controller, rev 40').
> > > > 
> > > > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > > 
> > > Looks ok to me.
> > > 
> > > > +#ifdef CONFIG_PM
> > > > +
> > > > +/*
> > > > + *	Suspend the interface.
> > > > + */
> > > > +
> > > > +static int uli526x_suspend(struct pci_dev *pdev, pm_message_t state)
> > > > +{
> > > > +	struct net_device *dev = pci_get_drvdata(pdev);
> > > > +
> > > > +	ULI526X_DBUG(0, "uli526x_suspend", 0);
> > > > +
> > > > +	if (dev && netdev_priv(dev)) {
> > > > +		if (netif_running(dev)) {
> > > > +			netif_device_detach(dev);
> > > > +			uli526x_down(dev);
> > > > +		}
> > > > +		pci_save_state(pdev);
> > > > +		pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
> > > > +		pci_disable_device(pdev);
> > > > +		pci_set_power_state(pdev, pci_choose_state(pdev, state));
> > > > +	}
> > > > +	return 0;
> > > > +}
> > > > +
> > > > +/*
> > > > + *	Resume the interface.
> > > > + */
> > > > +
> > > > +static int uli526x_resume(struct pci_dev *pdev)
> > > > +{
> > > > +	struct net_device *dev = pci_get_drvdata(pdev);
> > > > +	struct uli526x_board_info *db = netdev_priv(dev);
> > > > +	int err;
> > > > +
> > > > +	ULI526X_DBUG(0, "uli526x_resume", 0);
> > > > +
> > > > +	if (dev && db) {
> > > > +		pci_set_power_state(pdev, PCI_D0);
> > > > +		err = pci_enable_device(pdev);
> > > > +		if (err) {
> > > > +			printk(KERN_WARNING "%s: Could not enable device \n",
> > > > +				dev->name);
> > > > +			return err;
> > > > +		}
> > > > +		pci_restore_state(pdev);
> > > > +		pci_set_master(pdev);
> > > > +		if (netif_running(dev)) {
> > > > +			uli526x_up(dev);
> > > > +			netif_device_attach(dev);
> > > > +		}
> > > > +	}
> > > > +	return 0;
> > > > +}
> > > > +
> > > #else 
> > > #define *_resume NULL
> > > #define *_suspend NULL
> > 
> > > > +#endif /* CONFIG_PM */
> > > 
> > > > @@ -1689,6 +1775,10 @@ static struct pci_driver uli526x_driver 
> > > >  	.id_table	= uli526x_pci_tbl,
> > > >  	.probe		= uli526x_init_one,
> > > >  	.remove		= __devexit_p(uli526x_remove_one),
> > > > +#ifdef CONFIG_PM
> > > > +	.suspend	= uli526x_suspend,
> > > > +	.resume		= uli526x_resume,
> > > > +#endif
> > > 
> > > ...so that this ifdef is not needed?
> > 
> > OK, why not.
> 
> Because it's uglier and #ifdef is the established way of doing things?

Hmm, I have no strong opinion.  I slightly prefer the #ifdef, but well.

Perhaps I'll send it to Andrew 'as is' if no one else has any more comments. ;-)

Greetings,
Rafael


-- 
"Premature optimization is the root of all evil." - Donald Knuth

  reply	other threads:[~2007-06-04 21:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-03 10:37 [RFC][PATCH] Add suspend and resume support to uli526x Rafael J. Wysocki
2007-06-04 11:11 ` Pavel Machek
2007-06-04 13:49   ` Rafael J. Wysocki
2007-06-04 21:16     ` Nigel Cunningham
2007-06-04 21:31       ` Rafael J. Wysocki [this message]
2007-06-04 22:41       ` Pavel Machek
2007-06-04 22:49         ` Nigel Cunningham
2007-06-04 22:53           ` Pavel Machek
2007-06-04 22:55             ` Nigel Cunningham
2007-06-05  5:56               ` Stephen Hemminger
2007-06-05  9:31                 ` Rafael J. Wysocki
2007-06-05  0:58 ` Valerie Henson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200706042331.03933.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-pm@lists.osdl.org \
    --cc=netdev@vger.kernel.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    --cc=peer.chen@uli.com.tw \
    --cc=val@nmt.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).