* [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
@ 2019-10-22 8:43 Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Note: resending with Arnd's review tags and rebased on top of char-misc-next
The new devm_platform_ioremap_resource() helper has now been widely
adopted and used in many drivers. Users of the write-combined ioremap()
variants could benefit from the same code shrinkage. This series provides
a write-combined version of devm_platform_ioremap_resource() and uses it in a
relevant driver with the assumption that - just like was the case
previously - a coccinelle script will be developed to ease the transition
for others.
There are also users of platform_get_resource_byname() who call
devm_ioremap_resource() next, so provide another variant that they can use
together with two examples.
v1 -> v2:
- dropped everything related to nocache ioremap as this is going away
v2 -> v3:
- don't call platform_get_resource() as an argument of devm_ioremap_resource(),
it actually decreases readability
- add devm_platform_ioremap_resource_byname() as another variant
Bartosz Golaszewski (8):
Documentation: devres: add missing entry for
devm_platform_ioremap_resource()
lib: devres: prepare devm_ioremap_resource() for more variants
lib: devres: provide devm_ioremap_resource_wc()
drivers: platform: provide devm_platform_ioremap_resource_wc()
misc: sram: use devm_platform_ioremap_resource_wc()
drivers: provide devm_platform_ioremap_resource_byname()
gpio: mvebu: use devm_platform_ioremap_resource_byname()
gpio: tegra186: use devm_platform_ioremap_resource_byname()
.../driver-api/driver-model/devres.rst | 4 ++
drivers/base/platform.c | 39 +++++++++++-
drivers/gpio/gpio-mvebu.c | 19 +++---
drivers/gpio/gpio-tegra186.c | 4 +-
drivers/misc/sram.c | 28 +++------
include/linux/device.h | 2 +
include/linux/platform_device.h | 6 ++
lib/devres.c | 62 +++++++++++++------
8 files changed, 108 insertions(+), 56 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants Bartosz Golaszewski
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
devm_platform_ioremap_resource() should be documented in devres.rst.
Add the missing entry.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
Documentation/driver-api/driver-model/devres.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index a100bef54952..8e3087662daf 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -316,6 +316,7 @@ IOMAP
devm_ioremap_nocache()
devm_ioremap_wc()
devm_ioremap_resource() : checks resource, requests memory region, ioremaps
+ devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
devm_iounmap()
pcim_iomap()
pcim_iomap_regions() : do request_region() and iomap() on multiple BARs
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc() Bartosz Golaszewski
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
We want to add the write-combined variant of devm_ioremap_resource().
Let's first implement __devm_ioremap_resource() which takes
an additional argument type. The types are the same as for
__devm_ioremap(). The existing devm_ioremap_resource() now simply
calls __devm_ioremap_resource() with regular DEVM_IOREMAP type.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
lib/devres.c | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/lib/devres.c b/lib/devres.c
index 6a0e9bd6524a..a14c727128c1 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -114,25 +114,9 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
}
EXPORT_SYMBOL(devm_iounmap);
-/**
- * devm_ioremap_resource() - check, request region, and ioremap resource
- * @dev: generic device to handle the resource for
- * @res: resource to be handled
- *
- * Checks that a resource is a valid memory region, requests the memory
- * region and ioremaps it. All operations are managed and will be undone
- * on driver detach.
- *
- * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
- * on failure. Usage example:
- *
- * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- * base = devm_ioremap_resource(&pdev->dev, res);
- * if (IS_ERR(base))
- * return PTR_ERR(base);
- */
-void __iomem *devm_ioremap_resource(struct device *dev,
- const struct resource *res)
+static void __iomem *
+__devm_ioremap_resource(struct device *dev, const struct resource *res,
+ enum devm_ioremap_type type)
{
resource_size_t size;
void __iomem *dest_ptr;
@@ -151,7 +135,7 @@ void __iomem *devm_ioremap_resource(struct device *dev,
return IOMEM_ERR_PTR(-EBUSY);
}
- dest_ptr = devm_ioremap(dev, res->start, size);
+ dest_ptr = __devm_ioremap(dev, res->start, size, type);
if (!dest_ptr) {
dev_err(dev, "ioremap failed for resource %pR\n", res);
devm_release_mem_region(dev, res->start, size);
@@ -160,6 +144,29 @@ void __iomem *devm_ioremap_resource(struct device *dev,
return dest_ptr;
}
+
+/**
+ * devm_ioremap_resource() - check, request region, and ioremap resource
+ * @dev: generic device to handle the resource for
+ * @res: resource to be handled
+ *
+ * Checks that a resource is a valid memory region, requests the memory
+ * region and ioremaps it. All operations are managed and will be undone
+ * on driver detach.
+ *
+ * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure. Usage example:
+ *
+ * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ * base = devm_ioremap_resource(&pdev->dev, res);
+ * if (IS_ERR(base))
+ * return PTR_ERR(base);
+ */
+void __iomem *devm_ioremap_resource(struct device *dev,
+ const struct resource *res)
+{
+ return __devm_ioremap_resource(dev, res, DEVM_IOREMAP);
+}
EXPORT_SYMBOL(devm_ioremap_resource);
/*
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc() Bartosz Golaszewski
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Provide a variant of devm_ioremap_resource() for write-combined ioremap.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
Documentation/driver-api/driver-model/devres.rst | 1 +
include/linux/device.h | 2 ++
lib/devres.c | 15 +++++++++++++++
3 files changed, 18 insertions(+)
diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index 8e3087662daf..e605bb9df6e1 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -316,6 +316,7 @@ IOMAP
devm_ioremap_nocache()
devm_ioremap_wc()
devm_ioremap_resource() : checks resource, requests memory region, ioremaps
+ devm_ioremap_resource_wc()
devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
devm_iounmap()
pcim_iomap()
diff --git a/include/linux/device.h b/include/linux/device.h
index 297239a08bb7..1f4aaf2d4b2a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -946,6 +946,8 @@ extern void devm_free_pages(struct device *dev, unsigned long addr);
void __iomem *devm_ioremap_resource(struct device *dev,
const struct resource *res);
+void __iomem *devm_ioremap_resource_wc(struct device *dev,
+ const struct resource *res);
void __iomem *devm_of_iomap(struct device *dev,
struct device_node *node, int index,
diff --git a/lib/devres.c b/lib/devres.c
index a14c727128c1..97fb44e5b4d6 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -169,6 +169,21 @@ void __iomem *devm_ioremap_resource(struct device *dev,
}
EXPORT_SYMBOL(devm_ioremap_resource);
+/**
+ * devm_ioremap_resource_wc() - write-combined variant of
+ * devm_ioremap_resource()
+ * @dev: generic device to handle the resource for
+ * @res: resource to be handled
+ *
+ * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure. Usage example:
+ */
+void __iomem *devm_ioremap_resource_wc(struct device *dev,
+ const struct resource *res)
+{
+ return __devm_ioremap_resource(dev, res, DEVM_IOREMAP_WC);
+}
+
/*
* devm_of_iomap - Requests a resource and maps the memory mapped IO
* for a given device_node managed by a given device
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (2 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc() Bartosz Golaszewski
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Provide a write-combined variant of devm_platform_ioremap_resource().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
.../driver-api/driver-model/devres.rst | 1 +
drivers/base/platform.c | 19 ++++++++++++++++++-
include/linux/platform_device.h | 3 +++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index e605bb9df6e1..480b78ca3871 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -318,6 +318,7 @@ IOMAP
devm_ioremap_resource() : checks resource, requests memory region, ioremaps
devm_ioremap_resource_wc()
devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
+ devm_platform_ioremap_resource_wc()
devm_iounmap()
pcim_iomap()
pcim_iomap_regions() : do request_region() and iomap() on multiple BARs
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b230beb6ccb4..177010c27516 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -60,6 +60,7 @@ struct resource *platform_get_resource(struct platform_device *dev,
}
EXPORT_SYMBOL_GPL(platform_get_resource);
+#ifdef CONFIG_HAS_IOMEM
/**
* devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
* device
@@ -68,7 +69,6 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
* resource management
* @index: resource index
*/
-#ifdef CONFIG_HAS_IOMEM
void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
unsigned int index)
{
@@ -78,6 +78,23 @@ 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_wc - write-combined variant of
+ * devm_platform_ioremap_resource()
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ * resource management
+ * @index: resource index
+ */
+void __iomem *devm_platform_ioremap_resource_wc(struct platform_device *pdev,
+ unsigned int index)
+{
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, index);
+ return devm_ioremap_resource_wc(&pdev->dev, res);
+}
#endif /* CONFIG_HAS_IOMEM */
static int __platform_get_irq(struct platform_device *dev, unsigned int num)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index f2688404d1cd..74cecb919e5c 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -57,6 +57,9 @@ platform_find_device_by_driver(struct device *start,
extern void __iomem *
devm_platform_ioremap_resource(struct platform_device *pdev,
unsigned int index);
+extern void __iomem *
+devm_platform_ioremap_resource_wc(struct platform_device *pdev,
+ unsigned int index);
extern int platform_get_irq(struct platform_device *, unsigned int);
extern int platform_get_irq_optional(struct platform_device *, unsigned int);
extern int platform_irq_count(struct platform_device *);
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (3 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname() Bartosz Golaszewski
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Use the new devm_platform_ioremap_resource_wc() helper instead of
devm_ioremap_wc() combinded with a call to platform_get_resource().
Also use devm_platform_ioremap_resource() where applicable.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/misc/sram.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index f30448bf3a63..6c1a23cb3e8c 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -340,8 +340,6 @@ static const struct of_device_id sram_dt_ids[] = {
static int sram_probe(struct platform_device *pdev)
{
struct sram_dev *sram;
- struct resource *res;
- size_t size;
int ret;
int (*init_func)(void);
@@ -351,25 +349,14 @@ static int sram_probe(struct platform_device *pdev)
sram->dev = &pdev->dev;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(sram->dev, "found no memory resource\n");
- return -EINVAL;
- }
-
- size = resource_size(res);
-
- if (!devm_request_mem_region(sram->dev, res->start, size, pdev->name)) {
- dev_err(sram->dev, "could not request region for resource\n");
- return -EBUSY;
- }
-
if (of_property_read_bool(pdev->dev.of_node, "no-memory-wc"))
- sram->virt_base = devm_ioremap(sram->dev, res->start, size);
+ sram->virt_base = devm_platform_ioremap_resource(pdev, 0);
else
- sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size);
- if (!sram->virt_base)
- return -ENOMEM;
+ sram->virt_base = devm_platform_ioremap_resource_wc(pdev, 0);
+ if (IS_ERR(sram->virt_base)) {
+ dev_err(&pdev->dev, "could not map SRAM registers\n");
+ return PTR_ERR(sram->virt_base);
+ }
sram->pool = devm_gen_pool_create(sram->dev, ilog2(SRAM_GRANULARITY),
NUMA_NO_NODE, NULL);
@@ -382,7 +369,8 @@ static int sram_probe(struct platform_device *pdev)
else
clk_prepare_enable(sram->clk);
- ret = sram_reserve_regions(sram, res);
+ ret = sram_reserve_regions(sram,
+ platform_get_resource(pdev, IORESOURCE_MEM, 0));
if (ret)
goto err_disable_clk;
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (4 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Provide a variant of devm_platform_ioremap_resource() that allows to
lookup resources from platform devices by name rather than by index.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
.../driver-api/driver-model/devres.rst | 1 +
drivers/base/platform.c | 20 +++++++++++++++++++
include/linux/platform_device.h | 3 +++
3 files changed, 24 insertions(+)
diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index 480b78ca3871..4ab193319d8c 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -319,6 +319,7 @@ IOMAP
devm_ioremap_resource_wc()
devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
devm_platform_ioremap_resource_wc()
+ devm_platform_ioremap_resource_byname()
devm_iounmap()
pcim_iomap()
pcim_iomap_regions() : do request_region() and iomap() on multiple BARs
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 177010c27516..5cdd72a9e186 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -95,6 +95,26 @@ void __iomem *devm_platform_ioremap_resource_wc(struct platform_device *pdev,
res = platform_get_resource(pdev, IORESOURCE_MEM, index);
return devm_ioremap_resource_wc(&pdev->dev, res);
}
+
+/**
+ * devm_platform_ioremap_resource_byname - call devm_ioremap_resource for
+ * a platform device, retrieve the
+ * resource by name
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ * resource management
+ * @name: name of the resource
+ */
+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 */
static int __platform_get_irq(struct platform_device *dev, unsigned int num)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 74cecb919e5c..43fe441a98ea 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -60,6 +60,9 @@ devm_platform_ioremap_resource(struct platform_device *pdev,
extern void __iomem *
devm_platform_ioremap_resource_wc(struct platform_device *pdev,
unsigned int index);
+extern void __iomem *
+devm_platform_ioremap_resource_byname(struct platform_device *pdev,
+ const char *name);
extern int platform_get_irq(struct platform_device *, unsigned int);
extern int platform_get_irq_optional(struct platform_device *, unsigned int);
extern int platform_irq_count(struct platform_device *);
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (5 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-11-04 15:05 ` Linus Walleij
2019-10-22 8:43 ` [RESEND PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
` (2 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Use devm_platform_ioremap_resource_byname() instead of calling
platform_get_resource_byname() and devm_ioremap_resource() separately.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpio/gpio-mvebu.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 6c0687694341..2f0f50336b9a 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -773,23 +773,12 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
{
struct device *dev = &pdev->dev;
struct mvebu_pwm *mvpwm;
- struct resource *res;
u32 set;
if (!of_device_is_compatible(mvchip->chip.of_node,
"marvell,armada-370-gpio"))
return 0;
- /*
- * There are only two sets of PWM configuration registers for
- * all the GPIO lines on those SoCs which this driver reserves
- * for the first two GPIO chips. So if the resource is missing
- * we can't treat it as an error.
- */
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm");
- if (!res)
- return 0;
-
if (IS_ERR(mvchip->clk))
return PTR_ERR(mvchip->clk);
@@ -812,7 +801,13 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
mvchip->mvpwm = mvpwm;
mvpwm->mvchip = mvchip;
- mvpwm->membase = devm_ioremap_resource(dev, res);
+ /*
+ * There are only two sets of PWM configuration registers for
+ * all the GPIO lines on those SoCs which this driver reserves
+ * for the first two GPIO chips. So if the resource is missing
+ * we can't treat it as an error.
+ */
+ mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm");
if (IS_ERR(mvpwm->membase))
return PTR_ERR(mvpwm->membase);
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RESEND PATCH v3 8/8] gpio: tegra186: use devm_platform_ioremap_resource_byname()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (6 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
@ 2019-10-22 8:43 ` Bartosz Golaszewski
2019-11-04 15:06 ` Linus Walleij
2019-11-04 9:29 ` [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-11-05 17:33 ` Greg Kroah-Hartman
9 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-10-22 8:43 UTC (permalink / raw)
To: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linus Walleij
Cc: linux-doc, linux-kernel, linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Use the devm_platform_ioremap_resource_byname() helper instead of
calling platform_get_resource_byname() and devm_ioremap_resource()
separately.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpio/gpio-tegra186.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index a9058fda187e..ef40fbe923cf 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -407,7 +407,6 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
unsigned int i, j, offset;
struct gpio_irq_chip *irq;
struct tegra_gpio *gpio;
- struct resource *res;
char **names;
int err;
@@ -417,8 +416,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
gpio->soc = of_device_get_match_data(&pdev->dev);
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpio");
- gpio->base = devm_ioremap_resource(&pdev->dev, res);
+ gpio->base = devm_platform_ioremap_resource_byname(pdev, "gpio");
if (IS_ERR(gpio->base))
return PTR_ERR(gpio->base);
--
2.23.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (7 preceding siblings ...)
2019-10-22 8:43 ` [RESEND PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
@ 2019-11-04 9:29 ` Bartosz Golaszewski
2019-11-04 10:24 ` Greg Kroah-Hartman
2019-11-05 17:33 ` Greg Kroah-Hartman
9 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2019-11-04 9:29 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-doc, Jonathan Corbet, Linus Walleij, Arnd Bergmann,
Rafael J . Wysocki, Linux Kernel Mailing List,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
wt., 22 paź 2019 o 10:43 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
>
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Note: resending with Arnd's review tags and rebased on top of char-misc-next
>
> The new devm_platform_ioremap_resource() helper has now been widely
> adopted and used in many drivers. Users of the write-combined ioremap()
> variants could benefit from the same code shrinkage. This series provides
> a write-combined version of devm_platform_ioremap_resource() and uses it in a
> relevant driver with the assumption that - just like was the case
> previously - a coccinelle script will be developed to ease the transition
> for others.
>
> There are also users of platform_get_resource_byname() who call
> devm_ioremap_resource() next, so provide another variant that they can use
> together with two examples.
>
> v1 -> v2:
> - dropped everything related to nocache ioremap as this is going away
>
> v2 -> v3:
> - don't call platform_get_resource() as an argument of devm_ioremap_resource(),
> it actually decreases readability
> - add devm_platform_ioremap_resource_byname() as another variant
>
> Bartosz Golaszewski (8):
> Documentation: devres: add missing entry for
> devm_platform_ioremap_resource()
> lib: devres: prepare devm_ioremap_resource() for more variants
> lib: devres: provide devm_ioremap_resource_wc()
> drivers: platform: provide devm_platform_ioremap_resource_wc()
> misc: sram: use devm_platform_ioremap_resource_wc()
> drivers: provide devm_platform_ioremap_resource_byname()
> gpio: mvebu: use devm_platform_ioremap_resource_byname()
> gpio: tegra186: use devm_platform_ioremap_resource_byname()
>
> .../driver-api/driver-model/devres.rst | 4 ++
> drivers/base/platform.c | 39 +++++++++++-
> drivers/gpio/gpio-mvebu.c | 19 +++---
> drivers/gpio/gpio-tegra186.c | 4 +-
> drivers/misc/sram.c | 28 +++------
> include/linux/device.h | 2 +
> include/linux/platform_device.h | 6 ++
> lib/devres.c | 62 +++++++++++++------
> 8 files changed, 108 insertions(+), 56 deletions(-)
>
> --
> 2.23.0
>
Hi Greg,
can you pick it up for char-misc for v5.5? This was reviewed by Arnd.
Best regards,
Bartosz Golaszewski
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-11-04 9:29 ` [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-11-04 10:24 ` Greg Kroah-Hartman
0 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2019-11-04 10:24 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: linux-doc, Jonathan Corbet, Linus Walleij, Arnd Bergmann,
Rafael J . Wysocki, Linux Kernel Mailing List,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
On Mon, Nov 04, 2019 at 10:29:23AM +0100, Bartosz Golaszewski wrote:
> wt., 22 paź 2019 o 10:43 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
> >
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Note: resending with Arnd's review tags and rebased on top of char-misc-next
> >
> > The new devm_platform_ioremap_resource() helper has now been widely
> > adopted and used in many drivers. Users of the write-combined ioremap()
> > variants could benefit from the same code shrinkage. This series provides
> > a write-combined version of devm_platform_ioremap_resource() and uses it in a
> > relevant driver with the assumption that - just like was the case
> > previously - a coccinelle script will be developed to ease the transition
> > for others.
> >
> > There are also users of platform_get_resource_byname() who call
> > devm_ioremap_resource() next, so provide another variant that they can use
> > together with two examples.
> >
> > v1 -> v2:
> > - dropped everything related to nocache ioremap as this is going away
> >
> > v2 -> v3:
> > - don't call platform_get_resource() as an argument of devm_ioremap_resource(),
> > it actually decreases readability
> > - add devm_platform_ioremap_resource_byname() as another variant
> >
> > Bartosz Golaszewski (8):
> > Documentation: devres: add missing entry for
> > devm_platform_ioremap_resource()
> > lib: devres: prepare devm_ioremap_resource() for more variants
> > lib: devres: provide devm_ioremap_resource_wc()
> > drivers: platform: provide devm_platform_ioremap_resource_wc()
> > misc: sram: use devm_platform_ioremap_resource_wc()
> > drivers: provide devm_platform_ioremap_resource_byname()
> > gpio: mvebu: use devm_platform_ioremap_resource_byname()
> > gpio: tegra186: use devm_platform_ioremap_resource_byname()
> >
> > .../driver-api/driver-model/devres.rst | 4 ++
> > drivers/base/platform.c | 39 +++++++++++-
> > drivers/gpio/gpio-mvebu.c | 19 +++---
> > drivers/gpio/gpio-tegra186.c | 4 +-
> > drivers/misc/sram.c | 28 +++------
> > include/linux/device.h | 2 +
> > include/linux/platform_device.h | 6 ++
> > lib/devres.c | 62 +++++++++++++------
> > 8 files changed, 108 insertions(+), 56 deletions(-)
> >
> > --
> > 2.23.0
> >
>
> Hi Greg,
>
> can you pick it up for char-misc for v5.5? This was reviewed by Arnd.
Yes, sorry, am backlogged on patches at the moment, will get to it this
week...
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname()
2019-10-22 8:43 ` [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
@ 2019-11-04 15:05 ` Linus Walleij
0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2019-11-04 15:05 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linux Doc Mailing List, linux-kernel,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
On Tue, Oct 22, 2019 at 10:43 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Use devm_platform_ioremap_resource_byname() instead of calling
> platform_get_resource_byname() and devm_ioremap_resource() separately.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v3 8/8] gpio: tegra186: use devm_platform_ioremap_resource_byname()
2019-10-22 8:43 ` [RESEND PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
@ 2019-11-04 15:06 ` Linus Walleij
0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2019-11-04 15:06 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Jonathan Corbet, Greg Kroah-Hartman, Rafael J . Wysocki,
Arnd Bergmann, Linux Doc Mailing List, linux-kernel,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
On Tue, Oct 22, 2019 at 10:43 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Use the devm_platform_ioremap_resource_byname() helper instead of
> calling platform_get_resource_byname() and devm_ioremap_resource()
> separately.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (8 preceding siblings ...)
2019-11-04 9:29 ` [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-11-05 17:33 ` Greg Kroah-Hartman
9 siblings, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2019-11-05 17:33 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Jonathan Corbet, Rafael J . Wysocki, Arnd Bergmann,
Linus Walleij, linux-doc, linux-kernel, linux-gpio,
Bartosz Golaszewski
On Tue, Oct 22, 2019 at 10:43:10AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Note: resending with Arnd's review tags and rebased on top of char-misc-next
>
> The new devm_platform_ioremap_resource() helper has now been widely
> adopted and used in many drivers. Users of the write-combined ioremap()
> variants could benefit from the same code shrinkage. This series provides
> a write-combined version of devm_platform_ioremap_resource() and uses it in a
> relevant driver with the assumption that - just like was the case
> previously - a coccinelle script will be developed to ease the transition
> for others.
>
> There are also users of platform_get_resource_byname() who call
> devm_ioremap_resource() next, so provide another variant that they can use
> together with two examples.
I've queued these up in my driver-core tree as there were some conflicts
with other work that happened in platform.h and device.h that I figured
would be good to get out of the way now and not have to wait until the
merge window to resolve.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2019-11-05 17:39 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 8:43 [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname() Bartosz Golaszewski
2019-10-22 8:43 ` [RESEND PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
2019-11-04 15:05 ` Linus Walleij
2019-10-22 8:43 ` [RESEND PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
2019-11-04 15:06 ` Linus Walleij
2019-11-04 9:29 ` [RESEND PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-11-04 10:24 ` Greg Kroah-Hartman
2019-11-05 17:33 ` Greg Kroah-Hartman
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).