- Drop the struct pci_dev.driver pointer, which is redundant with the
  struct device.driver pointer (Uwe Kleine-König)

* pci/driver:
  PCI: Remove struct pci_dev->driver
  PCI: Use to_pci_driver() instead of pci_dev->driver
  x86/pci/probe_roms: Use to_pci_driver() instead of pci_dev->driver
  perf/x86/intel/uncore: Use to_pci_driver() instead of pci_dev->driver
  powerpc/eeh: Use to_pci_driver() instead of pci_dev->driver
  usb: xhci: Use to_pci_driver() instead of pci_dev->driver
  cxl: Use to_pci_driver() instead of pci_dev->driver
  cxl: Factor out common dev->driver expressions
  xen/pcifront: Use to_pci_driver() instead of pci_dev->driver
  xen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv
  nfp: use dev_driver_string() instead of pci_dev->driver->name
  mlxsw: pci: Use dev_driver_string() instead of pci_dev->driver->name
  net: marvell: prestera: use dev_driver_string() instead of pci_dev->driver->name
  net: hns3: use dev_driver_string() instead of pci_dev->driver->name
  crypto: hisilicon - use dev_driver_string() instead of pci_dev->driver->name
  powerpc/eeh: Use dev_driver_string() instead of struct pci_dev->driver->name
  ssb: Use dev_driver_string() instead of pci_dev->driver->name
  bcma: simplify reference to driver name
  crypto: qat - simplify adf_enable_aer()
  scsi: message: fusion: Remove unused mpt_pci driver .probe() 'id' parameter
  PCI/ERR: Factor out common dev->driver expressions
  PCI: Drop pci_device_probe() test of !pci_dev->driver
  PCI: Drop pci_device_remove() test of pci_dev->driver
  PCI: Return NULL for to_pci_driver(NULL)
This commit is contained in:
Bjorn Helgaas 2021-11-05 11:28:43 -05:00
Родитель 1cac57a267 b5f9c644eb
Коммит d03c426f7a
31 изменённых файлов: 179 добавлений и 190 удалений

Просмотреть файл

@ -55,11 +55,6 @@ void eeh_pe_dev_mode_mark(struct eeh_pe *pe, int mode);
void eeh_sysfs_add_device(struct pci_dev *pdev); void eeh_sysfs_add_device(struct pci_dev *pdev);
void eeh_sysfs_remove_device(struct pci_dev *pdev); void eeh_sysfs_remove_device(struct pci_dev *pdev);
static inline const char *eeh_driver_name(struct pci_dev *pdev)
{
return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
}
#endif /* CONFIG_EEH */ #endif /* CONFIG_EEH */
#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff) #define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)

Просмотреть файл

