* [PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants Bartosz Golaszewski
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* [PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc() Bartosz Golaszewski
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* [PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 1/8] Documentation: devres: add missing entry for devm_platform_ioremap_resource() Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 2/8] lib: devres: prepare devm_ioremap_resource() for more variants Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc() Bartosz Golaszewski
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* [PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (2 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 3/8] lib: devres: provide devm_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc() Bartosz Golaszewski
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
.../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 b6c6c7d97d5b..d481b8a7d4fc 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 1b5cec067533..83930790c701 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] 16+ messages in thread
* [PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (3 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 4/8] drivers: platform: provide devm_platform_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname() Bartosz Golaszewski
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* [PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (4 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 5/8] misc: sram: use devm_platform_ioremap_resource_wc() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
.../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 d481b8a7d4fc..265d34253865 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 83930790c701..fea5563f6fcf 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] 16+ messages in thread
* [PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (5 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 6/8] drivers: provide devm_platform_ioremap_resource_byname() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-06 5:39 ` [PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
2019-10-21 15:04 ` [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* [PATCH v3 8/8] gpio: tegra186: use devm_platform_ioremap_resource_byname()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (6 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 7/8] gpio: mvebu: use devm_platform_ioremap_resource_byname() Bartosz Golaszewski
@ 2019-10-06 5:39 ` Bartosz Golaszewski
2019-10-21 15:04 ` [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-06 5:39 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>
---
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] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-06 5:39 [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
` (7 preceding siblings ...)
2019-10-06 5:39 ` [PATCH v3 8/8] gpio: tegra186: " Bartosz Golaszewski
@ 2019-10-21 15:04 ` Bartosz Golaszewski
2019-10-21 15:52 ` Arnd Bergmann
8 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-21 15:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arnd Bergmann
Cc: linux-doc, Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
Bartosz Golaszewski, Jonathan Corbet, Rafael J . Wysocki,
Linus Walleij
niedz., 6 paź 2019 o 07:39 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
>
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> 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
>
Greg, Arnd,
gentle ping for this. I noticed that some maintainers are complaining
about being spammed with patches converting old drivers to using
devm_platform_ioremap_resource() and there's even a patch removing the
relevant coccinelle script on the list, but I think for new drivers
these are still useful. Do you want to pick them up for v5.5 (or at
all)?
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-21 15:04 ` [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource() Bartosz Golaszewski
@ 2019-10-21 15:52 ` Arnd Bergmann
2019-10-21 16:29 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2019-10-21 15:52 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Greg Kroah-Hartman, linux-doc, Linux Kernel Mailing List,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Jonathan Corbet,
Rafael J . Wysocki, Linus Walleij, Christoph Hellwig
On Mon, Oct 21, 2019 at 5:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> niedz., 6 paź 2019 o 07:39 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > 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(-)
>
> Greg, Arnd,
>
> gentle ping for this. I noticed that some maintainers are complaining
> about being spammed with patches converting old drivers to using
> devm_platform_ioremap_resource() and there's even a patch removing the
> relevant coccinelle script on the list, but I think for new drivers
> these are still useful. Do you want to pick them up for v5.5 (or at
> all)?
I think this series is useful and we should merge it. Are there any
remaining dependencies or conflicts with Christoph Hellwig's recent
__ioremap rework? If there are, I would prioritize his work and maybe
delay this one by another merge window, otherwise please add
my Reviewed-by to all patches and resend them for Greg to pick
up (provided he has no objections).
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-21 15:52 ` Arnd Bergmann
@ 2019-10-21 16:29 ` Bartosz Golaszewski
2019-10-21 19:29 ` Arnd Bergmann
0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-21 16:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Kroah-Hartman, linux-doc, Linux Kernel Mailing List,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Jonathan Corbet,
Rafael J . Wysocki, Linus Walleij, Christoph Hellwig
pon., 21 paź 2019 o 17:53 Arnd Bergmann <arnd@arndb.de> napisał(a):
>
> On Mon, Oct 21, 2019 at 5:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > niedz., 6 paź 2019 o 07:39 Bartosz Golaszewski <brgl@bgdev.pl> napisał(a):
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > > 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(-)
> >
> > Greg, Arnd,
> >
> > gentle ping for this. I noticed that some maintainers are complaining
> > about being spammed with patches converting old drivers to using
> > devm_platform_ioremap_resource() and there's even a patch removing the
> > relevant coccinelle script on the list, but I think for new drivers
> > these are still useful. Do you want to pick them up for v5.5 (or at
> > all)?
>
> I think this series is useful and we should merge it. Are there any
> remaining dependencies or conflicts with Christoph Hellwig's recent
> __ioremap rework? If there are, I would prioritize his work and maybe
> delay this one by another merge window, otherwise please add
> my Reviewed-by to all patches and resend them for Greg to pick
> up (provided he has no objections).
>
> Arnd
Is Christoph's work in next? The series doesn't apply cleanly on next,
I needed to fix a couple conflicts. What branch should I rebase it on
before resending?
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-21 16:29 ` Bartosz Golaszewski
@ 2019-10-21 19:29 ` Arnd Bergmann
2019-10-30 21:35 ` Christoph Hellwig
0 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2019-10-21 19:29 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Greg Kroah-Hartman, linux-doc, Linux Kernel Mailing List,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Jonathan Corbet,
Rafael J . Wysocki, Linus Walleij, Christoph Hellwig
On Mon, Oct 21, 2019 at 6:29 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> pon., 21 paź 2019 o 17:53 Arnd Bergmann <arnd@arndb.de> napisał(a):
> > On Mon, Oct 21, 2019 at 5:04 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > gentle ping for this. I noticed that some maintainers are complaining
> > > about being spammed with patches converting old drivers to using
> > > devm_platform_ioremap_resource() and there's even a patch removing the
> > > relevant coccinelle script on the list, but I think for new drivers
> > > these are still useful. Do you want to pick them up for v5.5 (or at
> > > all)?
> >
> > I think this series is useful and we should merge it. Are there any
> > remaining dependencies or conflicts with Christoph Hellwig's recent
> > __ioremap rework? If there are, I would prioritize his work and maybe
> > delay this one by another merge window, otherwise please add
> > my Reviewed-by to all patches and resend them for Greg to pick
> > up (provided he has no objections).
>
> Is Christoph's work in next? The series doesn't apply cleanly on next,
> I needed to fix a couple conflicts. What branch should I rebase it on
> before resending?
Not sure, maybe Christoph can comment.
Your patches would best go through the char-misc tree and be based
on top of that, for Christoph's I think the idea is to have some go
through the architecture maintainer trees, and have whatever is
left go through my asm-generic tree.
Arnd
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-21 19:29 ` Arnd Bergmann
@ 2019-10-30 21:35 ` Christoph Hellwig
2019-10-31 6:41 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2019-10-30 21:35 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Bartosz Golaszewski, Greg Kroah-Hartman, linux-doc,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
Bartosz Golaszewski, Jonathan Corbet, Rafael J . Wysocki,
Linus Walleij, Christoph Hellwig
On Mon, Oct 21, 2019 at 09:29:30PM +0200, Arnd Bergmann wrote:
> > Is Christoph's work in next? The series doesn't apply cleanly on next,
> > I needed to fix a couple conflicts. What branch should I rebase it on
> > before resending?
>
> Not sure, maybe Christoph can comment.
>
> Your patches would best go through the char-misc tree and be based
> on top of that, for Christoph's I think the idea is to have some go
> through the architecture maintainer trees, and have whatever is
> left go through my asm-generic tree.
Actually I thought of just doing an ioremap tree for this merge window.
What kind of changes does Bartosz have? I'm kinda missing the context
here.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-30 21:35 ` Christoph Hellwig
@ 2019-10-31 6:41 ` Bartosz Golaszewski
2019-10-31 8:12 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-31 6:41 UTC (permalink / raw)
To: Christoph Hellwig, Greg Kroah-Hartman
Cc: Arnd Bergmann, Bartosz Golaszewski, linux-doc,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
Jonathan Corbet, Rafael J . Wysocki, Linus Walleij
śr., 30 paź 2019 o 22:35 Christoph Hellwig <hch@infradead.org> napisał(a):
>
> On Mon, Oct 21, 2019 at 09:29:30PM +0200, Arnd Bergmann wrote:
> > > Is Christoph's work in next? The series doesn't apply cleanly on next,
> > > I needed to fix a couple conflicts. What branch should I rebase it on
> > > before resending?
> >
> > Not sure, maybe Christoph can comment.
> >
> > Your patches would best go through the char-misc tree and be based
> > on top of that, for Christoph's I think the idea is to have some go
> > through the architecture maintainer trees, and have whatever is
> > left go through my asm-generic tree.
>
> Actually I thought of just doing an ioremap tree for this merge window.
>
> What kind of changes does Bartosz have? I'm kinda missing the context
> here.
Just the series you've responded to here, but I don't think it should
conflict with your changes (not very much anyway).
Greg: can this be picked up into char-misc?
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3 0/8] drivers: add new variants of devm_platform_ioremap_resource()
2019-10-31 6:41 ` Bartosz Golaszewski
@ 2019-10-31 8:12 ` Bartosz Golaszewski
0 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2019-10-31 8:12 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Christoph Hellwig, Greg Kroah-Hartman, Arnd Bergmann, linux-doc,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
Jonathan Corbet, Rafael J . Wysocki, Linus Walleij
czw., 31 paź 2019 o 07:41 Bartosz Golaszewski
<bgolaszewski@baylibre.com> napisał(a):
>
> śr., 30 paź 2019 o 22:35 Christoph Hellwig <hch@infradead.org> napisał(a):
> >
> > On Mon, Oct 21, 2019 at 09:29:30PM +0200, Arnd Bergmann wrote:
> > > > Is Christoph's work in next? The series doesn't apply cleanly on next,
> > > > I needed to fix a couple conflicts. What branch should I rebase it on
> > > > before resending?
> > >
> > > Not sure, maybe Christoph can comment.
> > >
> > > Your patches would best go through the char-misc tree and be based
> > > on top of that, for Christoph's I think the idea is to have some go
> > > through the architecture maintainer trees, and have whatever is
> > > left go through my asm-generic tree.
> >
> > Actually I thought of just doing an ioremap tree for this merge window.
> >
> > What kind of changes does Bartosz have? I'm kinda missing the context
> > here.
>
> Just the series you've responded to here, but I don't think it should
> conflict with your changes (not very much anyway).
>
> Greg: can this be picked up into char-misc?
>
> Bart
I refer of course to the re-sent version rebased on top of char-misc.
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread