From: David Matlack <dmatlack@xxxxxxxxxx> Refactor PCI_SER_GET() to be more readable by storing the pointer to struct pci_dev_ser in an intermediate variable and adding a helper function to_pci_dev_ser(). Change pci_lu_adopt() to return a boolean since it is only used to check if a device has preserved state. Opportunistically fix the formatting on the static inline prototype of pci_liveupdate_reclaim_resource() as well. No functional change intended. Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx> Signed-off-by: Chris Li <chrisl@xxxxxxxxxx> --- drivers/pci/pci.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 7af32edb128faef9c5e2665ca5055374f7fd30ea..d092cea96dc22cca5d3526c720cfb8b330c47683 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1196,27 +1196,37 @@ static inline int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int inde PCI_CONF1_EXT_REG(reg)) #ifdef CONFIG_LIVEUPDATE -#define PCI_SER_GET(__pci_dev, __var, __def) \ - (__pci_dev->dev.lu.dev_state) ? \ - ((struct pci_dev_ser *)__pci_dev->dev.lu.dev_state)->__var : __def - void pci_liveupdate_restore(struct pci_dev *dev); void pci_liveupdate_override_driver(struct pci_dev *dev); -static inline struct pci_dev_ser *pci_lu_adopt(struct pci_dev *dev) +static inline struct pci_dev_ser *to_pci_dev_ser(struct pci_dev *dev) +{ + return dev->dev.lu.dev_state; +} +static inline bool pci_lu_adopt(struct pci_dev *dev) { - return dev->dev.lu.requested ? dev->dev.lu.dev_state : NULL; + return dev->dev.lu.requested && to_pci_dev_ser(dev); } int pci_liveupdate_reclaim_resource(struct pci_dev *dev); #else -#define PCI_SER_GET(__dev, __var, __def) __def - static inline void pci_liveupdate_restore(struct pci_dev *dev) {} static inline void pci_liveupdate_override_driver(struct pci_dev *dev) {} -static inline struct pci_dev_ser *pci_lu_adopt(struct pci_dev *dev) +static inline struct pci_dev_ser *to_pci_dev_ser(struct pci_dev *dev) { return NULL; } -static inline int pci_liveupdate_reclaim_resource( - struct pci_dev *dev) { return -ENXIO; } +static inline bool pci_lu_adopt(struct pci_dev *dev) +{ + return false; +} +static inline int pci_liveupdate_reclaim_resource(struct pci_dev *dev) +{ + return -ENXIO; +} #endif + +#define PCI_SER_GET(__pci_dev, __field, __default) ({ \ + struct pci_dev_ser *__ser = to_pci_dev_ser(__pci_dev); \ + \ + __ser ? __ser->__field : __default; \ +}) #endif /* DRIVERS_PCI_H */ -- 2.50.1.487.gc89ff58d15-goog