32c960f320fcba16852ad9ecd66f67db65ea9f47
[openwrt/openwrt.git] / target / linux / ath79 / patches-4.19 / 0050-v5.1-drivers-provide-devm_platform_ioremap_resource.patch
1 From 7945f929f1a77a1c8887a97ca07f87626858ff42 Mon Sep 17 00:00:00 2001
2 From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
3 Date: Wed, 20 Feb 2019 11:12:39 +0000
4 Subject: [PATCH] drivers: provide devm_platform_ioremap_resource()
5
6 There are currently 1200+ instances of using platform_get_resource()
7 and devm_ioremap_resource() together in the kernel tree.
8
9 This patch wraps these two calls in a single helper. Thanks to that
10 we don't have to declare a local variable for struct resource * and can
11 omit the redundant argument for resource type. We also have one
12 function call less.
13
14 Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
15 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
17 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
18 ---
19 drivers/base/platform.c | 18 ++++++++++++++++++
20 include/linux/platform_device.h | 3 +++
21 2 files changed, 21 insertions(+)
22
23 --- a/drivers/base/platform.c
24 +++ b/drivers/base/platform.c
25 @@ -81,6 +81,24 @@ struct resource *platform_get_resource(s
26 EXPORT_SYMBOL_GPL(platform_get_resource);
27
28 /**
29 + * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
30 + * device
31 + *
32 + * @pdev: platform device to use both for memory resource lookup as well as
33 + * resource managemend
34 + * @index: resource index
35 + */
36 +void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
37 + unsigned int index)
38 +{
39 + struct resource *res;
40 +
41 + res = platform_get_resource(pdev, IORESOURCE_MEM, index);
42 + return devm_ioremap_resource(&pdev->dev, res);
43 +}
44 +EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
45 +
46 +/**
47 * platform_get_irq - get an IRQ for a device
48 * @dev: platform device
49 * @num: IRQ number index
50 --- a/include/linux/platform_device.h
51 +++ b/include/linux/platform_device.h
52 @@ -51,6 +51,9 @@ extern struct device platform_bus;
53 extern void arch_setup_pdev_archdata(struct platform_device *);
54 extern struct resource *platform_get_resource(struct platform_device *,
55 unsigned int, unsigned int);
56 +extern void __iomem *
57 +devm_platform_ioremap_resource(struct platform_device *pdev,
58 + unsigned int index);
59 extern int platform_get_irq(struct platform_device *, unsigned int);
60 extern int platform_irq_count(struct platform_device *);
61 extern struct resource *platform_get_resource_byname(struct platform_device *,