linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] i2c: bcm2835: Use devm_ioremap_resource()
@ 2014-02-11 13:02 Jingoo Han
       [not found] ` <001101cf2729$890d5b10$9b281130$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Jingoo Han @ 2014-02-11 13:02 UTC (permalink / raw)
  To: 'Wolfram Sang'
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Jingoo Han',
	'Stephen Warren', 'Florian Meier'

Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because the value is checked by devm_ioremap_resource().

Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 drivers/i2c/busses/i2c-bcm2835.c |   24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 77df97b..13b7ed5 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -219,7 +219,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
 static int bcm2835_i2c_probe(struct platform_device *pdev)
 {
 	struct bcm2835_i2c_dev *i2c_dev;
-	struct resource *mem, *requested, *irq;
+	struct resource *mem, *irq;
 	u32 bus_clk_rate, divider;
 	int ret;
 	struct i2c_adapter *adap;
@@ -234,25 +234,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	init_completion(&i2c_dev->completion);
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "No mem resource\n");
-		return -ENODEV;
-	}
-
-	requested = devm_request_mem_region(&pdev->dev, mem->start,
-					    resource_size(mem),
-					    dev_name(&pdev->dev));
-	if (!requested) {
-		dev_err(&pdev->dev, "Could not claim register region\n");
-		return -EBUSY;
-	}
-
-	i2c_dev->regs = devm_ioremap(&pdev->dev, mem->start,
-				     resource_size(mem));
-	if (!i2c_dev->regs) {
-		dev_err(&pdev->dev, "Could not map registers\n");
-		return -ENOMEM;
-	}
+	i2c_dev->regs = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(i2c_dev->regs))
+		return PTR_ERR(i2c_dev->regs);
 
 	i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(i2c_dev->clk)) {
-- 
1.7.10.4

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

* [PATCH 2/2] i2c: mxs: Use devm_ioremap_resource()
       [not found] ` <001101cf2729$890d5b10$9b281130$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2014-02-11 13:04   ` Jingoo Han
       [not found]     ` <001a01cf2729$dc23cd70$946b6850$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2014-02-12  5:11   ` [PATCH 1/2] i2c: bcm2835: " Stephen Warren
  2014-03-09 20:46   ` Wolfram Sang
  2 siblings, 1 reply; 9+ messages in thread
From: Jingoo Han @ 2014-02-11 13:04 UTC (permalink / raw)
  To: 'Wolfram Sang'
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Jingoo Han',
	'Marek Vasut', 'Shawn Guo',
	'Sascha Hauer'

Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because the value is checked by devm_ioremap_resource().

Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 drivers/i2c/busses/i2c-mxs.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 0cde4e6..9585b90 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -806,7 +806,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	struct mxs_i2c_dev *i2c;
 	struct i2c_adapter *adap;
 	struct resource *res;
-	resource_size_t res_size;
 	int err, irq;
 
 	i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL);
@@ -819,19 +818,14 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	irq = platform_get_irq(pdev, 0);
+	i2c->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(i2c->regs))
+		return PTR_ERR(i2c->regs);
 
-	if (!res || irq < 0)
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
 		return -ENOENT;
 
-	res_size = resource_size(res);
-	if (!devm_request_mem_region(dev, res->start, res_size, res->name))
-		return -EBUSY;
-
-	i2c->regs = devm_ioremap_nocache(dev, res->start, res_size);
-	if (!i2c->regs)
-		return -EBUSY;
-
 	err = devm_request_irq(dev, irq, mxs_i2c_isr, 0, dev_name(dev), i2c);
 	if (err)
 		return err;
-- 
1.7.10.4

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

* Re: [PATCH 2/2] i2c: mxs: Use devm_ioremap_resource()
       [not found]     ` <001a01cf2729$dc23cd70$946b6850$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2014-02-12  3:33       ` Shawn Guo
  2014-02-12  7:36       ` Marek Vasut
  2014-03-09 20:47       ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2014-02-12  3:33 UTC (permalink / raw)
  To: Jingoo Han
  Cc: 'Wolfram Sang', linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	'Marek Vasut', 'Sascha Hauer'

On Tue, Feb 11, 2014 at 10:04:55PM +0900, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Acked-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

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

* Re: [PATCH 1/2] i2c: bcm2835: Use devm_ioremap_resource()
       [not found] ` <001101cf2729$890d5b10$9b281130$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2014-02-11 13:04   ` [PATCH 2/2] i2c: mxs: " Jingoo Han
@ 2014-02-12  5:11   ` Stephen Warren
  2014-03-09 20:46   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2014-02-12  5:11 UTC (permalink / raw)
  To: Jingoo Han, 'Wolfram Sang'
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Florian Meier'

On 02/11/2014 06:02 AM, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().

Acked-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>

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

* Re: [PATCH 2/2] i2c: mxs: Use devm_ioremap_resource()
       [not found]     ` <001a01cf2729$dc23cd70$946b6850$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2014-02-12  3:33       ` Shawn Guo