@ -399,6 +399,14 @@ out:
return ret; return ret;
} }
static inline const char *eeh_driver_name(struct pci_dev *pdev)
{
if (pdev)
return dev_driver_string(&pdev->dev);
return "<null>";
}
/** /**
* eeh_dev_check_failure - Check if all 1's data is due to EEH slot freeze * eeh_dev_check_failure - Check if all 1's data is due to EEH slot freeze
* @edev: eeh device * @edev: eeh device

Просмотреть файл

@ -104,13 +104,13 @@ static bool eeh_edev_actionable(struct eeh_dev *edev)
*/ */
static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev) static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev)
{ {
if (!pdev || !pdev->driver) if (!pdev || !pdev->dev.driver)
return NULL; return NULL;
if (!try_module_get(pdev->driver->driver.owner)) if (!try_module_get(pdev->dev.driver->owner))
return NULL; return NULL;
return pdev->driver; return to_pci_driver(pdev->dev.driver);
} }
/** /**
@ -122,10 +122,10 @@ static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev)
*/ */
static inline void eeh_pcid_put(struct pci_dev *pdev) static inline void eeh_pcid_put(struct pci_dev *pdev)
{ {
if (!pdev || !pdev->driver) if (!pdev || !pdev->dev.driver)
return; return;
module_put(pdev->driver->driver.owner); module_put(pdev->dev.driver->owner);
} }
/** /**

Просмотреть файл

@ -1187,7 +1187,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
* PCI slot and func to indicate the uncore box. * PCI slot and func to indicate the uncore box.
*/ */
if (id->driver_data & ~0xffff) { if (id->driver_data & ~0xffff) {
struct pci_driver *pci_drv = pdev->driver; struct pci_driver *pci_drv = to_pci_driver(pdev->dev.driver);
pmu = uncore_pci_find_dev_pmu(pdev, pci_drv->id_table); pmu = uncore_pci_find_dev_pmu(pdev, pci_drv->id_table);
if (pmu == NULL) if (pmu == NULL)

Просмотреть файл

@ -80,7 +80,7 @@ static struct resource video_rom_resource = {
*/ */
static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device) static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device)
{ {
struct pci_driver *drv = pdev->driver; struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
const struct pci_device_id *id; const struct pci_device_id *id;
if (pdev->vendor == vendor && pdev->device == device) if (pdev->vendor == vendor && pdev->device == device)

Просмотреть файл

@ -162,7 +162,6 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
{ {
struct bcma_bus *bus; struct bcma_bus *bus;
int err = -ENOMEM; int err = -ENOMEM;
const char *name;
u32 val; u32 val;
/* Alloc */ /* Alloc */
@ -175,10 +174,7 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
if (err) if (err)
goto err_kfree_bus; goto err_kfree_bus;
name = dev_name(&dev->dev); err = pci_request_regions(dev, "bcma-pci-bridge");
if (dev->driver && dev->driver->name)
name = dev->driver->name;
err = pci_request_regions(dev, name);
if (err) if (err)
goto err_pci_disable; goto err_pci_disable;
pci_set_master(dev); pci_set_master(dev);

Просмотреть файл

@ -3085,7 +3085,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm)
}; };
int ret; int ret;
ret = strscpy(interface.name, pdev->driver->name, ret = strscpy(interface.name, dev_driver_string(&pdev->dev),
sizeof(interface.name)); sizeof(interface.name));
if (ret < 0) if (ret < 0)
return -ENAMETOOLONG; return -ENAMETOOLONG;

Просмотреть файл

@ -247,11 +247,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_master(pdev); pci_set_master(pdev);
if (adf_enable_aer(accel_dev)) { adf_enable_aer(accel_dev);
dev_err(&pdev->dev, "Failed to enable aer.\n");
ret = -EFAULT;
goto out_err;
}
if (pci_save_state(pdev)) { if (pci_save_state(pdev)) {
dev_err(&pdev->dev, "Failed to save pci state.\n"); dev_err(&pdev->dev, "Failed to save pci state.\n");
@ -304,6 +300,7 @@ static struct pci_driver adf_driver = {
.probe = adf_probe, .probe = adf_probe,
.remove = adf_remove, .remove = adf_remove,
.sriov_configure = adf_sriov_configure, .sriov_configure = adf_sriov_configure,
.err_handler = &adf_err_handler,
}; };
module_pci_driver(adf_driver); module_pci_driver(adf_driver);

Просмотреть файл

@ -33,6 +33,7 @@ static struct pci_driver adf_driver = {
.probe = adf_probe, .probe = adf_probe,
.remove = adf_remove, .remove = adf_remove,
.sriov_configure = adf_sriov_configure, .sriov_configure = adf_sriov_configure,
.err_handler = &adf_err_handler,
}; };
static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
pci_set_master(pdev); pci_set_master(pdev);
if (adf_enable_aer(accel_dev)) { adf_enable_aer(accel_dev);
dev_err(&pdev->dev, "Failed to enable aer\n");
ret = -EFAULT;
goto out_err_free_reg;
}
if (pci_save_state(pdev)) { if (pci_save_state(pdev)) {
dev_err(&pdev->dev, "Failed to save pci state\n"); dev_err(&pdev->dev, "Failed to save pci state\n");

Просмотреть файл

@ -33,6 +33,7 @@ static struct pci_driver adf_driver = {
.probe = adf_probe, .probe = adf_probe,
.remove = adf_remove, .remove = adf_remove,
.sriov_configure = adf_sriov_configure, .sriov_configure = adf_sriov_configure,
.err_handler = &adf_err_handler,
}; };
static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
pci_set_master(pdev); pci_set_master(pdev);
if (adf_enable_aer(accel_dev)) { adf_enable_aer(accel_dev);
dev_err(&pdev->dev, "Failed to enable aer\n");
ret = -EFAULT;
goto out_err_free_reg;
}
if (pci_save_state(pdev)) { if (pci_save_state(pdev)) {
dev_err(&pdev->dev, "Failed to save pci state\n"); dev_err(&pdev->dev, "Failed to save pci state\n");

Просмотреть файл

@ -166,11 +166,12 @@ static void adf_resume(struct pci_dev *pdev)
dev_info(&pdev->dev, "Device is up and running\n"); dev_info(&pdev->dev, "Device is up and running\n");
} }
static const struct pci_error_handlers adf_err_handler = { const struct pci_error_handlers adf_err_handler = {
.error_detected = adf_error_detected, .error_detected = adf_error_detected,
.slot_reset = adf_slot_reset, .slot_reset = adf_slot_reset,
.resume = adf_resume, .resume = adf_resume,
}; };
EXPORT_SYMBOL_GPL(adf_err_handler);
/** /**
* adf_enable_aer() - Enable Advance Error Reporting for acceleration device * adf_enable_aer() - Enable Advance Error Reporting for acceleration device
@ -179,17 +180,12 @@ static const struct pci_error_handlers adf_err_handler = {
* Function enables PCI Advance Error Reporting for the * Function enables PCI Advance Error Reporting for the
* QAT acceleration device accel_dev. * QAT acceleration device accel_dev.
* To be used by QAT device specific drivers. * To be used by QAT device specific drivers.
*
* Return: 0 on success, error code otherwise.
*/ */
int adf_enable_aer(struct adf_accel_dev *accel_dev) void adf_enable_aer(struct adf_accel_dev *accel_dev)
{ {
struct pci_dev *pdev = accel_to_pci_dev(accel_dev); struct pci_dev *pdev = accel_to_pci_dev(accel_dev);
struct pci_driver *pdrv = pdev->driver;
pdrv->err_handler = &adf_err_handler;
pci_enable_pcie_error_reporting(pdev); pci_enable_pcie_error_reporting(pdev);
return 0;
} }
EXPORT_SYMBOL_GPL(adf_enable_aer); EXPORT_SYMBOL_GPL(adf_enable_aer);

Просмотреть файл

@ -95,7 +95,8 @@ void adf_ae_fw_release(struct adf_accel_dev *accel_dev);
int adf_ae_start(struct adf_accel_dev *accel_dev); int adf_ae_start(struct adf_accel_dev *accel_dev);
int adf_ae_stop(struct adf_accel_dev *accel_dev); int adf_ae_stop(struct adf_accel_dev *accel_dev);
int adf_enable_aer(struct adf_accel_dev *accel_dev); extern const struct pci_error_handlers adf_err_handler;
void adf_enable_aer(struct adf_accel_dev *accel_dev);
void adf_disable_aer(struct adf_accel_dev *accel_dev); void adf_disable_aer(struct adf_accel_dev *accel_dev);
void adf_reset_sbr(struct adf_accel_dev *accel_dev); void adf_reset_sbr(struct adf_accel_dev *accel_dev);
void adf_reset_flr(struct adf_accel_dev *accel_dev); void adf_reset_flr(struct adf_accel_dev *accel_dev);

Просмотреть файл

@ -33,6 +33,7 @@ static struct pci_driver adf_driver = {
.probe = adf_probe, .probe = adf_probe,
.remove = adf_remove, .remove = adf_remove,
.sriov_configure = adf_sriov_configure, .sriov_configure = adf_sriov_configure,
.err_handler = &adf_err_handler,
}; };
static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev) static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
@ -192,11 +193,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
pci_set_master(pdev); pci_set_master(pdev);
if (adf_enable_aer(accel_dev)) { adf_enable_aer(accel_dev);
dev_err(&pdev->dev, "Failed to enable aer\n");
ret = -EFAULT;
goto out_err_free_reg;
}
if (pci_save_state(pdev)) { if (pci_save_state(pdev)) {
dev_err(&pdev->dev, "Failed to save pci state\n"); dev_err(&pdev->dev, "Failed to save pci state\n");

Просмотреть файл

@ -829,7 +829,6 @@ int
mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx) mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx)
{ {
MPT_ADAPTER *ioc; MPT_ADAPTER *ioc;
const struct pci_device_id *id;
if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
return -EINVAL; return -EINVAL;
@ -838,10 +837,8 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx)
/* call per pci device probe entry point */ /* call per pci device probe entry point */
list_for_each_entry(ioc, &ioc_list, list) { list_for_each_entry(ioc, &ioc_list, list) {
id = ioc->pcidev->driver ?
ioc->pcidev->driver->id_table : NULL;
if (dd_cbfunc->probe) if (dd_cbfunc->probe)
dd_cbfunc->probe(ioc->pcidev, id); dd_cbfunc->probe(ioc->pcidev);
} }
return 0; return 0;
@ -2032,7 +2029,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) { for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
if(MptDeviceDriverHandlers[cb_idx] && if(MptDeviceDriverHandlers[cb_idx] &&
MptDeviceDriverHandlers[cb_idx]->probe) { MptDeviceDriverHandlers[cb_idx]->probe) {
MptDeviceDriverHandlers[cb_idx]->probe(pdev,id); MptDeviceDriverHandlers[cb_idx]->probe(pdev);
} }
} }

