Skip to contentSkip to conversation

mtd: denali_dt: Use devm_ioremap_resource()

PATCH Dinh Nguyen 3 participants 3 messages Feb 28, 2014 – Mar 26, 2014 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

Dinh Nguyen

author Tested-by
#1 lore raw
In reply to a message not in the archive
Quoted 31 lines · Jingoo Han
Quoted 30 lines · Brian Norris
Quoted 29 lines · Jingoo Han

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

---
 drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)
drivers/mtd/nand/denali_dt.c +0 -11
index babb02c..35cb17f 100644
@@ -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;
-	}
-
Quoted 9 lines
Quoted 8 lines

drivers/mtd/nand/denali_dt.c struct denali_dt { · line 44

Quoted 1 line
drivers/mtd/nand/denali_dt.c +0 -1
-	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.

Thanks,
Dinh

Quoted 19 lines

(+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

#2 lore raw
Quoted 42 lines · Dinh Nguyen
Quoted 31 lines · Jingoo Han
Quoted 30 lines · Brian Norris
Quoted 29 lines · Jingoo Han

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

---
 drivers/mtd/nand/denali_dt.c |   39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)
drivers/mtd/nand/denali_dt.c +0 -11
index babb02c..35cb17f 100644
@@ -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;
-	}
-
Quoted 9 lines
Quoted 8 lines

drivers/mtd/nand/denali_dt.c struct denali_dt { · line 44

Quoted 1 line
drivers/mtd/nand/denali_dt.c +0 -1
-	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.

Quoted 4 lines

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

Hi Dinh Nguyen,

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

Best regards,
Jingoo Han

Quoted 22 lines

Thanks,
Dinh

Quoted 19 lines

(+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

#3 lore raw
Quoted 10 lines · Jingoo Han
Quoted 9 lines · Dinh Nguyen
Quoted 7 lines · Jingoo Han
Quoted 6 lines · Brian Norris

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.

Quoted 7 lines
Quoted 4 lines

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

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

Yes, thanks Dinh!

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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