linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource()
@ 2014-02-12  2:29 Jingoo Han
  2014-02-12  2:34 ` [PATCH 2/2] mtd: omap2: " Jingoo Han
  2014-02-23  2:19 ` [PATCH 1/2] mtd: denali_dt: " Brian Norris
  0 siblings, 2 replies; 7+ messages in thread
From: Jingoo Han @ 2014-02-12  2:29 UTC (permalink / raw)
  To: 'Brian Norris'
  Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
	'Dinh Nguyen'

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

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
index babb02c..35cb17f 100644
--- a/drivers/mtd/nand/denali_dt.c
+++ b/drivers/mtd/nand/denali_dt.c
@@ -30,24 +30,6 @@ struct denali_dt {
 	struct clk		*clk;
 };
 
-static void __iomem *request_and_map(struct device *dev,
-				     const struct resource *res)
-{
-	void __iomem *ptr;
-
-	if (!devm_request_mem_region(dev, res->start, resource_size(res),
-				     "denali-dt")) {
-		dev_err(dev, "unable to request %s\n", res->name);
-		return NULL;
-	}
-
-	ptr = devm_ioremap_nocache(dev, res->start, resource_size(res));
-	if (!ptr)
-		dev_err(dev, "ioremap_nocache of %s failed!", res->name);
-
-	return ptr;
-}
-
 static const struct of_device_id denali_nand_dt_ids[] = {
 		{ .compatible = "denali,denali-nand-dt" },
 		{ /* sentinel */ }
@@ -78,13 +60,6 @@ static int denali_dt_probe(struct platform_device *ofdev)
 		return -ENOMEM;
 	denali = &dt->denali;
 
-	denali_reg = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "denali_reg");
-	nand_data = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "nand_data");
-	if (!denali_reg || !nand_data) {
-		dev_err(&ofdev->dev, "resources not completely defined\n");
-		return -EINVAL;
-	}
-
 	denali->platform = DT;
 	denali->dev = &ofdev->dev;
 	denali->irq = platform_get_irq(ofdev, 0);
@@ -93,13 +68,15 @@ static int denali_dt_probe(struct platform_device *ofdev)
 		return denali->irq;
 	}
 
-	denali->flash_reg = request_and_map(&ofdev->dev, denali_reg);
-	if (!denali->flash_reg)
-		return -ENOMEM;
+	denali_reg = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "denali_reg");
+	denali->flash_reg = devm_ioremap_resource(&ofdev->dev, denali_reg);
+	if (IS_ERR(denali->flash_reg))
+		return PTR_ERR(denali->flash_reg);
 
-	denali->flash_mem = request_and_map(&ofdev->dev, nand_data);
-	if (!denali->flash_mem)
-		return -ENOMEM;
+	nand_data = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "nand_data");
+	denali->flash_mem = devm_ioremap_resource(&ofdev->dev, nand_data);
+	if (IS_ERR(denali->flash_mem))
+		return PTR_ERR(denali->flash_mem);
 
 	if (!of_property_read_u32(ofdev->dev.of_node,
 		"dma-mask", (u32 *)&denali_dma_mask)) {
-- 
1.7.10.4

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

* [PATCH 2/2] mtd: omap2: Use devm_ioremap_resource()
  2014-02-12  2:29 [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource() Jingoo Han
@ 2014-02-12  2:34 ` Jingoo Han
  2014-03-26  6:25   ` Brian Norris
  2014-02-23  2:19 ` [PATCH 1/2] mtd: denali_dt: " Brian Norris
  1 sibling, 1 reply; 7+ messages in thread
From: Jingoo Han @ 2014-02-12  2:34 UTC (permalink / raw)
  To: 'Brian Norris'
  Cc: linux-mtd, 'Jingoo Han', 'David Woodhouse',
	'Gupta, Pekon', 'Ezequiel Garcia'

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(). Also,
'unsigned long mem_size' is removed from 'struct omap_nand_info',
because the 'mem_size' variable is not necessary anymore.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mtd/nand/omap2.c |   23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ef4190a..2c44586 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -159,7 +159,6 @@ struct omap_nand_info {
 
 	int				gpmc_cs;
 	unsigned long			phys_base;
-	unsigned long			mem_size;
 	struct completion		comp;
 	struct dma_chan			*dma;
 	int				gpmc_irq_fifo;
@@ -1665,27 +1664,11 @@ static int omap_nand_probe(struct platform_device *pdev)
 	nand_chip->options	|= NAND_SKIP_BBTSCAN;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		err = -EINVAL;
-		dev_err(&pdev->dev, "error getting memory resource\n");
-		goto return_error;
-	}
+	nand_chip->IO_ADDR_R = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(nand_chip->IO_ADDR_R))
+		return PTR_ERR(nand_chip->IO_ADDR_R);
 
 	info->phys_base = res->start;
-	info->mem_size = resource_size(res);
-
-	if (!devm_request_mem_region(&pdev->dev, info->phys_base,
-				info->mem_size,	pdev->dev.driver->name)) {
-		err = -EBUSY;
-		goto return_error;
-	}
-
-	nand_chip->IO_ADDR_R = devm_ioremap(&pdev->dev, info->phys_base,
-						info->mem_size);
-	if (!nand_chip->IO_ADDR_R) {
-		err = -ENOMEM;
-		goto return_error;
-	}
 
 	nand_chip->controller = &info->controller;
 
-- 
1.7.10.4

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

* Re: [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource()
  2014-02-12  2:29 [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource() Jingoo Han
  2014-02-12  2:34 ` [PATCH 2/2] mtd: omap2: " Jingoo Han
@ 2014-02-23  2:19 ` Brian Norris
  1 sibling, 0 replies; 7+ messages in thread
From: Brian Norris @ 2014-02-23  2:19 UTC (permalink / raw)
  To: Jingoo Han; +Cc: linux-mtd, 'David Woodhouse', 'Dinh Nguyen'

Hi Dinh,

Do you have any comment on this patch?

Jingoo,

On Wed, Feb 12, 2014 at 11:29:42AM +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_byname() because the value is
> checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
>  drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
>  1 file changed, 8 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
> index babb02c..35cb17f 100644
> --- a/drivers/mtd/nand/denali_dt.c
> +++ b/drivers/mtd/nand/denali_dt.c
> @@ -30,24 +30,6 @@ struct denali_dt {
>  	struct clk		*clk;
>  };
>  
> -static void __iomem *request_and_map(struct device *dev,
> -				     const struct resource *res)
> -{
> -	void __iomem *ptr;
> -
> -	if (!devm_request_mem_region(dev, res->start, resource_size(res),
> -				     "denali-dt")) {
> -		dev_err(dev, "unable to request %s\n", res->name);
> -		return NULL;
> -	}
> -
> -	ptr = devm_ioremap_nocache(dev, res->start, resource_size(res));

Your code here is not a direct replacement; Dinh originally used the
_nocache variant of ioremap, but you are replacing it with the standard
one. There is no difference between the two on several ARCH's, but I
can't guarantee that your patch is safe without confirmation/testing. So
I will not take this without an Ack or Tested-by from someone
knowledgeable about denali.

> -	if (!ptr)
> -		dev_err(dev, "ioremap_nocache of %s failed!", res->name);
> -
> -	return ptr;
> -}
> -
>  static const struct of_device_id denali_nand_dt_ids[] = {
>  		{ .compatible = "denali,denali-nand-dt" },
>  		{ /* sentinel */ }
> @@ -78,13 +60,6 @@ static int denali_dt_probe(struct platform_device *ofdev)
>  		return -ENOMEM;
>  	denali = &dt->denali;
>  
> -	denali_reg = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "denali_reg");
> -	nand_data = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "nand_data");
> -	if (!denali_reg || !nand_data) {
> -		dev_err(&ofdev->dev, "resources not completely defined\n");
> -		return -EINVAL;
> -	}
> -
>  	denali->platform = DT;
>  	denali->dev = &ofdev->dev;
>  	denali->irq = platform_get_irq(ofdev, 0);
> @@ -93,13 +68,15 @@ static int denali_dt_probe(struct platform_device *ofdev)
>  		return denali->irq;
>  	}
>  
> -	denali->flash_reg = request_and_map(&ofdev->dev, denali_reg);
> -	if (!denali->flash_reg)
> -		return -ENOMEM;
> +	denali_reg = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "denali_reg");
> +	denali->flash_reg = devm_ioremap_resource(&ofdev->dev, denali_reg);
> +	if (IS_ERR(denali->flash_reg))
> +		return PTR_ERR(denali->flash_reg);
>  
> -	denali->flash_mem = request_and_map(&ofdev->dev, nand_data);
> -	if (!denali->flash_mem)
> -		return -ENOMEM;
> +	nand_data = platform_get_resource_byname(ofdev, IORESOURCE_MEM, "nand_data");
> +	denali->flash_mem = devm_ioremap_resource(&ofdev->dev, nand_data);
> +	if (IS_ERR(denali->flash_mem))
> +		return PTR_ERR(denali->flash_mem);
>  
>  	if (!of_property_read_u32(ofdev->dev.of_node,
>  		"dma-mask", (u32 *)&denali_dma_mask)) {

Thanks,
Brian

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

* Re: [PATCH 2/2] mtd: omap2: Use devm_ioremap_resource()
  2014-02-12  2:34 ` [PATCH 2/2] mtd: omap2: " Jingoo Han
@ 2014-03-26  6:25   ` Brian Norris
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Norris @ 2014-03-26  6:25 UTC (permalink / raw)
  To: Jingoo Han
  Cc: linux-mtd, 'David Woodhouse', 'Gupta, Pekon',
	'Ezequiel Garcia'

On Wed, Feb 12, 2014 at 11:34:37AM +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(). Also,
> 'unsigned long mem_size' is removed from 'struct omap_nand_info',
> because the 'mem_size' variable is not necessary anymore.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

Required a bit of rebasing, since Pekon has been making a few changes.
Pushed to l2-mtd.git!

Thanks,
Brian

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

* Re: [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource()
  2014-03-03  0:21   ` Jingoo Han
@ 2014-03-26  6:24     ` Brian Norris
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Norris @ 2014-03-26  6:24 UTC (permalink / raw)
  To: Jingoo Han
  Cc: 'Thierry Reding', linux-mtd, 'Lars-Peter Clausen',
	'David Woodhouse', 'Dinh Nguyen'

On Mon, Mar 03, 2014 at 09:21:06AM +0900, Jingoo Han wrote:
> On Saturday, March 01, 2014 1:21 AM, Dinh Nguyen wrote:
> > On Mon, 2014-02-24 at 01:08 +0000, Jingoo Han wrote:
> > > On Sunday, February 23, 2014 11:20 AM, Brian Norris wrote:
> > > > Your code here is not a direct replacement; Dinh originally used the
> > > > _nocache variant of ioremap, but you are replacing it with the standard
> > > > one. There is no difference between the two on several ARCH's, but I
> > > > can't guarantee that your patch is safe without confirmation/testing. So
> > > > I will not take this without an Ack or Tested-by from someone
> > > > knowledgeable about denali.
> > 
> > Sorry that it took a while to get around to this. But I was able to test
> > the patch and it looks fine.
> > 
> > Tested-by: Dinh Nguyen <dinguyen@altera.com>
> 
> I really appreciate your tested-by. :-)
> Thank you a lot.

Yes, thanks Dinh!

> > > According to the comment of devm_ioremap_resource(),
> > > 'devm_ioremap_resource()' ioremaps it either as cacheable or
> > > as non-cacheable memory depending on the resource's flags
> > > Thus, devm_ioremap_nocache() will be called automatically.

I see. Thanks for pointing that out. Pushed to l2-mtd.git!

Brian

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

* Re: [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource()
  2014-02-28 16:20 ` Dinh Nguyen
@ 2014-03-03  0:21   ` Jingoo Han
  2014-03-26  6:24     ` Brian Norris
  0 siblings, 1 reply; 7+ messages in thread
From: Jingoo Han @ 2014-03-03  0:21 UTC (permalink / raw)
  To: 'Dinh Nguyen'
  Cc: 'Lars-Peter Clausen', 'Jingoo Han',
	'Thierry Reding', linux-mtd, 'Brian Norris',
	'David Woodhouse'

On Saturday, March 01, 2014 1:21 AM, Dinh Nguyen wrote:
> On Mon, 2014-02-24 at 01:08 +0000, Jingoo Han wrote:
> > On Sunday, February 23, 2014 11:20 AM, Brian Norris wrote:
> > > On Wed, Feb 12, 2014 at 11:29:42AM +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_byname() because the value is
> > > > checked by devm_ioremap_resource().
> > > >
> > > > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> > > > ---
> > > >  drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
> > > >  1 file changed, 8 insertions(+), 31 deletions(-)
> > > >
> > > > diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
> > > > index babb02c..35cb17f 100644
> > > > --- a/drivers/mtd/nand/denali_dt.c
> > > > +++ b/drivers/mtd/nand/denali_dt.c
> > > > @@ -30,24 +30,6 @@ struct denali_dt {
> > > >  	struct clk		*clk;
> > > >  };
> > > >
> > > > -static void __iomem *request_and_map(struct device *dev,
> > > > -				     const struct resource *res)
> > > > -{
> > > > -	void __iomem *ptr;
> > > > -
> > > > -	if (!devm_request_mem_region(dev, res->start, resource_size(res),
> > > > -				     "denali-dt")) {
> > > > -		dev_err(dev, "unable to request %s\n", res->name);
> > > > -		return NULL;
> > > > -	}
> > > > -
> > > > -	ptr = devm_ioremap_nocache(dev, res->start, resource_size(res));
> > >
> > > Your code here is not a direct replacement; Dinh originally used the
> > > _nocache variant of ioremap, but you are replacing it with the standard
> > > one. There is no difference between the two on several ARCH's, but I
> > > can't guarantee that your patch is safe without confirmation/testing. So
> > > I will not take this without an Ack or Tested-by from someone
> > > knowledgeable about denali.
> >
> 
> Sorry that it took a while to get around to this. But I was able to test
> the patch and it looks fine.
> 
> Tested-by: Dinh Nguyen <dinguyen@altera.com>

Hi Dinh Nguyen,

I really appreciate your tested-by. :-)
Thank you a lot.

Best regards,
Jingoo Han

> 
> Thanks,
> Dinh
> > (+cc Lars-Peter Clausen, Thierry Reding)
> >
> > According to the comment of devm_ioremap_resource(),
> > 'devm_ioremap_resource()' ioremaps it either as cacheable or
> > as non-cacheable memory depending on the resource's flags
> > Thus, devm_ioremap_nocache() will be called automatically.
> >
> > ./lib/devres.c
> > void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
> > {
> > 	....
> >
> > 	if (res->flags & IORESOURCE_CACHEABLE)
> > 		dest_ptr = devm_ioremap(dev, res->start, size);
> > 	else
> > 		dest_ptr = devm_ioremap_nocache(dev, res->start, size);
> >
> > Best regards,
> > Jingoo Han

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

* Re: [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource()
       [not found] <17863671.112301393204091097.JavaMail.weblogic@epml01>
@ 2014-02-28 16:20 ` Dinh Nguyen
  2014-03-03  0:21   ` Jingoo Han
  0 siblings, 1 reply; 7+ messages in thread
From: Dinh Nguyen @ 2014-02-28 16:20 UTC (permalink / raw)
  To: Jingoo Han
  Cc: thierry.reding, linux-mtd, Brian Norris, 'David Woodhouse', lars

On Mon, 2014-02-24 at 01:08 +0000, Jingoo Han wrote:
> On Sunday, February 23, 2014 11:20 AM, Brian Norris wrote:
> > On Wed, Feb 12, 2014 at 11:29:42AM +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_byname() because the value is
> > > checked by devm_ioremap_resource().
> > >
> > > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> > > ---
> > >  drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
> > >  1 file changed, 8 insertions(+), 31 deletions(-)
> > >
> > > diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c
> > > index babb02c..35cb17f 100644
> > > --- a/drivers/mtd/nand/denali_dt.c
> > > +++ b/drivers/mtd/nand/denali_dt.c
> > > @@ -30,24 +30,6 @@ struct denali_dt {
> > >  	struct clk		*clk;
> > >  };
> > >
> > > -static void __iomem *request_and_map(struct device *dev,
> > > -				     const struct resource *res)
> > > -{
> > > -	void __iomem *ptr;
> > > -
> > > -	if (!devm_request_mem_region(dev, res->start, resource_size(res),
> > > -				     "denali-dt")) {
> > > -		dev_err(dev, "unable to request %s\n", res->name);
> > > -		return NULL;
> > > -	}
> > > -
> > > -	ptr = devm_ioremap_nocache(dev, res->start, resource_size(res));
> > 
> > Your code here is not a direct replacement; Dinh originally used the
> > _nocache variant of ioremap, but you are replacing it with the standard
> > one. There is no difference between the two on several ARCH's, but I
> > can't guarantee that your patch is safe without confirmation/testing. So
> > I will not take this without an Ack or Tested-by from someone
> > knowledgeable about denali.
> 

Sorry that it took a while to get around to this. But I was able to test
the patch and it looks fine.

Tested-by: Dinh Nguyen <dinguyen@altera.com>

Thanks,
Dinh
> (+cc Lars-Peter Clausen, Thierry Reding)
> 
> According to the comment of devm_ioremap_resource(), 
> 'devm_ioremap_resource()' ioremaps it either as cacheable or
> as non-cacheable memory depending on the resource's flags
> Thus, devm_ioremap_nocache() will be called automatically.
> 
> ./lib/devres.c
> void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
> {
> 	....
> 
> 	if (res->flags & IORESOURCE_CACHEABLE)
> 		dest_ptr = devm_ioremap(dev, res->start, size);
> 	else
> 		dest_ptr = devm_ioremap_nocache(dev, res->start, size);
> 
> Best regards,
> Jingoo Han

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

end of thread, other threads:[~2014-03-26  6:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12  2:29 [PATCH 1/2] mtd: denali_dt: Use devm_ioremap_resource() Jingoo Han
2014-02-12  2:34 ` [PATCH 2/2] mtd: omap2: " Jingoo Han
2014-03-26  6:25   ` Brian Norris
2014-02-23  2:19 ` [PATCH 1/2] mtd: denali_dt: " Brian Norris
     [not found] <17863671.112301393204091097.JavaMail.weblogic@epml01>
2014-02-28 16:20 ` Dinh Nguyen
2014-03-03  0:21   ` Jingoo Han
2014-03-26  6:24     ` Brian Norris

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).