Просмотреть файл

@ -257,7 +257,7 @@ typedef enum {
} MPT_DRIVER_CLASS; } MPT_DRIVER_CLASS;
struct mpt_pci_driver{ struct mpt_pci_driver{
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); int (*probe) (struct pci_dev *dev);
void (*remove) (struct pci_dev *dev); void (*remove) (struct pci_dev *dev);
}; };

Просмотреть файл

@ -114,7 +114,7 @@ static int mptctl_do_reset(MPT_ADAPTER *iocp, unsigned long arg);
static int mptctl_hp_hostinfo(MPT_ADAPTER *iocp, unsigned long arg, unsigned int cmd); static int mptctl_hp_hostinfo(MPT_ADAPTER *iocp, unsigned long arg, unsigned int cmd);
static int mptctl_hp_targetinfo(MPT_ADAPTER *iocp, unsigned long arg); static int mptctl_hp_targetinfo(MPT_ADAPTER *iocp, unsigned long arg);
static int mptctl_probe(struct pci_dev *, const struct pci_device_id *); static int mptctl_probe(struct pci_dev *);
static void mptctl_remove(struct pci_dev *); static void mptctl_remove(struct pci_dev *);
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
@ -2838,7 +2838,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a
*/ */
static int static int
mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) mptctl_probe(struct pci_dev *pdev)
{ {
MPT_ADAPTER *ioc = pci_get_drvdata(pdev); MPT_ADAPTER *ioc = pci_get_drvdata(pdev);

Просмотреть файл

@ -1377,7 +1377,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
} }
static int static int
mptlan_probe(struct pci_dev *pdev, const struct pci_device_id *id) mptlan_probe(struct pci_dev *pdev)
{ {
MPT_ADAPTER *ioc = pci_get_drvdata(pdev); MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
struct net_device *dev; struct net_device *dev;

Просмотреть файл

@ -20,33 +20,37 @@ static void pci_error_handlers(struct cxl_afu *afu,
pci_channel_state_t state) pci_channel_state_t state)
{ {
struct pci_dev *afu_dev; struct pci_dev *afu_dev;
struct pci_driver *afu_drv;
const struct pci_error_handlers *err_handler;
if (afu->phb == NULL) if (afu->phb == NULL)
return; return;
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
if (!afu_dev->driver) afu_drv = to_pci_driver(afu_dev->dev.driver);
if (!afu_drv)
continue; continue;
err_handler = afu_drv->err_handler;
switch (bus_error_event) { switch (bus_error_event) {
case CXL_ERROR_DETECTED_EVENT: case CXL_ERROR_DETECTED_EVENT:
afu_dev->error_state = state; afu_dev->error_state = state;
if (afu_dev->driver->err_handler && if (err_handler &&
afu_dev->driver->err_handler->error_detected) err_handler->error_detected)
afu_dev->driver->err_handler->error_detected(afu_dev, state); err_handler->error_detected(afu_dev, state);
break; break;
case CXL_SLOT_RESET_EVENT: case CXL_SLOT_RESET_EVENT:
afu_dev->error_state = state; afu_dev->error_state = state;
if (afu_dev->driver->err_handler && if (err_handler &&
afu_dev->driver->err_handler->slot_reset) err_handler->slot_reset)
afu_dev->driver->err_handler->slot_reset(afu_dev); err_handler->slot_reset(afu_dev);
break; break;
case CXL_RESUME_EVENT: case CXL_RESUME_EVENT:
if (afu_dev->driver->err_handler && if (err_handler &&
afu_dev->driver->err_handler->resume) err_handler->resume)
afu_dev->driver->err_handler->resume(afu_dev); err_handler->resume(afu_dev);
break; break;
} }
} }

Просмотреть файл

@ -1795,6 +1795,8 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
pci_channel_state_t state) pci_channel_state_t state)
{ {
struct pci_dev *afu_dev; struct pci_dev *afu_dev;
struct pci_driver *afu_drv;
const struct pci_error_handlers *err_handler;
pci_ers_result_t result = PCI_ERS_RESULT_NEED_RESET; pci_ers_result_t result = PCI_ERS_RESULT_NEED_RESET;
pci_ers_result_t afu_result = PCI_ERS_RESULT_NEED_RESET; pci_ers_result_t afu_result = PCI_ERS_RESULT_NEED_RESET;
@ -1805,13 +1807,15 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
return result; return result;
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
if (!afu_dev->driver) afu_drv = to_pci_driver(afu_dev->dev.driver);
if (!afu_drv)
continue; continue;
afu_dev->error_state = state; afu_dev->error_state = state;
if (afu_dev->driver->err_handler) err_handler = afu_drv->err_handler;
afu_result = afu_dev->driver->err_handler->error_detected(afu_dev, if (err_handler)
afu_result = err_handler->error_detected(afu_dev,
state); state);
/* Disconnect trumps all, NONE trumps NEED_RESET */ /* Disconnect trumps all, NONE trumps NEED_RESET */
if (afu_result == PCI_ERS_RESULT_DISCONNECT) if (afu_result == PCI_ERS_RESULT_DISCONNECT)
@ -1972,6 +1976,8 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
struct cxl_afu *afu; struct cxl_afu *afu;
struct cxl_context *ctx; struct cxl_context *ctx;
struct pci_dev *afu_dev; struct pci_dev *afu_dev;
struct pci_driver *afu_drv;
const struct pci_error_handlers *err_handler;
pci_ers_result_t afu_result = PCI_ERS_RESULT_RECOVERED; pci_ers_result_t afu_result = PCI_ERS_RESULT_RECOVERED;
pci_ers_result_t result = PCI_ERS_RESULT_RECOVERED; pci_ers_result_t result = PCI_ERS_RESULT_RECOVERED;
int i; int i;
@ -2028,12 +2034,13 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
* shouldn't start new work until we call * shouldn't start new work until we call
* their resume function. * their resume function.
*/ */
if (!afu_dev->driver) afu_drv = to_pci_driver(afu_dev->dev.driver);
if (!afu_drv)
continue; continue;
if (afu_dev->driver->err_handler && err_handler = afu_drv->err_handler;
afu_dev->driver->err_handler->slot_reset) if (err_handler && err_handler->slot_reset)
afu_result = afu_dev->driver->err_handler->slot_reset(afu_dev); afu_result = err_handler->slot_reset(afu_dev);
if (afu_result == PCI_ERS_RESULT_DISCONNECT) if (afu_result == PCI_ERS_RESULT_DISCONNECT)
result = PCI_ERS_RESULT_DISCONNECT; result = PCI_ERS_RESULT_DISCONNECT;
@ -2060,6 +2067,8 @@ static void cxl_pci_resume(struct pci_dev *pdev)
struct cxl *adapter = pci_get_drvdata(pdev); struct cxl *adapter = pci_get_drvdata(pdev);
struct cxl_afu *afu; struct cxl_afu *afu;
struct pci_dev *afu_dev; struct pci_dev *afu_dev;
struct pci_driver *afu_drv;
const struct pci_error_handlers *err_handler;
int i; int i;
/* Everything is back now. Drivers should restart work now. /* Everything is back now. Drivers should restart work now.
@ -2074,9 +2083,13 @@ static void cxl_pci_resume(struct pci_dev *pdev)
continue; continue;
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) { list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
if (afu_dev->driver && afu_dev->driver->err_handler && afu_drv = to_pci_driver(afu_dev->dev.driver);
afu_dev->driver->err_handler->resume) if (!afu_drv)
afu_dev->driver->err_handler->resume(afu_dev); continue;
err_handler = afu_drv->err_handler;
if (err_handler && err_handler->resume)
err_handler->resume(afu_dev);
} }
} }
spin_unlock(&adapter->afu_list_lock); spin_unlock(&adapter->afu_list_lock);

Просмотреть файл

@ -606,7 +606,7 @@ static void hns3_get_drvinfo(struct net_device *netdev,
return; return;
} }
strncpy(drvinfo->driver, h->pdev->driver->name, strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
sizeof(drvinfo->driver)); sizeof(drvinfo->driver));
drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';

Просмотреть файл

@ -720,7 +720,7 @@ out_release:
static int prestera_pci_probe(struct pci_dev *pdev, static int prestera_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
const char *driver_name = pdev->driver->name; const char *driver_name = dev_driver_string(&pdev->dev);
struct prestera_fw *fw; struct prestera_fw *fw;
int err; int err;

Просмотреть файл

@ -1876,7 +1876,7 @@ static void mlxsw_pci_cmd_fini(struct mlxsw_pci *mlxsw_pci)
static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{ {
const char *driver_name = pdev->driver->name; const char *driver_name = dev_driver_string(&pdev->dev);
struct mlxsw_pci *mlxsw_pci; struct mlxsw_pci *mlxsw_pci;
int err; int err;

Просмотреть файл

@ -202,7 +202,8 @@ nfp_get_drvinfo(struct nfp_app *app, struct pci_dev *pdev,
{ {
char nsp_version[ETHTOOL_FWVERS_LEN] = {}; char nsp_version[ETHTOOL_FWVERS_LEN] = {};
strlcpy(drvinfo->driver, pdev->driver->name, sizeof(drvinfo->driver)); strlcpy(drvinfo->driver, dev_driver_string(&pdev->dev),
sizeof(drvinfo->driver));
nfp_net_get_nspinfo(app, nsp_version); nfp_net_get_nspinfo(app, nsp_version);
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
"%s %s %s %s", vnic_version, nsp_version, "%s %s %s %s", vnic_version, nsp_version,

Просмотреть файл

@ -164,13 +164,15 @@ static ssize_t sriov_vf_total_msix_show(struct device *dev,
char *buf) char *buf)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct pci_driver *pdrv;
u32 vf_total_msix = 0; u32 vf_total_msix = 0;
device_lock(dev); device_lock(dev);
if (!pdev->driver || !pdev->driver->sriov_get_vf_total_msix) pdrv = to_pci_driver(dev->driver);
if (!pdrv || !pdrv->sriov_get_vf_total_msix)
goto unlock; goto unlock;
vf_total_msix = pdev->driver->sriov_get_vf_total_msix(pdev); vf_total_msix = pdrv->sriov_get_vf_total_msix(pdev);
unlock: unlock:
device_unlock(dev); device_unlock(dev);
return sysfs_emit(buf, "%u\n", vf_total_msix); return sysfs_emit(buf, "%u\n", vf_total_msix);
@ -183,6 +185,7 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev,
{ {
struct pci_dev *vf_dev = to_pci_dev(dev); struct pci_dev *vf_dev = to_pci_dev(dev);
struct pci_dev *pdev = pci_physfn(vf_dev); struct pci_dev *pdev = pci_physfn(vf_dev);
struct pci_driver *pdrv;
int val, ret; int val, ret;
ret = kstrtoint(buf, 0, &val); ret = kstrtoint(buf, 0, &val);
@ -193,13 +196,14 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev,
return -EINVAL; return -EINVAL;
device_lock(&pdev->dev); device_lock(&pdev->dev);
if (!pdev->driver || !pdev->driver->sriov_set_msix_vec_count) { pdrv = to_pci_driver(dev->driver);
if (!pdrv || !pdrv->sriov_set_msix_vec_count) {
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto err_pdev; goto err_pdev;
} }
device_lock(&vf_dev->dev); device_lock(&vf_dev->dev);
if (vf_dev->driver) { if (to_pci_driver(vf_dev->dev.driver)) {
/* /*
* A driver is already attached to this VF and has configured * A driver is already attached to this VF and has configured
* itself based on the current MSI-X vector count. Changing * itself based on the current MSI-X vector count. Changing
@ -209,7 +213,7 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev,
goto err_dev; goto err_dev;
} }
ret = pdev->driver->sriov_set_msix_vec_count(vf_dev, val); ret = pdrv->sriov_set_msix_vec_count(vf_dev, val);
err_dev: err_dev:
device_unlock(&vf_dev->dev); device_unlock(&vf_dev->dev);
@ -376,6 +380,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct pci_driver *pdrv;
int ret; int ret;
u16 num_vfs; u16 num_vfs;
@ -392,14 +397,15 @@ static ssize_t sriov_numvfs_store(struct device *dev,
goto exit; goto exit;
/* is PF driver loaded */ /* is PF driver loaded */
if (!pdev->driver) { pdrv = to_pci_driver(dev->driver);
if (!pdrv) {
pci_info(pdev, "no driver bound to device; cannot configure SR-IOV\n"); pci_info(pdev, "no driver bound to device; cannot configure SR-IOV\n");
ret = -ENOENT; ret = -ENOENT;
goto exit; goto exit;
} }
/* is PF driver loaded w/callback */ /* is PF driver loaded w/callback */
if (!pdev->driver->sriov_configure) { if (!pdrv->sriov_configure) {
pci_info(pdev, "driver does not support SR-IOV configuration via sysfs\n"); pci_info(pdev, "driver does not support SR-IOV configuration via sysfs\n");
ret = -ENOENT; ret = -ENOENT;
goto exit; goto exit;
@ -407,7 +413,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
if (num_vfs == 0) { if (num_vfs == 0) {
/* disable VFs */ /* disable VFs */
ret = pdev->driver->sriov_configure(pdev, 0); ret = pdrv->sriov_configure(pdev, 0);
goto exit; goto exit;
} }
@ -419,7 +425,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
goto exit; goto exit;
} }
ret = pdev->driver->sriov_configure(pdev, num_vfs); ret = pdrv->sriov_configure(pdev, num_vfs);
if (ret < 0) if (ret < 0)
goto exit; goto exit;

Просмотреть файл

@ -319,12 +319,10 @@ static long local_pci_probe(void *_ddi)
* its remove routine. * its remove routine.
*/ */
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
pci_dev->driver = pci_drv;
rc = pci_drv->probe(pci_dev, ddi->id); rc = pci_drv->probe(pci_dev, ddi->id);
if (!rc) if (!rc)
return rc; return rc;
if (rc < 0) { if (rc < 0) {
pci_dev->driver = NULL;
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
return rc; return rc;
} }
@ -390,14 +388,13 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
* @pci_dev: PCI device being probed * @pci_dev: PCI device being probed
* *
* returns 0 on success, else error. * returns 0 on success, else error.
* side-effect: pci_dev->driver is set to drv when drv claims pci_dev.
*/ */
static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
{ {
const struct pci_device_id *id; const struct pci_device_id *id;
int error = 0; int error = 0;
if (!pci_dev->driver && drv->probe) { if (drv->probe) {
error = -ENODEV; error = -ENODEV;
id = pci_match_device(drv, pci_dev); id = pci_match_device(drv, pci_dev);
@ -457,18 +454,15 @@ static int pci_device_probe(struct device *dev)
static void pci_device_remove(struct device *dev) static void pci_device_remove(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
struct pci_driver *drv = pci_dev->driver; struct pci_driver *drv = to_pci_driver(dev->driver);
if (drv) {
if (drv->remove) { if (drv->remove) {
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
drv->remove(pci_dev); drv->remove(pci_dev);
pm_runtime_put_noidle(dev); pm_runtime_put_noidle(dev);
} }
pcibios_free_irq(pci_dev); pcibios_free_irq(pci_dev);
pci_dev->driver = NULL;
pci_iov_remove(pci_dev); pci_iov_remove(pci_dev);
}
/* Undo the runtime PM settings in local_pci_probe() */ /* Undo the runtime PM settings in local_pci_probe() */
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
@ -495,7 +489,7 @@ static void pci_device_remove(struct device *dev)
static void pci_device_shutdown(struct device *dev) static void pci_device_shutdown(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
struct pci_driver *drv = pci_dev->driver; struct pci_driver *drv = to_pci_driver(dev->driver);
pm_runtime_resume(dev); pm_runtime_resume(dev);
@ -591,7 +585,7 @@ static int pci_pm_reenable_device(struct pci_dev *pci_dev)
static int pci_legacy_suspend(struct device *dev, pm_message_t state) static int pci_legacy_suspend(struct device *dev, pm_message_t state)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
struct pci_driver *drv = pci_dev->driver; struct pci_driver *drv = to_pci_driver(dev->driver);
if (drv && drv->suspend) { if (drv && drv->suspend) {
pci_power_t prev = pci_dev->current_state; pci_power_t prev = pci_dev->current_state;
@ -632,7 +626,7 @@ static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
static int pci_legacy_resume(struct device *dev) static int pci_legacy_resume(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_dev *pci_dev = to_pci_dev(dev);
struct pci_driver *drv = pci_dev->driver; struct pci_driver *drv = to_pci_driver(dev->driver);
pci_fixup_device(pci_fixup_resume, pci_dev); pci_fixup_device(pci_fixup_resume, pci_dev);
@ -651,7 +645,7 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev)
static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
{ {
struct pci_driver *drv = pci_dev->driver; struct pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
bool ret = drv && (drv->suspend || drv->resume); bool ret = drv && (drv->suspend || drv->resume);
/* /*
@ -1244,11 +1238,11 @@ static int pci_pm_runtime_suspend(struct device *dev)
int error; int error;
/* /*
* If pci_dev->driver is not set (unbound), we leave the device in D0, * If the device has no driver, we leave it in D0, but it may go to
* but it may go to D3cold when the bridge above it runtime suspends. * D3cold when the bridge above it runtime suspends. Save its
* Save its config space in case that happens. * config space in case that happens.
*/ */
if (!pci_dev->driver) { if (!to_pci_driver(dev->driver)) {
pci_save_state(pci_dev); pci_save_state(pci_dev);
return 0; return 0;
} }
@ -1305,7 +1299,7 @@ static int pci_pm_runtime_resume(struct device *dev)
*/ */
pci_restore_standard_config(pci_dev); pci_restore_standard_config(pci_dev);
if (!pci_dev->driver) if (!to_pci_driver(dev->driver))
return 0; return 0;
pci_fixup_device(pci_fixup_resume_early, pci_dev); pci_fixup_device(pci_fixup_resume_early, pci_dev);
@ -1324,14 +1318,13 @@ static int pci_pm_runtime_resume(struct device *dev)
static int pci_pm_runtime_idle(struct device *dev) static int pci_pm_runtime_idle(struct device *dev)
{ {
struct pci_dev *pci_dev = to_pci_dev(dev);
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
/* /*
* If pci_dev->driver is not set (unbound), the device should * If the device has no driver, it should always remain in D0
* always remain in D0 regardless of the runtime PM status * regardless of the runtime PM status
*/ */
if (!pci_dev->driver) if (!to_pci_driver(dev->driver))
return 0; return 0;
if (!pm) if (!pm)
@ -1438,8 +1431,10 @@ static struct pci_driver pci_compat_driver = {
*/ */
struct pci_driver *pci_dev_driver(const struct pci_dev *dev) struct pci_driver *pci_dev_driver(const struct pci_dev *dev)
{ {
if (dev->driver) struct pci_driver *drv = to_pci_driver(dev->dev.driver);
return dev->driver;
if (drv)
return drv;
else { else {
int i; int i;
for (i = 0; i <= PCI_ROM_RESOURCE; i++) for (i = 0; i <= PCI_ROM_RESOURCE; i++)

Просмотреть файл

@ -5121,13 +5121,14 @@ EXPORT_SYMBOL_GPL(pci_dev_unlock);
static void pci_dev_save_and_disable(struct pci_dev *dev) static void pci_dev_save_and_disable(struct pci_dev *dev)
{ {
struct pci_driver *drv = to_pci_driver(dev->dev.driver);
const struct pci_error_handlers *err_handler = const struct pci_error_handlers *err_handler =
dev->driver ? dev->driver->err_handler : NULL; drv ? drv->err_handler : NULL;
/* /*
* dev->driver->err_handler->reset_prepare() is protected against * drv->err_handler->reset_prepare() is protected against races
* races with ->remove() by the device lock, which must be held by * with ->remove() by the device lock, which must be held by the
* the caller. * caller.
*/ */
if (err_handler && err_handler->reset_prepare) if (err_handler && err_handler->reset_prepare)
err_handler->reset_prepare(dev); err_handler->reset_prepare(dev);
@ -5152,15 +5153,15 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
static void pci_dev_restore(struct pci_dev *dev) static void pci_dev_restore(struct pci_dev *dev)
{ {
struct pci_driver *drv = to_pci_driver(dev->dev.driver);
const struct pci_error_handlers *err_handler = const struct pci_error_handlers *err_handler =
dev->driver ? dev->driver->err_handler : NULL; drv ? drv->err_handler : NULL;
pci_restore_state(dev); pci_restore_state(dev);
/* /*
* dev->driver->err_handler->reset_done() is protected against * drv->err_handler->reset_done() is protected against races with
* races with ->remove() by the device lock, which must be held by * ->remove() by the device lock, which must be held by the caller.
* the caller.
*/ */
if (err_handler && err_handler->reset_done) if (err_handler && err_handler->reset_done)
err_handler->reset_done(dev); err_handler->reset_done(dev);

Просмотреть файл

@ -49,14 +49,16 @@ static int report_error_detected(struct pci_dev *dev,
pci_channel_state_t state, pci_channel_state_t state,
enum pci_ers_result *result) enum pci_ers_result *result)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote; pci_ers_result_t vote;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
pdrv = to_pci_driver(dev->dev.driver);
if (!pci_dev_set_io_state(dev, state) || if (!pci_dev_set_io_state(dev, state) ||
!dev->driver || !pdrv ||
!dev->driver->err_handler || !pdrv->err_handler ||
!dev->driver->err_handler->error_detected) { !pdrv->err_handler->error_detected) {
/* /*
* If any device in the subtree does not have an error_detected * If any device in the subtree does not have an error_detected
* callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent * callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent
@ -70,7 +72,7 @@ static int report_error_detected(struct pci_dev *dev,
vote = PCI_ERS_RESULT_NONE; vote = PCI_ERS_RESULT_NONE;
} }
} else { } else {
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->error_detected(dev, state); vote = err_handler->error_detected(dev, state);
} }
pci_uevent_ers(dev, vote); pci_uevent_ers(dev, vote);
@ -91,16 +93,18 @@ static int report_normal_detected(struct pci_dev *dev, void *data)
static int report_mmio_enabled(struct pci_dev *dev, void *data) static int report_mmio_enabled(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote, *result = data; pci_ers_result_t vote, *result = data;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
if (!dev->driver || pdrv = to_pci_driver(dev->dev.driver);
!dev->driver->err_handler || if (!pdrv ||
!dev->driver->err_handler->mmio_enabled) !pdrv->err_handler ||
!pdrv->err_handler->mmio_enabled)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->mmio_enabled(dev); vote = err_handler->mmio_enabled(dev);
*result = merge_result(*result, vote); *result = merge_result(*result, vote);
out: out:
@ -110,16 +114,18 @@ out:
static int report_slot_reset(struct pci_dev *dev, void *data) static int report_slot_reset(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
pci_ers_result_t vote, *result = data; pci_ers_result_t vote, *result = data;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
if (!dev->driver || pdrv = to_pci_driver(dev->dev.driver);
!dev->driver->err_handler || if (!pdrv ||
!dev->driver->err_handler->slot_reset) !pdrv->err_handler ||
!pdrv->err_handler->slot_reset)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
vote = err_handler->slot_reset(dev); vote = err_handler->slot_reset(dev);
*result = merge_result(*result, vote); *result = merge_result(*result, vote);
out: out:
@ -129,16 +135,18 @@ out:
static int report_resume(struct pci_dev *dev, void *data) static int report_resume(struct pci_dev *dev, void *data)
{ {
struct pci_driver *pdrv;
const struct pci_error_handlers *err_handler; const struct pci_error_handlers *err_handler;
device_lock(&dev->dev); device_lock(&dev->dev);
pdrv = to_pci_driver(dev->dev.driver);
if (!pci_dev_set_io_state(dev, pci_channel_io_normal) || if (!pci_dev_set_io_state(dev, pci_channel_io_normal) ||
!dev->driver || !pdrv ||
!dev->driver->err_handler || !pdrv->err_handler ||
!dev->driver->err_handler->resume) !pdrv->err_handler->resume)
goto out; goto out;
err_handler = dev->driver->err_handler; err_handler = pdrv->err_handler;
err_handler->resume(dev); err_handler->resume(dev);
out: out:
pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED); pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED);

Просмотреть файл

@ -588,61 +588,43 @@ static pci_ers_result_t pcifront_common_process(int cmd,
struct pcifront_device *pdev, struct pcifront_device *pdev,
pci_channel_state_t state) pci_channel_state_t state)
{ {
pci_ers_result_t result;
struct pci_driver *pdrv; struct pci_driver *pdrv;
int bus = pdev->sh_info->aer_op.bus; int bus = pdev->sh_info->aer_op.bus;
int devfn = pdev->sh_info->aer_op.devfn; int devfn = pdev->sh_info->aer_op.devfn;
int domain = pdev->sh_info->aer_op.domain; int domain = pdev->sh_info->aer_op.domain;
struct pci_dev *pcidev; struct pci_dev *pcidev;
int flag = 0;
dev_dbg(&pdev->xdev->dev, dev_dbg(&pdev->xdev->dev,
"pcifront AER process: cmd %x (bus:%x, devfn%x)", "pcifront AER process: cmd %x (bus:%x, devfn%x)",
cmd, bus, devfn); cmd, bus, devfn);
result = PCI_ERS_RESULT_NONE;
pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn); pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn);
if (!pcidev || !pcidev->driver) { if (!pcidev || !pcidev->dev.driver) {
dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n"); dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
pci_dev_put(pcidev); pci_dev_put(pcidev);
return result; return PCI_ERS_RESULT_NONE;
} }
pdrv = pcidev->driver; pdrv = to_pci_driver(pcidev->dev.driver);
if (pdrv) {
if (pdrv->err_handler && pdrv->err_handler->error_detected) { if (pdrv->err_handler && pdrv->err_handler->error_detected) {
pci_dbg(pcidev, "trying to call AER service\n"); pci_dbg(pcidev, "trying to call AER service\n");
if (pcidev) {
flag = 1;
switch (cmd) { switch (cmd) {
case XEN_PCI_OP_aer_detected: case XEN_PCI_OP_aer_detected:
result = pdrv->err_handler-> return pdrv->err_handler->error_detected(pcidev, state);
error_detected(pcidev, state);
break;
case XEN_PCI_OP_aer_mmio: case XEN_PCI_OP_aer_mmio:
result = pdrv->err_handler-> return pdrv->err_handler->mmio_enabled(pcidev);
mmio_enabled(pcidev);
break;
case XEN_PCI_OP_aer_slotreset: case XEN_PCI_OP_aer_slotreset:
result = pdrv->err_handler-> return pdrv->err_handler->slot_reset(pcidev);
slot_reset(pcidev);
break;
case XEN_PCI_OP_aer_resume: case XEN_PCI_OP_aer_resume:
pdrv->err_handler->resume(pcidev); pdrv->err_handler->resume(pcidev);
break; return PCI_ERS_RESULT_NONE;
default: default:
dev_err(&pdev->xdev->dev, dev_err(&pdev->xdev->dev,
"bad request in aer recovery " "bad request in aer recovery operation!\n");
"operation!\n"); }
}
} return PCI_ERS_RESULT_NONE;
}
}
}
if (!flag)
result = PCI_ERS_RESULT_NONE;
return result;
} }

Просмотреть файл

@ -69,7 +69,6 @@ static int ssb_pcihost_probe(struct pci_dev *dev,
{ {
struct ssb_bus *ssb; struct ssb_bus *ssb;
int err = -ENOMEM; int err = -ENOMEM;
const char *name;
u32 val; u32 val;
ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
@ -78,10 +77,7 @@ static int ssb_pcihost_probe(struct pci_dev *dev,
err = pci_enable_device(dev); err = pci_enable_device(dev);
if (err) if (err)
goto err_kfree_ssb; goto err_kfree_ssb;
name = dev_name(&dev->dev); err = pci_request_regions(dev, dev_driver_string(&dev->dev));
if (dev->driver && dev->driver->name)
name = dev->driver->name;
err = pci_request_regions(dev, name);
if (err) if (err)
goto err_pci_disable; goto err_pci_disable;
pci_set_master(dev); pci_set_master(dev);

Просмотреть файл

@ -103,7 +103,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
struct xhci_driver_data *driver_data; struct xhci_driver_data *driver_data;
const struct pci_device_id *id; const struct pci_device_id *id;
id = pci_match_id(pdev->driver->id_table, pdev); id = pci_match_id(to_pci_driver(pdev->dev.driver)->id_table, pdev);
if (id && id->driver_data) { if (id && id->driver_data) {
driver_data = (struct xhci_driver_data *)id->driver_data; driver_data = (struct xhci_driver_data *)id->driver_data;

Просмотреть файл

@ -342,7 +342,6 @@ struct pci_dev {
u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */ u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */
unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */
struct pci_driver *driver; /* Driver bound to this device */
u64 dma_mask; /* Mask of the bits of bus address this u64 dma_mask; /* Mask of the bits of bus address this
device implements. Normally this is device implements. Normally this is
0xffffffff. You only need to change 0xffffffff. You only need to change
@ -900,7 +899,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