Skip to contentSkip to conversation

drivers: Provide devm_platform_ioremap_resource_byname()

PATCH In review Markus Elfring 5 participants 10 messages Jun 14, 2019 – Jun 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: Provide devm_platform_ioremap_resource_byname()

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

---
 drivers/base/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/base/platform.c +18 -0
index 4d1729853d1a..c1f19a479dd7 100644
@@ -97,6 +97,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+
+/**
+ * devm_platform_ioremap_resource_byname
+ * Call devm_ioremap_resource() for a platform device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource management
+ * @name: resource name
+ */
+void __iomem *devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+						    const char *name)
+{
+	struct resource *res;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	return devm_ioremap_resource(&pdev->dev, res);
+}
+EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
 #endif /* CONFIG_HAS_IOMEM */
 
 /**

--
2.22.0

Reviewed-by on v1 1/1
#1 lore raw

+Cc: Jack Ping, who did internally the same

Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Quoted 4 lines

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

This one makes sense.
Though I'm not sure Greg will see your message.

Rafael, maybe you can apply this one?

FWIW,

Quoted 38 lines
---
 drivers/base/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/base/platform.c +18 -1
index 4d1729853d1a..c1f19a479dd7 100644
@@ -97,6 +97,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+
+/**
+ * devm_platform_ioremap_resource_byname
+ * Call devm_ioremap_resource() for a platform device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource management
+ * @name: resource name
+ */
+void __iomem *devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+						    const char *name)
+{
+	struct resource *res;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	return devm_ioremap_resource(&pdev->dev, res);
+}
+EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
 #endif /* CONFIG_HAS_IOMEM */
 
 /**
--

2.22.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 11 lines · Andy Shevchenko

+Cc: Jack Ping, who did internally the same

Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Quoted 7 lines
Quoted 4 lines

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

This one makes sense.
Though I'm not sure Greg will see your message.

Nope, didn't see it, don't want to see it, it will only cause more work in the longrun...

Quoted 1 line

Rafael, maybe you can apply this one?

Um, don't go around maintainers please, that's rude. There is a reason this specific developer is in my blacklist, and perhaps they should be in yours as well :)

Quoted 28 lines

FWIW,

Quoted 25 lines
---
 drivers/base/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/base/platform.c +11 -0
index 4d1729853d1a..c1f19a479dd7 100644
@@ -97,6 +97,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
 	return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+
+/**
+ * devm_platform_ioremap_resource_byname
+ * Call devm_ioremap_resource() for a platform device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource management
+ * @name: resource name
+ */
+void __iomem *devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+						    const char *name)
Quoted 8 lines

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 118

Quoted 8 lines
drivers/base/platform.c +7 -0
+{
+	struct resource *res;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+	return devm_ioremap_resource(&pdev->dev, res);
+}
+EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
 #endif /* CONFIG_HAS_IOMEM */

I don't like adding new apis with no user.

thanks,

greg k-h

#3 lore raw
Quoted 20 lines · Greg Kroah-Hartman
Quoted 11 lines · Andy Shevchenko

+Cc: Jack Ping, who did internally the same

Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Quoted 7 lines
Quoted 4 lines

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

This one makes sense.
Though I'm not sure Greg will see your message.

Quoted 6 lines

Nope, didn't see it, don't want to see it, it will only cause more work in the longrun...

Quoted 1 line

Rafael, maybe you can apply this one?

Um, don't go around maintainers please, that's rude.

I won't do it, how should we proceed if de facto this functionality is good to have besides the fact of coming new user in the future?

Quoted 3 lines

There is a reason
this specific developer is in my blacklist, and perhaps they should be in yours as well :)

Perhaps.

Quoted 1 line

I don't like adding new apis with no user.

Perhaps Jack Ping will send it as a first patch of his series where he utilizes this functionality. Would it be acceptable?

That's why I Cc'ed him as well.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 35 lines · Andy Shevchenko
Quoted 20 lines · Greg Kroah-Hartman
Quoted 11 lines · Andy Shevchenko

+Cc: Jack Ping, who did internally the same

Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Quoted 7 lines
Quoted 4 lines

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

