Re: [PATCH v1 1/1] mei: me: use managed functions pcim_* and devm_*

From: Andy Shevchenko
Date: Sun Jun 05 2016 - 10:48:36 EST


On Mon, 2016-02-01 at 16:00 +0200, Andy Shevchenko wrote:
> This makes the error handling much more simpler than open-coding
> everything and
> in addition makes the probe function smaller an tidier.
>

It's already one release cycle passed. What is the destiny of this
change?

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
> Âdrivers/misc/mei/hw-me.cÂÂ|ÂÂ4 ++--
> Âdrivers/misc/mei/pci-me.c | 40 ++++++++----------------------------
> ----
> Â2 files changed, 10 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
> index 25b1997..e26c4f4 100644
> --- a/drivers/misc/mei/hw-me.c
> +++ b/drivers/misc/mei/hw-me.c
> @@ -1336,8 +1336,8 @@ struct mei_device *mei_me_dev_init(struct
> pci_dev *pdev,
> Â struct mei_device *dev;
> Â struct mei_me_hw *hw;
> Â
> - dev = kzalloc(sizeof(struct mei_device) +
> - Âsizeof(struct mei_me_hw), GFP_KERNEL);
> + dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) +
> + ÂÂÂÂÂÂÂsizeof(struct mei_me_hw),
> GFP_KERNEL);
> Â if (!dev)
> Â return NULL;
> Â hw = to_me_hw(dev);
> diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
> index 75fc9c6..3c07a02 100644
> --- a/drivers/misc/mei/pci-me.c
> +++ b/drivers/misc/mei/pci-me.c
> @@ -142,7 +142,7 @@ static int mei_me_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> Â return -ENODEV;
> Â
> Â /* enable pci dev */
> - err = pci_enable_device(pdev);
> + err = pcim_enable_device(pdev);
> Â if (err) {
> Â dev_err(&pdev->dev, "failed to enable pci
> device.\n");
> Â goto end;
> @@ -153,7 +153,7 @@ static int mei_me_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> Â err = pci_request_regions(pdev, KBUILD_MODNAME);
> Â if (err) {
> Â dev_err(&pdev->dev, "failed to get pci regions.\n");
> - goto disable_device;
> + goto end;
> Â }
> Â
> Â if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) ||
> @@ -166,23 +166,22 @@ static int mei_me_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> Â }
> Â if (err) {
> Â dev_err(&pdev->dev, "No usable DMA configuration,
> aborting\n");
> - goto release_regions;
> + goto end;
> Â }
> Â
> -
> Â /* allocates and initializes the mei dev structure */
> Â dev = mei_me_dev_init(pdev, cfg);
> Â if (!dev) {
> Â err = -ENOMEM;
> - goto release_regions;
> + goto end;
> Â }
> Â hw = to_me_hw(dev);
> Â /* mappingÂÂIO device memory */
> - hw->mem_addr = pci_iomap(pdev, 0, 0);
> + hw->mem_addr = pcim_iomap(pdev, 0, 0);
> Â if (!hw->mem_addr) {
> Â dev_err(&pdev->dev, "mapping I/O device memory
> failure.\n");
> Â err = -ENOMEM;
> - goto free_device;
> + goto end;
> Â }
> Â pci_enable_msi(pdev);
> Â
> @@ -196,7 +195,7 @@ static int mei_me_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> Â if (err) {
> Â dev_err(&pdev->dev, "request_threaded_irq failure.
> irq = %d\n",
> Â ÂÂÂÂÂÂÂpdev->irq);
> - goto disable_msi;
> + goto end;
> Â }
> Â
> Â if (mei_start(dev)) {
> @@ -235,15 +234,6 @@ release_irq:
> Â mei_cancel_work(dev);
> Â mei_disable_interrupts(dev);
> Â free_irq(pdev->irq, dev);
> -disable_msi:
> - pci_disable_msi(pdev);
> - pci_iounmap(pdev, hw->mem_addr);
> -free_device:
> - kfree(dev);
> -release_regions:
> - pci_release_regions(pdev);
> -disable_device:
> - pci_disable_device(pdev);
> Âend:
> Â dev_err(&pdev->dev, "initialization failed.\n");
> Â return err;
> @@ -260,7 +250,6 @@ end:
> Âstatic void mei_me_remove(struct pci_dev *pdev)
> Â{
> Â struct mei_device *dev;
> - struct mei_me_hw *hw;
> Â
> Â dev = pci_get_drvdata(pdev);
> Â if (!dev)
> @@ -269,9 +258,6 @@ static void mei_me_remove(struct pci_dev *pdev)
> Â if (mei_pg_is_enabled(dev))
> Â pm_runtime_get_noresume(&pdev->dev);
> Â
> - hw = to_me_hw(dev);
> -
> -
> Â dev_dbg(&pdev->dev, "stop\n");
> Â mei_stop(dev);
> Â
> @@ -282,20 +268,10 @@ static void mei_me_remove(struct pci_dev *pdev)
> Â mei_disable_interrupts(dev);
> Â
> Â free_irq(pdev->irq, dev);
> - pci_disable_msi(pdev);
> -
> - if (hw->mem_addr)
> - pci_iounmap(pdev, hw->mem_addr);
> Â
> Â mei_deregister(dev);
> -
> - kfree(dev);
> -
> - pci_release_regions(pdev);
> - pci_disable_device(pdev);
> -
> -
> Â}
> +
> Â#ifdef CONFIG_PM_SLEEP
> Âstatic int mei_me_pci_suspend(struct device *device)
> Â{

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy