public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource
@ 2013-06-05  9:24 Andy Shevchenko
  2013-06-05  9:24 ` [PATCH 2/3] mmc: dw: eliminate useless usage of ret Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-06-05  9:24 UTC (permalink / raw)
  To: Jaehoon Chung, Chris Ball, linux-mmc; +Cc: Andy Shevchenko

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/dw_mmc-pltfm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
index 37873f1..526abae 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.c
+++ b/drivers/mmc/host/dw_mmc-pltfm.c
@@ -25,7 +25,7 @@
 #include "dw_mmc.h"
 
 int dw_mci_pltfm_register(struct platform_device *pdev,
-				const struct dw_mci_drv_data *drv_data)
+			  const struct dw_mci_drv_data *drv_data)
 {
 	struct dw_mci *host;
 	struct resource	*regs;
@@ -35,10 +35,6 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
 	if (!host)
 		return -ENOMEM;
 
-	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!regs)
-		return -ENXIO;
-
 	host->irq = platform_get_irq(pdev, 0);
 	if (host->irq < 0)
 		return host->irq;
@@ -47,6 +43,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
 	host->dev = &pdev->dev;
 	host->irq_flags = 0;
 	host->pdata = pdev->dev.platform_data;
+
+	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->regs = devm_ioremap_resource(&pdev->dev, regs);
 	if (IS_ERR(host->regs))
 		return PTR_ERR(host->regs);
-- 
1.8.2.rc0.22.gb3600c3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] mmc: dw: eliminate useless usage of ret
  2013-06-05  9:24 [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Andy Shevchenko
@ 2013-06-05  9:24 ` Andy Shevchenko
  2013-06-05 14:01   ` Seungwon Jeon
  2013-06-05  9:24 ` [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_* Andy Shevchenko
  2013-06-05 14:01 ` [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Seungwon Jeon
  2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2013-06-05  9:24 UTC (permalink / raw)
  To: Jaehoon Chung, Chris Ball, linux-mmc; +Cc: Andy Shevchenko

In few places usage of ret variable is not needed. This patch simplifies that
pieces of code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/dw_mmc-pci.c   |  8 ++------
 drivers/mmc/host/dw_mmc-pltfm.c | 17 +++--------------
 2 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c
index 083fcd2..c469ce6 100644
--- a/drivers/mmc/host/dw_mmc-pci.c
+++ b/drivers/mmc/host/dw_mmc-pci.c
@@ -100,22 +100,18 @@ static void dw_mci_pci_remove(struct pci_dev *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int dw_mci_pci_suspend(struct device *dev)
 {
-	int ret;
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct dw_mci *host = pci_get_drvdata(pdev);
 
-	ret = dw_mci_suspend(host);
-	return ret;
+	return dw_mci_suspend(host);
 }
 
 static int dw_mci_pci_resume(struct device *dev)
 {
-	int ret;
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct dw_mci *host = pci_get_drvdata(pdev);
 
-	ret = dw_mci_resume(host);
-	return ret;
+	return dw_mci_resume(host);
 }
 #else
 #define dw_mci_pci_suspend	NULL
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
index 526abae..2721bd5 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.c
+++ b/drivers/mmc/host/dw_mmc-pltfm.c
@@ -56,8 +56,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
 	}
 
 	platform_set_drvdata(pdev, host);
-	ret = dw_mci_probe(host);
-	return ret;
+	return dw_mci_probe(host);
 }
 EXPORT_SYMBOL_GPL(dw_mci_pltfm_register);
 
@@ -81,26 +80,16 @@ EXPORT_SYMBOL_GPL(dw_mci_pltfm_remove);
  */
 static int dw_mci_pltfm_suspend(struct device *dev)
 {
-	int ret;
 	struct dw_mci *host = dev_get_drvdata(dev);
 
-	ret = dw_mci_suspend(host);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dw_mci_suspend(host);
 }
 
 static int dw_mci_pltfm_resume(struct device *dev)
 {
-	int ret;
 	struct dw_mci *host = dev_get_drvdata(dev);
 
-	ret = dw_mci_resume(host);
-	if (ret)
-		return ret;
-
-	return 0;
+	return dw_mci_resume(host);
 }
 #else
 #define dw_mci_pltfm_suspend	NULL
-- 
1.8.2.rc0.22.gb3600c3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_*
  2013-06-05  9:24 [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Andy Shevchenko
  2013-06-05  9:24 ` [PATCH 2/3] mmc: dw: eliminate useless usage of ret Andy Shevchenko
@ 2013-06-05  9:24 ` Andy Shevchenko
  2013-06-05 14:04   ` Seungwon Jeon
  2013-06-05 14:01 ` [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Seungwon Jeon
  2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2013-06-05  9:24 UTC (permalink / raw)
  To: Jaehoon Chung, Chris Ball, linux-mmc; +Cc: Andy Shevchenko

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>
---
 drivers/mmc/host/dw_mmc-pci.c | 50 +++++++++++++------------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c
index c469ce6..b456b0c 100644
--- a/drivers/mmc/host/dw_mmc-pci.c
+++ b/drivers/mmc/host/dw_mmc-pci.c
@@ -21,7 +21,6 @@
 #include "dw_mmc.h"
 
 #define PCI_BAR_NO 2
-#define COMPLETE_BAR 0
 #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
 #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
 /* 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,
-				  const struct pci_device_id *entries)
+			    const struct pci_device_id *entries)
 {
 	struct dw_mci *host;
 	int ret;
 
-	ret = pci_enable_device(pdev);
+	ret = pcim_enable_device(pdev);
 	if (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);
-	if (!host) {
-		ret = -ENOMEM;
-		goto err_release;
-	}
+	host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
+	if (!host)
+		return -ENOMEM;
 
 	host->irq = pdev->irq;
 	host->irq_flags = IRQF_SHARED;
 	host->dev = &pdev->dev;
 	host->pdata = &pci_board_data;
 
-	host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR);
-	if (!host->regs) {
-		ret = -EIO;
-		goto err_unmap;
-	}
+	ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev));
+	if (ret)
+		return ret;
+
+	host->regs = pcim_iomap_table(pdev)[0];
 
-	pci_set_drvdata(pdev, host);
 	ret = dw_mci_probe(host);
 	if (ret)
-		goto err_probe_failed;
-	return ret;
-
-err_probe_failed:
-	pci_iounmap(pdev, host->regs);
-err_unmap:
-	kfree(host);
-err_release:
-	pci_release_regions(pdev);
-err_disable_dev:
-	pci_disable_device(pdev);
-	return ret;
+		return ret;
+
+	pci_set_drvdata(pdev, host);
+
+	return 0;
 }
 
 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);
 
 	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
-- 
1.8.2.rc0.22.gb3600c3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource
  2013-06-05  9:24 [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Andy Shevchenko
  2013-06-05  9:24 ` [PATCH 2/3] mmc: dw: eliminate useless usage of ret Andy Shevchenko
  2013-06-05  9:24 ` [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_* Andy Shevchenko
@ 2013-06-05 14:01 ` Seungwon Jeon
  2013-06-05 14:14   ` Andy Shevchenko
  2 siblings, 1 reply; 8+ messages in thread
From: Seungwon Jeon @ 2013-06-05 14:01 UTC (permalink / raw)
  To: 'Andy Shevchenko', 'Jaehoon Chung',
	'Chris Ball', linux-mmc

On 06/05/13 6:24 PM, Andy Shevchenko wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Looks good to me.
'dw_mmc'(instead of 'dw') as a prefix of subject is expected with other patches, though.
Specially, dw_mmc-pci is for PATCH 3/3.

Acked-by: Seungwon Jeon <tgih.jun@samsung.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 2/3] mmc: dw: eliminate useless usage of ret
  2013-06-05  9:24 ` [PATCH 2/3] mmc: dw: eliminate useless usage of ret Andy Shevchenko
@ 2013-06-05 14:01   ` Seungwon Jeon
  0 siblings, 0 replies; 8+ messages in thread
From: Seungwon Jeon @ 2013-06-05 14:01 UTC (permalink / raw)
  To: 'Andy Shevchenko', 'Jaehoon Chung',
	'Chris Ball', linux-mmc

On 06/05/13 6:24 PM, Andy Shevchenko wrote:
> In few places usage of ret variable is not needed. This patch simplifies that
> pieces of code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Seungwon Jeon <tgih.jun@samsung.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_*
  2013-06-05  9:24 ` [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_* Andy Shevchenko
@ 2013-06-05 14:04   ` Seungwon Jeon
  0 siblings, 0 replies; 8+ messages in thread
From: Seungwon Jeon @ 2013-06-05 14:04 UTC (permalink / raw)
  To: 'Andy Shevchenko', 'Jaehoon Chung',
	'Chris Ball', linux-mmc

On 06/05/13 6:24 PM, Andy Shevchenko wrote:
> 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>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource
  2013-06-05 14:01 ` [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Seungwon Jeon
@ 2013-06-05 14:14   ` Andy Shevchenko
  2013-06-27 15:25     ` Chris Ball
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2013-06-05 14:14 UTC (permalink / raw)
  To: Seungwon Jeon; +Cc: 'Jaehoon Chung', 'Chris Ball', linux-mmc

On Wed, 2013-06-05 at 23:01 +0900, Seungwon Jeon wrote: 
> On 06/05/13 6:24 PM, Andy Shevchenko wrote:
> > devm_ioremap_resource does sanity checks on the given resource. No need to
> > duplicate this in the driver.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Looks good to me.
> 'dw_mmc'(instead of 'dw') as a prefix of subject is expected with other patches, though.
> Specially, dw_mmc-pci is for PATCH 3/3.

Shall I resubmit patches?
I think no-one can mess up with this, because we fortunately have only
one mmc designware driver there.


> Acked-by: Seungwon Jeon <tgih.jun@samsung.com>

Thanks for review.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource
  2013-06-05 14:14   ` Andy Shevchenko
@ 2013-06-27 15:25     ` Chris Ball
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Ball @ 2013-06-27 15:25 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Seungwon Jeon, 'Jaehoon Chung', linux-mmc

Hi Andy,

On Wed, Jun 05 2013, Andy Shevchenko wrote:
> On Wed, 2013-06-05 at 23:01 +0900, Seungwon Jeon wrote: 
>> On 06/05/13 6:24 PM, Andy Shevchenko wrote:
>> > devm_ioremap_resource does sanity checks on the given resource. No need to
>> > duplicate this in the driver.
>> > 
>> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> 
>> Looks good to me.
>> 'dw_mmc'(instead of 'dw') as a prefix of subject is expected with other patches, though.
>> Specially, dw_mmc-pci is for PATCH 3/3.
>
> Shall I resubmit patches?
> I think no-one can mess up with this, because we fortunately have only
> one mmc designware driver there.

Thanks, I pushed all three patches to mmc-next for 3.11 and corrected
the titles.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-27 15:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05  9:24 [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Andy Shevchenko
2013-06-05  9:24 ` [PATCH 2/3] mmc: dw: eliminate useless usage of ret Andy Shevchenko
2013-06-05 14:01   ` Seungwon Jeon
2013-06-05  9:24 ` [PATCH 3/3] mmc: dw: convert to use pcim_* and devm_* Andy Shevchenko
2013-06-05 14:04   ` Seungwon Jeon
2013-06-05 14:01 ` [PATCH 1/3] mmc: dw: don't check resource with devm_ioremap_resource Seungwon Jeon
2013-06-05 14:14   ` Andy Shevchenko
2013-06-27 15:25     ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox