diff mbox series

[04/11] backports: platform_device.h: Add devm_platform_ioremap_resource()

Message ID 20191003155642.14909-5-hauke@hauke-m.de (mailing list archive)
State Accepted
Headers show
Series backports: Update to kernel 5.4-rc1 | expand

Commit Message

Hauke Mehrtens Oct. 3, 2019, 3:56 p.m. UTC
Add devm_platform_ioremap_resource() from upstream kernel commit
7945f929f1a7 ("drivers: provide devm_platform_ioremap_resource()") which
is now used by the mt76 driver.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 .../backport-include/linux/platform_device.h  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/platform_device.h b/backport/backport-include/linux/platform_device.h
index 5b821ee4..87142d7c 100644
--- a/backport/backport-include/linux/platform_device.h
+++ b/backport/backport-include/linux/platform_device.h
@@ -33,4 +33,26 @@  module_exit(__platform_driver##_exit);
                         platform_driver_unregister)
 #endif
 
+#if LINUX_VERSION_IS_LESS(5,1,0)
+/**
+ * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
+ *				    device
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ *        resource management
+ * @index: resource index
+ */
+#ifdef CONFIG_HAS_IOMEM
+#define devm_platform_ioremap_resource LINUX_BACKPORT(devm_platform_ioremap_resource)
+static inline void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
+					     unsigned int index)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, index);
+	return devm_ioremap_resource(&pdev->dev, res);
+}
+#endif /* CONFIG_HAS_IOMEM */
+#endif
+
 #endif /* __BACKPORT_PLATFORM_DEVICE_H */