Merge branch 'pci/driver'
- 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:
Коммит
d03c426f7a
|
@ -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_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 */
|
||||
|
||||
#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)
|
||||
|
|
|
@ -399,6 +399,14 @@ out:
|
|||
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
|
||||
* @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)
|
||||
{
|
||||
if (!pdev || !pdev->driver)
|
||||
if (!pdev || !pdev->dev.driver)
|
||||
return NULL;
|
||||
|
||||
if (!try_module_get(pdev->driver->driver.owner))
|
||||
if (!try_module_get(pdev->dev.driver->owner))
|
||||
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)
|
||||
{
|
||||
if (!pdev || !pdev->driver)
|
||||
if (!pdev || !pdev->dev.driver)
|
||||
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.
|
||||
*/
|
||||
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);
|
||||
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)
|
||||
{
|
||||
struct pci_driver *drv = pdev->driver;
|
||||
struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
|
||||
const struct pci_device_id *id;
|
||||
|
||||
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;
|
||||
int err = -ENOMEM;
|
||||
const char *name;
|
||||
u32 val;
|
||||
|
||||
/* Alloc */
|
||||
|
@ -175,10 +174,7 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
|
|||
if (err)
|
||||
goto err_kfree_bus;
|
||||
|
||||
name = dev_name(&dev->dev);
|
||||
if (dev->driver && dev->driver->name)
|
||||
name = dev->driver->name;
|
||||
err = pci_request_regions(dev, name);
|
||||
err = pci_request_regions(dev, "bcma-pci-bridge");
|
||||
if (err)
|
||||
goto err_pci_disable;
|
||||
pci_set_master(dev);
|
||||
|
|
|
@ -3085,7 +3085,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm)
|
|||
};
|
||||
int ret;
|
||||
|
||||
ret = strscpy(interface.name, pdev->driver->name,
|
||||
ret = strscpy(interface.name, dev_driver_string(&pdev->dev),
|
||||
sizeof(interface.name));
|
||||
if (ret < 0)
|
||||
return -ENAMETOOLONG;
|
||||
|
|
|
@ -247,11 +247,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
|
||||
pci_set_master(pdev);
|
||||
|
||||
if (adf_enable_aer(accel_dev)) {
|
||||
dev_err(&pdev->dev, "Failed to enable aer.\n");
|
||||
ret = -EFAULT;
|
||||
goto out_err;
|
||||
}
|
||||
adf_enable_aer(accel_dev);
|
||||
|
||||
if (pci_save_state(pdev)) {
|
||||
dev_err(&pdev->dev, "Failed to save pci state.\n");
|
||||
|
@ -304,6 +300,7 @@ static struct pci_driver adf_driver = {
|
|||
.probe = adf_probe,
|
||||
.remove = adf_remove,
|
||||
.sriov_configure = adf_sriov_configure,
|
||||
.err_handler = &adf_err_handler,
|
||||
};
|
||||
|
||||
module_pci_driver(adf_driver);
|
||||
|
|
|
@ -33,6 +33,7 @@ static struct pci_driver adf_driver = {
|
|||
.probe = adf_probe,
|
||||
.remove = adf_remove,
|
||||
.sriov_configure = adf_sriov_configure,
|
||||
.err_handler = &adf_err_handler,
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
if (adf_enable_aer(accel_dev)) {
|
||||
dev_err(&pdev->dev, "Failed to enable aer\n");
|
||||
ret = -EFAULT;
|
||||
goto out_err_free_reg;
|
||||
}
|
||||
adf_enable_aer(accel_dev);
|
||||
|
||||
if (pci_save_state(pdev)) {
|
||||
dev_err(&pdev->dev, "Failed to save pci state\n");
|
||||
|
|
|
@ -33,6 +33,7 @@ static struct pci_driver adf_driver = {
|
|||
.probe = adf_probe,
|
||||
.remove = adf_remove,
|
||||
.sriov_configure = adf_sriov_configure,
|
||||
.err_handler = &adf_err_handler,
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
if (adf_enable_aer(accel_dev)) {
|
||||
dev_err(&pdev->dev, "Failed to enable aer\n");
|
||||
ret = -EFAULT;
|
||||
goto out_err_free_reg;
|
||||
}
|
||||
adf_enable_aer(accel_dev);
|
||||
|
||||
if (pci_save_state(pdev)) {
|
||||
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");
|
||||
}
|
||||
|
||||
static const struct pci_error_handlers adf_err_handler = {
|
||||
const struct pci_error_handlers adf_err_handler = {
|
||||
.error_detected = adf_error_detected,
|
||||
.slot_reset = adf_slot_reset,
|
||||
.resume = adf_resume,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(adf_err_handler);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* QAT acceleration device accel_dev.
|
||||
* 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_driver *pdrv = pdev->driver;
|
||||
|
||||
pdrv->err_handler = &adf_err_handler;
|
||||
pci_enable_pcie_error_reporting(pdev);
|
||||
return 0;
|
||||
}
|
||||
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_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_reset_sbr(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,
|
||||
.remove = adf_remove,
|
||||
.sriov_configure = adf_sriov_configure,
|
||||
.err_handler = &adf_err_handler,
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
if (adf_enable_aer(accel_dev)) {
|
||||
dev_err(&pdev->dev, "Failed to enable aer\n");
|
||||
ret = -EFAULT;
|
||||
goto out_err_free_reg;
|
||||
}
|
||||
adf_enable_aer(accel_dev);
|
||||
|
||||
if (pci_save_state(pdev)) {
|
||||
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_ADAPTER *ioc;
|
||||
const struct pci_device_id *id;
|
||||
|
||||
if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
|
||||
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 */
|
||||
list_for_each_entry(ioc, &ioc_list, list) {
|
||||
id = ioc->pcidev->driver ?
|
||||
ioc->pcidev->driver->id_table : NULL;
|
||||
if (dd_cbfunc->probe)
|
||||
dd_cbfunc->probe(ioc->pcidev, id);
|
||||
dd_cbfunc->probe(ioc->pcidev);
|
||||
}
|
||||
|
||||
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++) {
|
||||
if(MptDeviceDriverHandlers[cb_idx] &&
|
||||
MptDeviceDriverHandlers[cb_idx]->probe) {
|
||||
MptDeviceDriverHandlers[cb_idx]->probe(pdev,id);
|
||||
MptDeviceDriverHandlers[cb_idx]->probe(pdev);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ typedef enum {
|
|||
} MPT_DRIVER_CLASS;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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_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 *);
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
@ -2838,7 +2838,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a
|
|||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -1377,7 +1377,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
|
|||
}
|
||||
|
||||
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);
|
||||
struct net_device *dev;
|
||||
|
|
|
@ -20,33 +20,37 @@ static void pci_error_handlers(struct cxl_afu *afu,
|
|||
pci_channel_state_t state)
|
||||
{
|
||||
struct pci_dev *afu_dev;
|
||||
struct pci_driver *afu_drv;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
|
||||
if (afu->phb == NULL)
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
err_handler = afu_drv->err_handler;
|
||||
switch (bus_error_event) {
|
||||
case CXL_ERROR_DETECTED_EVENT:
|
||||
afu_dev->error_state = state;
|
||||
|
||||
if (afu_dev->driver->err_handler &&
|
||||
afu_dev->driver->err_handler->error_detected)
|
||||
afu_dev->driver->err_handler->error_detected(afu_dev, state);
|
||||
if (err_handler &&
|
||||
err_handler->error_detected)
|
||||
err_handler->error_detected(afu_dev, state);
|
||||
break;
|
||||
case CXL_SLOT_RESET_EVENT:
|
||||
afu_dev->error_state = state;
|
||||
|
||||
if (afu_dev->driver->err_handler &&
|
||||
afu_dev->driver->err_handler->slot_reset)
|
||||
afu_dev->driver->err_handler->slot_reset(afu_dev);
|
||||
if (err_handler &&
|
||||
err_handler->slot_reset)
|
||||
err_handler->slot_reset(afu_dev);
|
||||
break;
|
||||
case CXL_RESUME_EVENT:
|
||||
if (afu_dev->driver->err_handler &&
|
||||
afu_dev->driver->err_handler->resume)
|
||||
afu_dev->driver->err_handler->resume(afu_dev);
|
||||
if (err_handler &&
|
||||
err_handler->resume)
|
||||
err_handler->resume(afu_dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1795,6 +1795,8 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
|
|||
pci_channel_state_t state)
|
||||
{
|
||||
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 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;
|
||||
|
||||
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;
|
||||
|
||||
afu_dev->error_state = state;
|
||||
|
||||
if (afu_dev->driver->err_handler)
|
||||
afu_result = afu_dev->driver->err_handler->error_detected(afu_dev,
|
||||
err_handler = afu_drv->err_handler;
|
||||
if (err_handler)
|
||||
afu_result = err_handler->error_detected(afu_dev,
|
||||
state);
|
||||
/* Disconnect trumps all, NONE trumps NEED_RESET */
|
||||
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_context *ctx;
|
||||
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 result = PCI_ERS_RESULT_RECOVERED;
|
||||
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
|
||||
* their resume function.
|
||||
*/
|
||||
if (!afu_dev->driver)
|
||||
afu_drv = to_pci_driver(afu_dev->dev.driver);
|
||||
if (!afu_drv)
|
||||
continue;
|
||||
|
||||
if (afu_dev->driver->err_handler &&
|
||||
afu_dev->driver->err_handler->slot_reset)
|
||||
afu_result = afu_dev->driver->err_handler->slot_reset(afu_dev);
|
||||
err_handler = afu_drv->err_handler;
|
||||
if (err_handler && err_handler->slot_reset)
|
||||
afu_result = err_handler->slot_reset(afu_dev);
|
||||
|
||||
if (afu_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_afu *afu;
|
||||
struct pci_dev *afu_dev;
|
||||
struct pci_driver *afu_drv;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
int i;
|
||||
|
||||
/* Everything is back now. Drivers should restart work now.
|
||||
|
@ -2074,9 +2083,13 @@ static void cxl_pci_resume(struct pci_dev *pdev)
|
|||
continue;
|
||||
|
||||
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
|
||||
if (afu_dev->driver && afu_dev->driver->err_handler &&
|
||||
afu_dev->driver->err_handler->resume)
|
||||
afu_dev->driver->err_handler->resume(afu_dev);
|
||||
afu_drv = to_pci_driver(afu_dev->dev.driver);
|
||||
if (!afu_drv)
|
||||
continue;
|
||||
|
||||
err_handler = afu_drv->err_handler;
|
||||
if (err_handler && err_handler->resume)
|
||||
err_handler->resume(afu_dev);
|
||||
}
|
||||
}
|
||||
spin_unlock(&adapter->afu_list_lock);
|
||||
|
|
|
@ -606,7 +606,7 @@ static void hns3_get_drvinfo(struct net_device *netdev,
|
|||
return;
|
||||
}
|
||||
|
||||
strncpy(drvinfo->driver, h->pdev->driver->name,
|
||||
strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
|
||||
sizeof(drvinfo->driver));
|
||||
drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
|
||||
|
||||
|
|
|
@ -720,7 +720,7 @@ out_release:
|
|||
static int prestera_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 prestera_fw *fw;
|
||||
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)
|
||||
{
|
||||
const char *driver_name = pdev->driver->name;
|
||||
const char *driver_name = dev_driver_string(&pdev->dev);
|
||||
struct mlxsw_pci *mlxsw_pci;
|
||||
int err;
|
||||
|
||||
|
|
|
@ -202,7 +202,8 @@ nfp_get_drvinfo(struct nfp_app *app, struct pci_dev *pdev,
|
|||
{
|
||||
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);
|
||||
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_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)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct pci_driver *pdrv;
|
||||
u32 vf_total_msix = 0;
|
||||
|
||||
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;
|
||||
|
||||
vf_total_msix = pdev->driver->sriov_get_vf_total_msix(pdev);
|
||||
vf_total_msix = pdrv->sriov_get_vf_total_msix(pdev);
|
||||
unlock:
|
||||
device_unlock(dev);
|
||||
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 *pdev = pci_physfn(vf_dev);
|
||||
struct pci_driver *pdrv;
|
||||
int val, ret;
|
||||
|
||||
ret = kstrtoint(buf, 0, &val);
|
||||
|
@ -193,13 +196,14 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev,
|
|||
return -EINVAL;
|
||||
|
||||
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;
|
||||
goto err_pdev;
|
||||
}
|
||||
|
||||
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
|
||||
* 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;
|
||||
}
|
||||
|
||||
ret = pdev->driver->sriov_set_msix_vec_count(vf_dev, val);
|
||||
ret = pdrv->sriov_set_msix_vec_count(vf_dev, val);
|
||||
|
||||
err_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)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct pci_driver *pdrv;
|
||||
int ret;
|
||||
u16 num_vfs;
|
||||
|
||||
|
@ -392,14 +397,15 @@ static ssize_t sriov_numvfs_store(struct device *dev,
|
|||
goto exit;
|
||||
|
||||
/* 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");
|
||||
ret = -ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* 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");
|
||||
ret = -ENOENT;
|
||||
goto exit;
|
||||
|
@ -407,7 +413,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
|
|||
|
||||
if (num_vfs == 0) {
|
||||
/* disable VFs */
|
||||
ret = pdev->driver->sriov_configure(pdev, 0);
|
||||
ret = pdrv->sriov_configure(pdev, 0);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -419,7 +425,7 @@ static ssize_t sriov_numvfs_store(struct device *dev,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
ret = pdev->driver->sriov_configure(pdev, num_vfs);
|
||||
ret = pdrv->sriov_configure(pdev, num_vfs);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
|
||||
|
|
|
@ -319,12 +319,10 @@ static long local_pci_probe(void *_ddi)
|
|||
* its remove routine.
|
||||
*/
|
||||
pm_runtime_get_sync(dev);
|
||||
pci_dev->driver = pci_drv;
|
||||
rc = pci_drv->probe(pci_dev, ddi->id);
|
||||
if (!rc)
|
||||
return rc;
|
||||
if (rc < 0) {
|
||||
pci_dev->driver = NULL;
|
||||
pm_runtime_put_sync(dev);
|
||||
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
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
const struct pci_device_id *id;
|
||||
int error = 0;
|
||||
|
||||
if (!pci_dev->driver && drv->probe) {
|
||||
if (drv->probe) {
|
||||
error = -ENODEV;
|
||||
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
pm_runtime_get_sync(dev);
|
||||
drv->remove(pci_dev);
|
||||
pm_runtime_put_noidle(dev);
|
||||
}
|
||||
pcibios_free_irq(pci_dev);
|
||||
pci_dev->driver = NULL;
|
||||
pci_iov_remove(pci_dev);
|
||||
}
|
||||
|
||||
/* Undo the runtime PM settings in local_pci_probe() */
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
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);
|
||||
|
||||
/*
|
||||
|
@ -1244,11 +1238,11 @@ static int pci_pm_runtime_suspend(struct device *dev)
|
|||
int error;
|
||||
|
||||
/*
|
||||
* If pci_dev->driver is not set (unbound), we leave the device in D0,
|
||||
* but it may go to D3cold when the bridge above it runtime suspends.
|
||||
* Save its config space in case that happens.
|
||||
* If the device has no driver, we leave it in D0, but it may go to
|
||||
* D3cold when the bridge above it runtime suspends. Save its
|
||||
* config space in case that happens.
|
||||
*/
|
||||
if (!pci_dev->driver) {
|
||||
if (!to_pci_driver(dev->driver)) {
|
||||
pci_save_state(pci_dev);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1305,7 +1299,7 @@ static int pci_pm_runtime_resume(struct device *dev)
|
|||
*/
|
||||
pci_restore_standard_config(pci_dev);
|
||||
|
||||
if (!pci_dev->driver)
|
||||
if (!to_pci_driver(dev->driver))
|
||||
return 0;
|
||||
|
||||
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)
|
||||
{
|
||||
struct pci_dev *pci_dev = to_pci_dev(dev);
|
||||
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
|
||||
|
||||
/*
|
||||
* If pci_dev->driver is not set (unbound), the device should
|
||||
* always remain in D0 regardless of the runtime PM status
|
||||
* If the device has no driver, it should always remain in D0
|
||||
* regardless of the runtime PM status
|
||||
*/
|
||||
if (!pci_dev->driver)
|
||||
if (!to_pci_driver(dev->driver))
|
||||
return 0;
|
||||
|
||||
if (!pm)
|
||||
|
@ -1438,8 +1431,10 @@ static struct pci_driver pci_compat_driver = {
|
|||
*/
|
||||
struct pci_driver *pci_dev_driver(const struct pci_dev *dev)
|
||||
{
|
||||
if (dev->driver)
|
||||
return dev->driver;
|
||||
struct pci_driver *drv = to_pci_driver(dev->dev.driver);
|
||||
|
||||
if (drv)
|
||||
return drv;
|
||||
else {
|
||||
int 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)
|
||||
{
|
||||
struct pci_driver *drv = to_pci_driver(dev->dev.driver);
|
||||
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
|
||||
* races with ->remove() by the device lock, which must be held by
|
||||
* the caller.
|
||||
* drv->err_handler->reset_prepare() is protected against races
|
||||
* with ->remove() by the device lock, which must be held by the
|
||||
* caller.
|
||||
*/
|
||||
if (err_handler && err_handler->reset_prepare)
|
||||
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)
|
||||
{
|
||||
struct pci_driver *drv = to_pci_driver(dev->dev.driver);
|
||||
const struct pci_error_handlers *err_handler =
|
||||
dev->driver ? dev->driver->err_handler : NULL;
|
||||
drv ? drv->err_handler : NULL;
|
||||
|
||||
pci_restore_state(dev);
|
||||
|
||||
/*
|
||||
* dev->driver->err_handler->reset_done() is protected against
|
||||
* races with ->remove() by the device lock, which must be held by
|
||||
* the caller.
|
||||
* drv->err_handler->reset_done() is protected against races with
|
||||
* ->remove() by the device lock, which must be held by the caller.
|
||||
*/
|
||||
if (err_handler && err_handler->reset_done)
|
||||
err_handler->reset_done(dev);
|
||||
|
|
|
@ -49,14 +49,16 @@ static int report_error_detected(struct pci_dev *dev,
|
|||
pci_channel_state_t state,
|
||||
enum pci_ers_result *result)
|
||||
{
|
||||
struct pci_driver *pdrv;
|
||||
pci_ers_result_t vote;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
|
||||
device_lock(&dev->dev);
|
||||
pdrv = to_pci_driver(dev->dev.driver);
|
||||
if (!pci_dev_set_io_state(dev, state) ||
|
||||
!dev->driver ||
|
||||
!dev->driver->err_handler ||
|
||||
!dev->driver->err_handler->error_detected) {
|
||||
!pdrv ||
|
||||
!pdrv->err_handler ||
|
||||
!pdrv->err_handler->error_detected) {
|
||||
/*
|
||||
* If any device in the subtree does not have an error_detected
|
||||
* 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;
|
||||
}
|
||||
} else {
|
||||
err_handler = dev->driver->err_handler;
|
||||
err_handler = pdrv->err_handler;
|
||||
vote = err_handler->error_detected(dev, state);
|
||||
}
|
||||
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)
|
||||
{
|
||||
struct pci_driver *pdrv;
|
||||
pci_ers_result_t vote, *result = data;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
|
||||
device_lock(&dev->dev);
|
||||
if (!dev->driver ||
|
||||
!dev->driver->err_handler ||
|
||||
!dev->driver->err_handler->mmio_enabled)
|
||||
pdrv = to_pci_driver(dev->dev.driver);
|
||||
if (!pdrv ||
|
||||
!pdrv->err_handler ||
|
||||
!pdrv->err_handler->mmio_enabled)
|
||||
goto out;
|
||||
|
||||
err_handler = dev->driver->err_handler;
|
||||
err_handler = pdrv->err_handler;
|
||||
vote = err_handler->mmio_enabled(dev);
|
||||
*result = merge_result(*result, vote);
|
||||
out:
|
||||
|
@ -110,16 +114,18 @@ out:
|
|||
|
||||
static int report_slot_reset(struct pci_dev *dev, void *data)
|
||||
{
|
||||
struct pci_driver *pdrv;
|
||||
pci_ers_result_t vote, *result = data;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
|
||||
device_lock(&dev->dev);
|
||||
if (!dev->driver ||
|
||||
!dev->driver->err_handler ||
|
||||
!dev->driver->err_handler->slot_reset)
|
||||
pdrv = to_pci_driver(dev->dev.driver);
|
||||
if (!pdrv ||
|
||||
!pdrv->err_handler ||
|
||||
!pdrv->err_handler->slot_reset)
|
||||
goto out;
|
||||
|
||||
err_handler = dev->driver->err_handler;
|
||||
err_handler = pdrv->err_handler;
|
||||
vote = err_handler->slot_reset(dev);
|
||||
*result = merge_result(*result, vote);
|
||||
out:
|
||||
|
@ -129,16 +135,18 @@ out:
|
|||
|
||||
static int report_resume(struct pci_dev *dev, void *data)
|
||||
{
|
||||
struct pci_driver *pdrv;
|
||||
const struct pci_error_handlers *err_handler;
|
||||
|
||||
device_lock(&dev->dev);
|
||||
pdrv = to_pci_driver(dev->dev.driver);
|
||||
if (!pci_dev_set_io_state(dev, pci_channel_io_normal) ||
|
||||
!dev->driver ||
|
||||
!dev->driver->err_handler ||
|
||||
!dev->driver->err_handler->resume)
|
||||
!pdrv ||
|
||||
!pdrv->err_handler ||
|
||||
!pdrv->err_handler->resume)
|
||||
goto out;
|
||||
|
||||
err_handler = dev->driver->err_handler;
|
||||
err_handler = pdrv->err_handler;
|
||||
err_handler->resume(dev);
|
||||
out:
|
||||
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,
|
||||
pci_channel_state_t state)
|
||||
{
|
||||
pci_ers_result_t result;
|
||||
struct pci_driver *pdrv;
|
||||
int bus = pdev->sh_info->aer_op.bus;
|
||||
int devfn = pdev->sh_info->aer_op.devfn;
|
||||
int domain = pdev->sh_info->aer_op.domain;
|
||||
struct pci_dev *pcidev;
|
||||
int flag = 0;
|
||||
|
||||
dev_dbg(&pdev->xdev->dev,
|
||||
"pcifront AER process: cmd %x (bus:%x, devfn%x)",
|
||||
cmd, bus, devfn);
|
||||
result = PCI_ERS_RESULT_NONE;
|
||||
|
||||
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");
|
||||
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) {
|
||||
pci_dbg(pcidev, "trying to call AER service\n");
|
||||
if (pcidev) {
|
||||
flag = 1;
|
||||
switch (cmd) {
|
||||
case XEN_PCI_OP_aer_detected:
|
||||
result = pdrv->err_handler->
|
||||
error_detected(pcidev, state);
|
||||
break;
|
||||
return pdrv->err_handler->error_detected(pcidev, state);
|
||||
case XEN_PCI_OP_aer_mmio:
|
||||
result = pdrv->err_handler->
|
||||
mmio_enabled(pcidev);
|
||||
break;
|
||||
return pdrv->err_handler->mmio_enabled(pcidev);
|
||||
case XEN_PCI_OP_aer_slotreset:
|
||||
result = pdrv->err_handler->
|
||||
slot_reset(pcidev);
|
||||
break;
|
||||
return pdrv->err_handler->slot_reset(pcidev);
|
||||
case XEN_PCI_OP_aer_resume:
|
||||
pdrv->err_handler->resume(pcidev);
|
||||
break;
|
||||
return PCI_ERS_RESULT_NONE;
|
||||
default:
|
||||
dev_err(&pdev->xdev->dev,
|
||||
"bad request in aer recovery "
|
||||
"operation!\n");
|
||||
"bad request in aer recovery operation!\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
result = PCI_ERS_RESULT_NONE;
|
||||
|
||||
return result;
|
||||
return PCI_ERS_RESULT_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ static int ssb_pcihost_probe(struct pci_dev *dev,
|
|||
{
|
||||
struct ssb_bus *ssb;
|
||||
int err = -ENOMEM;
|
||||
const char *name;
|
||||
u32 val;
|
||||
|
||||
ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
|
||||
|
@ -78,10 +77,7 @@ static int ssb_pcihost_probe(struct pci_dev *dev,
|
|||
err = pci_enable_device(dev);
|
||||
if (err)
|
||||
goto err_kfree_ssb;
|
||||
name = dev_name(&dev->dev);
|
||||
if (dev->driver && dev->driver->name)
|
||||
name = dev->driver->name;
|
||||
err = pci_request_regions(dev, name);
|
||||
err = pci_request_regions(dev, dev_driver_string(&dev->dev));
|
||||
if (err)
|
||||
goto err_pci_disable;
|
||||
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;
|
||||
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) {
|
||||
driver_data = (struct xhci_driver_data *)id->driver_data;
|
||||
|
|
|
@ -342,7 +342,6 @@ struct pci_dev {
|
|||
u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */
|
||||
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
|
||||
device implements. Normally this is
|
||||
0xffffffff. You only need to change
|
||||
|
@ -900,7 +899,10 @@ struct pci_driver {
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче