mac80211: Add devm_platform_get_and_ioremap_resource()

This function is missing in kernel 5.4, but it is sued by ath10k.
This fixes the build of ath10k on some targets.

Fixes: cfe0eb7485 ("mac80211: Update to version 5.14.13-1")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Hauke Mehrtens 2021-10-24 15:03:20 +02:00
parent 36104dc51f
commit 6a1284cfa8
1 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,79 @@
From d49395058c6bd4fb7b8bcc5ff7b4d7fbd9b6f97b Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sun, 24 Oct 2021 14:49:55 +0200
Subject: [PATCH] headers: Add devm_platform_get_and_ioremap_resource()
This function is copied from kernel 5.7 and used by mt76, ath10k and
ath11k. devm_platform_ioremap_resource() was changed to make sue of
this new function.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
.../backport-include/linux/platform_device.h | 45 ++++++++++++++++---
1 file changed, 38 insertions(+), 7 deletions(-)
--- a/backport-include/linux/platform_device.h
+++ b/backport-include/linux/platform_device.h
@@ -33,7 +33,39 @@ module_exit(__platform_driver##_exit);
platform_driver_unregister)
#endif
+#if LINUX_VERSION_IS_LESS(5,7,0)
+#ifdef CONFIG_HAS_IOMEM
+#define devm_platform_get_and_ioremap_resource LINUX_BACKPORT(devm_platform_get_and_ioremap_resource)
+/**
+ * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource() for a
+ * platform device and get resource
+ *
+ * @pdev: platform device to use both for memory resource lookup as well as
+ * resource management
+ * @index: resource index
+ * @res: optional output parameter to store a pointer to the obtained resource.
+ *
+ * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure.
+ */
+static inline void __iomem *
+devm_platform_get_and_ioremap_resource(struct platform_device *pdev,
+ unsigned int index, struct resource **res)
+{
+ struct resource *r;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, index);
+ if (res)
+ *res = r;
+ return devm_ioremap_resource(&pdev->dev, r);
+}
+#endif /* CONFIG_HAS_IOMEM */
+#endif /* < 5.7 */
+
#if LINUX_VERSION_IS_LESS(5,1,0)
+
+#ifdef CONFIG_HAS_IOMEM
+#define devm_platform_ioremap_resource LINUX_BACKPORT(devm_platform_ioremap_resource)
/**
* devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform
* device
@@ -41,16 +73,15 @@ module_exit(__platform_driver##_exit);
* @pdev: platform device to use both for memory resource lookup as well as
* resource management
* @index: resource index
+ *
+ * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure.
*/
-#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,
+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);
+ return devm_platform_get_and_ioremap_resource(pdev, index, NULL);
}
#endif /* CONFIG_HAS_IOMEM */
#endif