uio/uio_pci_generic: use device-managed function equivalents

This driver can be easily converted to use the device-managed allocator
function and the PCI managed enable function.

With these conversions the probe error paths are no longer needed and
neither is the remove function.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20201111113828.64992-1-alexandru.ardelean@analog.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alexandru Ardelean 2020-11-11 13:38:28 +02:00 committed by Greg Kroah-Hartman
parent 667aef00f3
commit ef84928cff
1 changed files with 9 additions and 28 deletions

View File

@ -74,23 +74,19 @@ static int probe(struct pci_dev *pdev,
struct uio_pci_generic_dev *gdev;
int err;
err = pci_enable_device(pdev);
err = pcim_enable_device(pdev);
if (err) {
dev_err(&pdev->dev, "%s: pci_enable_device failed: %d\n",
__func__, err);
return err;
}
if (pdev->irq && !pci_intx_mask_supported(pdev)) {
err = -ENODEV;
goto err_verify;
}
if (pdev->irq && !pci_intx_mask_supported(pdev))
return -ENOMEM;
gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL);
if (!gdev) {
err = -ENOMEM;
goto err_alloc;
}
gdev = devm_kzalloc(&pdev->dev, sizeof(struct uio_pci_generic_dev), GFP_KERNEL);
if (!gdev)
return -ENOMEM;
gdev->info.name = "uio_pci_generic";
gdev->info.version = DRIVER_VERSION;
@ -105,34 +101,19 @@ static int probe(struct pci_dev *pdev,
"no support for interrupts?\n");
}
err = uio_register_device(&pdev->dev, &gdev->info);
err = devm_uio_register_device(&pdev->dev, &gdev->info);
if (err)
goto err_register;
return err;
pci_set_drvdata(pdev, gdev);
return 0;
err_register:
kfree(gdev);
err_alloc:
err_verify:
pci_disable_device(pdev);
return err;
}
static void remove(struct pci_dev *pdev)
{
struct uio_pci_generic_dev *gdev = pci_get_drvdata(pdev);
uio_unregister_device(&gdev->info);
pci_disable_device(pdev);
kfree(gdev);
}
static struct pci_driver uio_pci_driver = {
.name = "uio_pci_generic",
.id_table = NULL, /* only dynamic id's */
.probe = probe,
.remove = remove,
};
module_pci_driver(uio_pci_driver);