This one makes sense.
Though I'm not sure Greg will see your message.

Quoted 6 lines

Nope, didn't see it, don't want to see it, it will only cause more work in the longrun...

Quoted 1 line

Rafael, maybe you can apply this one?

Um, don't go around maintainers please, that's rude.

I won't do it, how should we proceed if de facto this functionality is good to have besides the fact of coming new user in the future?

Quoted 3 lines

There is a reason
this specific developer is in my blacklist, and perhaps they should be in yours as well :)

Quoted 6 lines

Perhaps.

Quoted 1 line

I don't like adding new apis with no user.

Perhaps Jack Ping will send it as a first patch of his series where he utilizes this functionality. Would it be acceptable?

Yes, that would be ok.

thanks,

greg k-h

#5 lore raw
In reply to Andy Shevchenko
Quoted 4 lines
Quoted 1 line

I don't like adding new apis with no user.

Perhaps Jack Ping will send it as a first patch of his series where he utilizes this functionality. Would it be acceptable?

The proposed function can get wider application in a reasonable time frame if a corresponding script for the semantic patch language (Coccinelle software) would perform an automatic source code conversion (for example) according to your change acceptance.
How do you think about to support a bit more collateral software evolution?

Regards,
Markus

#6 lore raw
Quoted 10 lines · Markus Elfring
Quoted 4 lines
Quoted 1 line

I don't like adding new apis with no user.

Perhaps Jack Ping will send it as a first patch of his series where he utilizes this functionality. Would it be acceptable?

The proposed function can get wider application in a reasonable time frame if a corresponding script for the semantic patch language (Coccinelle software) would perform an automatic source code conversion (for example) according to your change acceptance.
How do you think about to support a bit more collateral software evolution?

Why don't you just do what is asked for?

julia

#8 lore raw
In reply to Greg Kroah-Hartman
Quoted 21 lines · Greg Kroah-Hartman
Quoted 11 lines · Andy Shevchenko

+Cc: Jack Ping, who did internally the same

Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 14 Jun 2019 15:15:14 +0200

The functions “platform_get_resource_byname” and “devm_ioremap_resource” are called together in 181 source files.
This implementation detail can be determined also with the help of the semantic patch language (Coccinelle software).

Quoted 7 lines
Quoted 4 lines

Wrap these two calls into another helper function.
Thus a local variable does not need to be declared for a resource structure pointer before and a redundant argument can be omitted for the resource type.

This one makes sense.
Though I'm not sure Greg will see your message.

Quoted 6 lines

Nope, didn't see it, don't want to see it, it will only cause more work in the longrun...

Quoted 1 line

Rafael, maybe you can apply this one?

Um, don't go around maintainers please, that's rude.

Totally agreed.

And there would be no reason for me to even consider applying it, really.

Quoted 33 lines

There is a reason this specific developer is in my blacklist, and perhaps they should be in yours as well :)

Quoted 30 lines

FWIW,

Quoted 27 lines
---
 drivers/base/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/base/platform.c +13 -0
index 4d1729853d1a..c1f19a479dd7 100644
@@ -97,6 +97,24 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
    return devm_ioremap_resource(&pdev->dev, res);
 }
 EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
+
+/**
+ * devm_platform_ioremap_resource_byname
+ * Call devm_ioremap_resource() for a platform device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource management
+ * @name: resource name
+ */
+void __iomem *devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+                                               const char *name)
+{
+   struct resource *res;
Quoted 8 lines
Quoted 6 lines

drivers/base/platform.c void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, · line 118

Quoted 6 lines
drivers/base/platform.c +5 -0
+
+   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+   return devm_ioremap_resource(&pdev->dev, res);
+}
+EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname);
 #endif /* CONFIG_HAS_IOMEM */

I don't like adding new apis with no user.

I agree with that too.

Cheers!

#9 lore raw
Quoted 3 lines
Quoted 1 line

I don't like adding new apis with no user.

I agree with that too.

How do you think about the possibility to let an improved script for the semantic patch language (Coccinelle software) perform the desired software transformation so that the usage of an additional function would get introduced by a known algorithm?

Can an agreement be achieved for the function name before?

Regards,
Markus