Commit 52ac7acf authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Ulf Hansson

mmc: sdhci-pci: Convert to use managed functions pcim_* and devm_*

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 6825a606
...@@ -1811,15 +1811,13 @@ static int sdhci_pci_probe(struct pci_dev *pdev, ...@@ -1811,15 +1811,13 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
return -ENODEV; return -ENODEV;
} }
ret = pci_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) if (ret)
return ret; return ret;
chip = kzalloc(sizeof(struct sdhci_pci_chip), GFP_KERNEL); chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
if (!chip) { if (!chip)
ret = -ENOMEM; return -ENOMEM;
goto err;
}
chip->pdev = pdev; chip->pdev = pdev;
chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data;
...@@ -1835,7 +1833,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, ...@@ -1835,7 +1833,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
if (chip->fixes && chip->fixes->probe) { if (chip->fixes && chip->fixes->probe) {
ret = chip->fixes->probe(chip); ret = chip->fixes->probe(chip);
if (ret) if (ret)
goto free; return ret;
} }
slots = chip->num_slots; /* Quirk may have changed this */ slots = chip->num_slots; /* Quirk may have changed this */
...@@ -1845,8 +1843,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev, ...@@ -1845,8 +1843,7 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
if (IS_ERR(slot)) { if (IS_ERR(slot)) {
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
sdhci_pci_remove_slot(chip->slots[i]); sdhci_pci_remove_slot(chip->slots[i]);
ret = PTR_ERR(slot); return PTR_ERR(slot);
goto free;
} }
chip->slots[i] = slot; chip->slots[i] = slot;
...@@ -1856,35 +1853,18 @@ static int sdhci_pci_probe(struct pci_dev *pdev, ...@@ -1856,35 +1853,18 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
sdhci_pci_runtime_pm_allow(&pdev->dev); sdhci_pci_runtime_pm_allow(&pdev->dev);
return 0; 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) static void sdhci_pci_remove(struct pci_dev *pdev)
{ {
int i; int i;
struct sdhci_pci_chip *chip; struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
chip = pci_get_drvdata(pdev);
if (chip) {
if (chip->allow_runtime_pm)
sdhci_pci_runtime_pm_forbid(&pdev->dev);
for (i = 0; i < chip->num_slots; i++) if (chip->allow_runtime_pm)
sdhci_pci_remove_slot(chip->slots[i]); sdhci_pci_runtime_pm_forbid(&pdev->dev);
pci_set_drvdata(pdev, NULL);
kfree(chip);
}
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 = { static struct pci_driver sdhci_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment