public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-mmc@vger.kernel.org, Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v1 1/1] mmc: sdhci-pci: Convert to use managed functions pcim_* and devm_*
Date: Thu, 21 Jul 2016 13:41:57 +0300	[thread overview]
Message-ID: <5790A6F5.2060100@intel.com> (raw)
In-Reply-To: <1468071703-77301-1-git-send-email-andriy.shevchenko@linux.intel.com>

On 09/07/16 16:41, 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.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


Acked-by: Adrian Hunter <adrian.hunter@intel.com>


> ---
>  drivers/mmc/host/sdhci-pci-core.c | 42 ++++++++++-----------------------------
>  1 file changed, 11 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
> index 6fbf708..773532d 100644
> --- a/drivers/mmc/host/sdhci-pci-core.c
> +++ b/drivers/mmc/host/sdhci-pci-core.c
> @@ -1819,15 +1819,13 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
>  		return -ENODEV;
>  	}
>  
> -	ret = pci_enable_device(pdev);
> +	ret = pcim_enable_device(pdev);
>  	if (ret)
>  		return ret;
>  
> -	chip = kzalloc(sizeof(struct sdhci_pci_chip), GFP_KERNEL);
> -	if (!chip) {
> -		ret = -ENOMEM;
> -		goto err;
> -	}
> +	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> +	if (!chip)
> +		return -ENOMEM;
>  
>  	chip->pdev = pdev;
>  	chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data;
> @@ -1843,7 +1841,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
>  	if (chip->fixes && chip->fixes->probe) {
>  		ret = chip->fixes->probe(chip);
>  		if (ret)
> -			goto free;
> +			return ret;
>  	}
>  
>  	slots = chip->num_slots;	/* Quirk may have changed this */
> @@ -1853,8 +1851,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
>  		if (IS_ERR(slot)) {
>  			for (i--; i >= 0; i--)
>  				sdhci_pci_remove_slot(chip->slots[i]);
> -			ret = PTR_ERR(slot);
> -			goto free;
> +			return PTR_ERR(slot);
>  		}
>  
>  		chip->slots[i] = slot;
> @@ -1864,35 +1861,18 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
>  		sdhci_pci_runtime_pm_allow(&pdev->dev);
>  
>  	return 0;
> -
> -free:
> -	pci_set_drvdata(pdev, NULL);
> -	kfree(chip);
> -
> -err:
> -	pci_disable_device(pdev);
> -	return ret;
>  }
>  
>  static void sdhci_pci_remove(struct pci_dev *pdev)
>  {
>  	int i;
> -	struct sdhci_pci_chip *chip;
> -
> -	chip = pci_get_drvdata(pdev);
> -
> -	if (chip) {
> -		if (chip->allow_runtime_pm)
> -			sdhci_pci_runtime_pm_forbid(&pdev->dev);
> +	struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
>  
> -		for (i = 0; i < chip->num_slots; i++)
> -			sdhci_pci_remove_slot(chip->slots[i]);
> -
> -		pci_set_drvdata(pdev, NULL);
> -		kfree(chip);
> -	}
> +	if (chip->allow_runtime_pm)
> +		sdhci_pci_runtime_pm_forbid(&pdev->dev);
>  
> -	pci_disable_device(pdev);
> +	for (i = 0; i < chip->num_slots; i++)
> +		sdhci_pci_remove_slot(chip->slots[i]);
>  }
>  
>  static struct pci_driver sdhci_driver = {
> 


  reply	other threads:[~2016-07-21 10:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-09 13:41 [PATCH v1 1/1] mmc: sdhci-pci: Convert to use managed functions pcim_* and devm_* Andy Shevchenko
2016-07-21 10:41 ` Adrian Hunter [this message]
2016-07-23  9:37 ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5790A6F5.2060100@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox