LKML Archive on
help / color / mirror / Atom feed
* pci_driver resume() callback return value
@ 2007-01-08 19:55 Dmitriy Monakhov
  2007-01-12 10:38 ` Pavel Machek
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitriy Monakhov @ 2007-01-08 19:55 UTC (permalink / raw)
  To: linux-kernel

While investigating pci driver model i've found strange thing.
struct pci_driver has resume() callback and it declarated like follows
int  (*resume) (struct pci_dev *dev);/* Device woken up */
Documentation states about it:
from Documentation/pci-error-recovery.txt
STEP 5: Resume Operations
The platform will call the resume() callback on all affected device
drivers if all drivers on the segment have returned
PCI_ERS_RESULT_RECOVERED from one of the 3 previous callbacks.
The goal of this callback is to tell the driver to restart activity,
that everything is back and running.
This callback does not return a result code.
But most of pci devices may return correct error code if error happens
during resume(), for example e1000 implement it as follows:
static int e1000_resume(struct pci_dev *pdev)
	struct net_device *netdev = pci_get_drvdata(pdev);
	struct e1000_adapter *adapter = netdev_priv(netdev);
	uint32_t err;
	if ((err = pci_enable_device(pdev))) {
           printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
           return err;
Even generic pci routines may return nonzero err code and upper(but_type) level
routunes properly handles it:
from drivers/pci/pci-driver.c:321
static int pci_device_resume(struct device * dev)
	int error;
	struct pci_dev * pci_dev = to_pci_dev(dev);
	struct pci_driver * drv = pci_dev->driver;

	if (drv && drv->resume)
		error = drv->resume(pci_dev);
		error = pci_default_resume(pci_dev);
	return error;

Now question. Should we,or should we not return error code from resume callback?
Where a two possible ways:
a) Comment in document section is out of date and we have to properly handle 
   and return error code if something goes wrong.
b) Comment in document section is correct and and dont have to worry about any 
error, and return code  from resume() callback.
As i understand (a) is correct answer.

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

end of thread, other threads:[~2007-01-12 11:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-08 19:55 pci_driver resume() callback return value Dmitriy Monakhov
2007-01-12 10:38 ` Pavel Machek

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