Re: [PATCH v2 1/5] driver core: Provide stubs for !IOMEM builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 18 Jul 2023 at 08:29, Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> 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 HAS_IOMEM.
>
> The most likely use case is builds with UML for KUnit testing.
>
> Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
> ---

This is really nice, thanks: we've definitely wasted^W spent a lot of
time adding the appropriate IOMEM dependencies when trying to setup
KUnit configs, so I'm looking forward to not worrying about that
again.

We have considered implementing fake versions of these specifically
aimed at testing, and are looking into the PCI-over-virtio
implementation in UML's LOGIC_IOMEM feature, which allows redirecting
IOMEM accesses to something more test-friendly.

Neither of those conflict with this as a fallback, though, and I'm all for it.

Reviewed-by: David Gow <davidgow@xxxxxxxxxx>

Cheers,
-- David


>  include/linux/device.h | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index bbaeabd04b0d..6731d7dc1a2a 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -349,6 +349,7 @@ unsigned long devm_get_free_pages(struct device *dev,
>                                   gfp_t gfp_mask, unsigned int order);
>  void devm_free_pages(struct device *dev, unsigned long addr);
>
> +#ifdef CONFIG_HAS_IOMEM
>  void __iomem *devm_ioremap_resource(struct device *dev,
>                                     const struct resource *res);
>  void __iomem *devm_ioremap_resource_wc(struct device *dev,
> @@ -357,6 +358,31 @@ void __iomem *devm_ioremap_resource_wc(struct device *dev,
>  void __iomem *devm_of_iomap(struct device *dev,
>                             struct device_node *node, int index,
>                             resource_size_t *size);
> +#else
> +
> +static inline
> +void __iomem *devm_ioremap_resource(struct device *dev,
> +                                   const struct resource *res)
> +{
> +       return ERR_PTR(-EINVAL);
> +}
> +
> +static inline
> +void __iomem *devm_ioremap_resource_wc(struct device *dev,
> +                                      const struct resource *res)
> +{
> +       return ERR_PTR(-EINVAL);
> +}
> +
> +static inline
> +void __iomem *devm_of_iomap(struct device *dev,
> +                           struct device_node *node, int index,
> +                           resource_size_t *size)
> +{
> +       return ERR_PTR(-EINVAL);
> +}
> +
> +#endif
>
>  /* allows to add/remove a custom action to devres stack */
>  void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
>
> --
> 2.39.2
>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux