Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform: Provide stubs for !HAS_IOMEM builds

The various _ioremap_resource functions are not built when
CONFIG_HAS_IOMEM is disabled but no stubs are provided. Given how
widespread IOMEM usage is in drivers and how rare !IOMEM configurations
are in practical use let's just provide some stubs so users will build
without having to add explicit dependencies on IOMEM.

The most likely use case is builds with UML for KUnit testing.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230718-asoc-topology-kunit-enable-v2-2-0ee11e662b92@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

+28
+28
include/linux/platform_device.h
··· 63 63 extern struct device * 64 64 platform_find_device_by_driver(struct device *start, 65 65 const struct device_driver *drv); 66 + 67 + #ifdef CONFIG_HAS_IOMEM 66 68 extern void __iomem * 67 69 devm_platform_get_and_ioremap_resource(struct platform_device *pdev, 68 70 unsigned int index, struct resource **res); ··· 74 72 extern void __iomem * 75 73 devm_platform_ioremap_resource_byname(struct platform_device *pdev, 76 74 const char *name); 75 + #else 76 + 77 + static inline void __iomem * 78 + devm_platform_get_and_ioremap_resource(struct platform_device *pdev, 79 + unsigned int index, struct resource **res) 80 + { 81 + return ERR_PTR(-EINVAL); 82 + } 83 + 84 + 85 + static inline void __iomem * 86 + devm_platform_ioremap_resource(struct platform_device *pdev, 87 + unsigned int index) 88 + { 89 + return ERR_PTR(-EINVAL); 90 + } 91 + 92 + static inline void __iomem * 93 + devm_platform_ioremap_resource_byname(struct platform_device *pdev, 94 + const char *name) 95 + { 96 + return ERR_PTR(-EINVAL); 97 + } 98 + 99 + #endif 100 + 77 101 extern int platform_get_irq(struct platform_device *, unsigned int); 78 102 extern int platform_get_irq_optional(struct platform_device *, unsigned int); 79 103 extern int platform_irq_count(struct platform_device *);