0050-v5.1-drivers-provide-devm_platform_ioremap_resource.patch 2.4 KB

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