Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver(). This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/20211004125935.2300113-11-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Uwe Kleine-König and committed by
Bjorn Helgaas
16bd44e5 4e59b754

+4 -4
+1 -1
drivers/misc/cxl/guest.c
··· 27 27 return; 28 28 29 29 list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { 30 - afu_drv = afu_dev->driver; 30 + afu_drv = to_pci_driver(afu_dev->dev.driver); 31 31 if (!afu_drv) 32 32 continue; 33 33
+3 -3
drivers/misc/cxl/pci.c
··· 1807 1807 return result; 1808 1808 1809 1809 list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { 1810 - afu_drv = afu_dev->driver; 1810 + afu_drv = to_pci_driver(afu_dev->dev.driver); 1811 1811 if (!afu_drv) 1812 1812 continue; 1813 1813 ··· 2034 2034 * shouldn't start new work until we call 2035 2035 * their resume function. 2036 2036 */ 2037 - afu_drv = afu_dev->driver; 2037 + afu_drv = to_pci_driver(afu_dev->dev.driver); 2038 2038 if (!afu_drv) 2039 2039 continue; 2040 2040 ··· 2083 2083 continue; 2084 2084 2085 2085 list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { 2086 - afu_drv = afu_dev->driver; 2086 + afu_drv = to_pci_driver(afu_dev->dev.driver); 2087 2087 if (!afu_drv) 2088 2088 continue; 2089 2089