Commit 8e9028b3 authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: Return NULL for to_pci_driver(NULL)

to_pci_driver() takes a pointer to a struct device_driver and uses
container_of() to find the struct pci_driver that contains it.

If given a NULL pointer to a struct device_driver, return a NULL pci_driver
pointer instead of applying container_of() to NULL.

This simplifies callers that would otherwise have to check for a NULL
pointer first.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent e4e737bb
...@@ -900,7 +900,10 @@ struct pci_driver { ...@@ -900,7 +900,10 @@ struct pci_driver {
struct pci_dynids dynids; struct pci_dynids dynids;
}; };
#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) static inline struct pci_driver *to_pci_driver(struct device_driver *drv)
{
return drv ? container_of(drv, struct pci_driver, driver) : NULL;
}
/** /**
* PCI_DEVICE - macro used to describe a specific PCI device * PCI_DEVICE - macro used to describe a specific PCI device
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment