diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-06-05 05:24:12 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-06-27 11:25:07 -0400 |
commit | 1395974142bde026da39020a15374a713edbbfb9 (patch) | |
tree | aeeb0fb9d9200d4e5dd3897fbe5ecc13698e3c59 | |
parent | dd369800202f1aeeb23b64fe9d336d67b202c3b2 (diff) |
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>
-rw-r--r-- | drivers/mmc/host/dw_mmc-pci.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c index c469ce624bb8..b456b0c35231 100644 --- a/drivers/mmc/host/dw_mmc-pci.c +++ b/drivers/mmc/host/dw_mmc-pci.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include "dw_mmc.h" | 21 | #include "dw_mmc.h" |
22 | 22 | ||
23 | #define PCI_BAR_NO 2 | 23 | #define PCI_BAR_NO 2 |
24 | #define COMPLETE_BAR 0 | ||
25 | #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700 | 24 | #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700 |
26 | #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107 | 25 | #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107 |
27 | /* Defining the Capabilities */ | 26 | /* Defining the Capabilities */ |
@@ -38,51 +37,37 @@ static struct dw_mci_board pci_board_data = { | |||
38 | }; | 37 | }; |
39 | 38 | ||
40 | static int dw_mci_pci_probe(struct pci_dev *pdev, | 39 | static int dw_mci_pci_probe(struct pci_dev *pdev, |
41 | const struct pci_device_id *entries) | 40 | const struct pci_device_id *entries) |
42 | { | 41 | { |
43 | struct dw_mci *host; | 42 | struct dw_mci *host; |
44 | int ret; | 43 | int ret; |
45 | 44 | ||
46 | ret = pci_enable_device(pdev); | 45 | ret = pcim_enable_device(pdev); |
47 | if (ret) | 46 | if (ret) |
48 | return ret; | 47 | return ret; |
49 | if (pci_request_regions(pdev, "dw_mmc_pci")) { | ||
50 | ret = -ENODEV; | ||
51 | goto err_disable_dev; | ||
52 | } | ||
53 | 48 | ||
54 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | 49 | host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL); |
55 | if (!host) { | 50 | if (!host) |
56 | ret = -ENOMEM; | 51 | return -ENOMEM; |
57 | goto err_release; | ||
58 | } | ||
59 | 52 | ||
60 | host->irq = pdev->irq; | 53 | host->irq = pdev->irq; |
61 | host->irq_flags = IRQF_SHARED; | 54 | host->irq_flags = IRQF_SHARED; |
62 | host->dev = &pdev->dev; | 55 | host->dev = &pdev->dev; |
63 | host->pdata = &pci_board_data; | 56 | host->pdata = &pci_board_data; |
64 | 57 | ||
65 | host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR); | 58 | ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev)); |
66 | if (!host->regs) { | 59 | if (ret) |
67 | ret = -EIO; | 60 | return ret; |
68 | goto err_unmap; | 61 | |
69 | } | 62 | host->regs = pcim_iomap_table(pdev)[0]; |
70 | 63 | ||
71 | pci_set_drvdata(pdev, host); | ||
72 | ret = dw_mci_probe(host); | 64 | ret = dw_mci_probe(host); |
73 | if (ret) | 65 | if (ret) |
74 | goto err_probe_failed; | 66 | return ret; |
75 | return ret; | 67 | |
76 | 68 | pci_set_drvdata(pdev, host); | |
77 | err_probe_failed: | 69 | |
78 | pci_iounmap(pdev, host->regs); | 70 | return 0; |
79 | err_unmap: | ||
80 | kfree(host); | ||
81 | err_release: | ||
82 | pci_release_regions(pdev); | ||
83 | err_disable_dev: | ||
84 | pci_disable_device(pdev); | ||
85 | return ret; | ||
86 | } | 71 | } |
87 | 72 | ||
88 | static void dw_mci_pci_remove(struct pci_dev *pdev) | 73 | static void dw_mci_pci_remove(struct pci_dev *pdev) |
@@ -90,11 +75,6 @@ static void dw_mci_pci_remove(struct pci_dev *pdev) | |||
90 | struct dw_mci *host = pci_get_drvdata(pdev); | 75 | struct dw_mci *host = pci_get_drvdata(pdev); |
91 | 76 | ||
92 | dw_mci_remove(host); | 77 | dw_mci_remove(host); |
93 | pci_set_drvdata(pdev, NULL); | ||
94 | pci_release_regions(pdev); | ||
95 | pci_iounmap(pdev, host->regs); | ||
96 | kfree(host); | ||
97 | pci_disable_device(pdev); | ||
98 | } | 78 | } |
99 | 79 | ||
100 | #ifdef CONFIG_PM_SLEEP | 80 | #ifdef CONFIG_PM_SLEEP |