[PATCH] mtd: Fix misuses of of_match_ptr()

Miquel Raynal miquel.raynal at bootlin.com
Mon Jan 31 08:21:36 PST 2022


On Thu, 2022-01-27 at 11:06:31 UTC, Miquel Raynal wrote:
> of_match_ptr() either expands to NULL if !CONFIG_OF, or is transparent
> otherwise. There are several drivers using this macro which keep their
> of_device_id array enclosed within an #ifdef CONFIG_OF check, these are
> considered fine. However, When misused, the of_device_id array pointed
> by this macro will produce a warning because it is finally unused when
> compiled without OF support.
> 
> A number of fixes are possible:
> - Always depend on CONFIG_OF, but this will not always work and may
>   break boards.
> - Enclose the compatible array by #ifdef's, this may save a bit of
>   memory but will reduce build coverage.
> - Tell the compiler the array may be unused, if this can be avoided,
>   let's not do this.
> - Just drop the macro, setting the of_device_id array for a non OF
>   enabled platform is not an issue, it will just be unused.
> 
> The latter solution seems the more appropriate, so let's use it.
> 
> Reported-by: kernel test robot <lkp at intel.com>
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> Acked-by: Paul Cercueil <paul at crapouillou.net>
> Reviewed-by: Alexandre Belloni <alexandre.belloni at bootlin.com>
> Acked-by: Pratyush Yadav <p.yadav at ti.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next.

Miquel



More information about the linux-mtd mailing list