@ 2014-02-12  7:36       ` Marek Vasut
  2014-03-09 20:47       ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2014-02-12  7:36 UTC (permalink / raw)
  To: Jingoo Han
  Cc: 'Wolfram Sang', linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	'Shawn Guo', 'Sascha Hauer'

On Tuesday, February 11, 2014 at 02:04:55 PM, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---

Acked-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>

Best regards,
Marek Vasut

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

* Re: [PATCH 1/2] i2c: bcm2835: Use devm_ioremap_resource()
       [not found] ` <001101cf2729$890d5b10$9b281130$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2014-02-11 13:04   ` [PATCH 2/2] i2c: mxs: " Jingoo Han
  2014-02-12  5:11   ` [PATCH 1/2] i2c: bcm2835: " Stephen Warren
@ 2014-03-09 20:46   ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-03-09 20:46 UTC (permalink / raw)
  To: Jingoo Han
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Stephen Warren',
	'Florian Meier'

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

On Tue, Feb 11, 2014 at 10:02:36PM +0900, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 2/2] i2c: mxs: Use devm_ioremap_resource()
       [not found]     ` <001a01cf2729$dc23cd70$946b6850$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2014-02-12  3:33       ` Shawn Guo
  2014-02-12  7:36       ` Marek Vasut
@ 2014-03-09 20:47       ` Wolfram Sang
  2014-03-09 23:34         ` [PATCH V2] " Jingoo Han
  2 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2014-03-09 20:47 UTC (permalink / raw)
  To: Jingoo Han
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Marek Vasut',
	'Shawn Guo', 'Sascha Hauer'

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]


> -	if (!res || irq < 0)
> +	irq = platform_get_irq(pdev, 0);
> +	if (irq < 0)
>  		return -ENOENT;

Please return irq here.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH V2] i2c: mxs: Use devm_ioremap_resource()
  2014-03-09 20:47       ` Wolfram Sang
@ 2014-03-09 23:34         ` Jingoo Han
       [not found]           ` <006501cf3bf0$12411a40$36c34ec0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Jingoo Han @ 2014-03-09 23:34 UTC (permalink / raw)
  To: 'Wolfram Sang'
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Marek Vasut',
	'Shawn Guo', 'Sascha Hauer', 'Jingoo Han'

Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because the value is checked by devm_ioremap_resource().

Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Acked-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Acked-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
---
Changes since v1:
- Replace 'return -ENOENT' with 'return irq' when returning error
  values from platform_get_irq(), per Wolfram Sang

 drivers/i2c/busses/i2c-mxs.c |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 0cde4e6..7170fc8 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -806,7 +806,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	struct mxs_i2c_dev *i2c;
 	struct i2c_adapter *adap;
 	struct resource *res;
-	resource_size_t res_size;
 	int err, irq;
 
 	i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL);
@@ -819,18 +818,13 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	irq = platform_get_irq(pdev, 0);
-
-	if (!res || irq < 0)
-		return -ENOENT;
+	i2c->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(i2c->regs))
+		return PTR_ERR(i2c->regs);
 
-	res_size = resource_size(res);
-	if (!devm_request_mem_region(dev, res->start, res_size, res->name))
-		return -EBUSY;
-
-	i2c->regs = devm_ioremap_nocache(dev, res->start, res_size);
-	if (!i2c->regs)
-		return -EBUSY;
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
 
 	err = devm_request_irq(dev, irq, mxs_i2c_isr, 0, dev_name(dev), i2c);
 	if (err)
-- 
1.7.10.4

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

* Re: [PATCH V2] i2c: mxs: Use devm_ioremap_resource()
       [not found]           ` <006501cf3bf0$12411a40$36c34ec0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2014-03-10  7:30             ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2014-03-10  7:30 UTC (permalink / raw)
  To: Jingoo Han
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, 'Marek Vasut',
	'Shawn Guo', 'Sascha Hauer'

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

On Mon, Mar 10, 2014 at 08:34:10AM +0900, Jingoo Han wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> Acked-by: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Acked-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-03-10  7:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-11 13:02 [PATCH 1/2] i2c: bcm2835: Use devm_ioremap_resource() Jingoo Han
     [not found] ` <001101cf2729$890d5b10$9b281130$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-02-11 13:04   ` [PATCH 2/2] i2c: mxs: " Jingoo Han
     [not found]     ` <001a01cf2729$dc23cd70$946b6850$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-02-12  3:33       ` Shawn Guo
2014-02-12  7:36       ` Marek Vasut
2014-03-09 20:47       ` Wolfram Sang
2014-03-09 23:34         ` [PATCH V2] " Jingoo Han
     [not found]           ` <006501cf3bf0$12411a40$36c34ec0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-03-10  7:30             ` Wolfram Sang
2014-02-12  5:11   ` [PATCH 1/2] i2c: bcm2835: " Stephen Warren
2014-03-09 20:46   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).