diff options
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/uio.c | 4 | ||||
-rw-r--r-- | drivers/uio/uio_pci_generic.c | 37 | ||||
-rw-r--r-- | drivers/uio/uio_pruss.c | 27 |
3 files changed, 18 insertions, 50 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index be06f1a961c2..ea96e319c8a0 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -906,7 +906,7 @@ static void uio_device_release(struct device *dev) } /** - * uio_register_device - register a new userspace IO device + * __uio_register_device - register a new userspace IO device * @owner: module that creates the new device * @parent: parent device * @info: UIO device capabilities @@ -1002,7 +1002,7 @@ static void devm_uio_unregister_device(struct device *dev, void *res) } /** - * devm_uio_register_device - Resource managed uio_register_device() + * __devm_uio_register_device - Resource managed uio_register_device() * @owner: module that creates the new device * @parent: parent device * @info: UIO device capabilities diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c index dde5cbb27178..1c6c09e1280d 100644 --- a/drivers/uio/uio_pci_generic.c +++ b/drivers/uio/uio_pci_generic.c @@ -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); diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index 1cc175d3c25c..41470c4dba02 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -99,7 +99,6 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev) for (cnt = 0; cnt < MAX_PRUSS_EVT; cnt++, p++) { uio_unregister_device(p); - kfree(p->name); } iounmap(gdev->prussio_vaddr); if (gdev->ddr_vaddr) { @@ -110,10 +109,8 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev) gen_pool_free(gdev->sram_pool, gdev->sram_vaddr, sram_pool_sz); - kfree(gdev->info); clk_disable(gdev->pruss_clk); clk_put(gdev->pruss_clk); - kfree(gdev); } static int pruss_probe(struct platform_device *pdev) @@ -125,22 +122,19 @@ static int pruss_probe(struct platform_device *pdev) int ret, cnt, i, len; struct uio_pruss_pdata *pdata = dev_get_platdata(dev); - gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL); + gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL); if (!gdev) return -ENOMEM; - gdev->info = kcalloc(MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL); - if (!gdev->info) { - ret = -ENOMEM; - goto err_free_gdev; - } + gdev->info = devm_kcalloc(dev, MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL); + if (!gdev->info) + return -ENOMEM; /* Power on PRU in case its not done as part of boot-loader */ gdev->pruss_clk = clk_get(dev, "pruss"); if (IS_ERR(gdev->pruss_clk)) { dev_err(dev, "Failed to get clock\n"); - ret = PTR_ERR(gdev->pruss_clk); - goto err_free_info; + return PTR_ERR(gdev->pruss_clk); } ret = clk_enable(gdev->pruss_clk); @@ -206,7 +200,7 @@ static int pruss_probe(struct platform_device *pdev) p->mem[2].size = extram_pool_sz; p->mem[2].memtype = UIO_MEM_PHYS; - p->name = kasprintf(GFP_KERNEL, "pruss_evt%d", cnt); + p->name = devm_kasprintf(dev, GFP_KERNEL, "pruss_evt%d", cnt); p->version = DRV_VERSION; /* Register PRUSS IRQ lines */ @@ -215,10 +209,8 @@ static int pruss_probe(struct platform_device *pdev) p->priv = gdev; ret = uio_register_device(dev, p); - if (ret < 0) { - kfree(p->name); + if (ret < 0) goto err_unloop; - } } platform_set_drvdata(pdev, gdev); @@ -227,7 +219,6 @@ static int pruss_probe(struct platform_device *pdev) err_unloop: for (i = 0, p = gdev->info; i < cnt; i++, p++) { uio_unregister_device(p); - kfree(p->name); } iounmap(gdev->prussio_vaddr); err_free_ddr_vaddr: @@ -240,10 +231,6 @@ err_clk_disable: clk_disable(gdev->pruss_clk); err_clk_put: clk_put(gdev->pruss_clk); -err_free_info: - kfree(gdev->info); -err_free_gdev: - kfree(gdev); return ret; } |