mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 08:09:56 +00:00
mmc: dw_mmc-pci: convert to use pcim_* and devm_*
The PCI driver is getting simplier and tidier with pcim_* and devm_* functions in use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Seungwon Jeon <tgih.jun@samsung.com> Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:
parent
dd36980020
commit
1395974142
@ -21,7 +21,6 @@
|
|||||||
#include "dw_mmc.h"
|
#include "dw_mmc.h"
|
||||||
|
|
||||||
#define PCI_BAR_NO 2
|
#define PCI_BAR_NO 2
|
||||||
#define COMPLETE_BAR 0
|
|
||||||
#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
|
#define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
|
||||||
#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
|
#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
|
||||||
/* Defining the Capabilities */
|
/* Defining the Capabilities */
|
||||||
@ -38,51 +37,37 @@ static struct dw_mci_board pci_board_data = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int dw_mci_pci_probe(struct pci_dev *pdev,
|
static int dw_mci_pci_probe(struct pci_dev *pdev,
|
||||||
const struct pci_device_id *entries)
|
const struct pci_device_id *entries)
|
||||||
{
|
{
|
||||||
struct dw_mci *host;
|
struct dw_mci *host;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = pci_enable_device(pdev);
|
ret = pcim_enable_device(pdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (pci_request_regions(pdev, "dw_mmc_pci")) {
|
|
||||||
ret = -ENODEV;
|
|
||||||
goto err_disable_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL);
|
host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
|
||||||
if (!host) {
|
if (!host)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_release;
|
|
||||||
}
|
|
||||||
|
|
||||||
host->irq = pdev->irq;
|
host->irq = pdev->irq;
|
||||||
host->irq_flags = IRQF_SHARED;
|
host->irq_flags = IRQF_SHARED;
|
||||||
host->dev = &pdev->dev;
|
host->dev = &pdev->dev;
|
||||||
host->pdata = &pci_board_data;
|
host->pdata = &pci_board_data;
|
||||||
|
|
||||||
host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR);
|
ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
|
||||||
if (!host->regs) {
|
if (ret)
|
||||||
ret = -EIO;
|
return ret;
|
||||||
goto err_unmap;
|
|
||||||
}
|
host->regs = pcim_iomap_table(pdev)[0];
|
||||||
|
|
||||||
pci_set_drvdata(pdev, host);
|
|
||||||
ret = dw_mci_probe(host);
|
ret = dw_mci_probe(host);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_probe_failed;
|
return ret;
|
||||||
return ret;
|
|
||||||
|
|
||||||
err_probe_failed:
|
pci_set_drvdata(pdev, host);
|
||||||
pci_iounmap(pdev, host->regs);
|
|
||||||
err_unmap:
|
return 0;
|
||||||
kfree(host);
|
|
||||||
err_release:
|
|
||||||
pci_release_regions(pdev);
|
|
||||||
err_disable_dev:
|
|
||||||
pci_disable_device(pdev);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dw_mci_pci_remove(struct pci_dev *pdev)
|
static void dw_mci_pci_remove(struct pci_dev *pdev)
|
||||||
@ -90,11 +75,6 @@ static void dw_mci_pci_remove(struct pci_dev *pdev)
|
|||||||
struct dw_mci *host = pci_get_drvdata(pdev);
|
struct dw_mci *host = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
dw_mci_remove(host);
|
dw_mci_remove(host);
|
||||||
pci_set_drvdata(pdev, NULL);
|
|
||||||
pci_release_regions(pdev);
|
|
||||||
pci_iounmap(pdev, host->regs);
|
|
||||||
kfree(host);
|
|
||||||
pci_disable_device(pdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user