[PATCH 2/3] mtd: spi-nor: explicitly include <linux/mod_devicetable.h>

Tudor Ambarus posted 3 patches 11 months, 1 week ago
[PATCH 2/3] mtd: spi-nor: explicitly include <linux/mod_devicetable.h>
Posted by Tudor Ambarus 11 months, 1 week ago
The core driver is using 'struct of_device_id' and relies on implicit
inclusion of <linux/mod_devicetable.h>, which comes from
<linux/of_platform.h>.

It is good practice to directly include all headers used, it avoids
implicit dependencies and spurious breakage if someone rearranges
headers and causes the implicit include to vanish.

Include the missing header.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
 drivers/mtd/spi-nor/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 1091c83294fa33393f27f914efb254da7a7524a2..ec298a285f820383b2c1d9ef4462a000d1b3b861 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/math64.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/spi-nor.h>

-- 
2.34.1
Re: [PATCH 2/3] mtd: spi-nor: explicitly include <linux/mod_devicetable.h>
Posted by Miquel Raynal 11 months, 1 week ago
Hello Tudor,

On 07/03/2025 at 09:09:06 +02, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:

> The core driver is using 'struct of_device_id' and relies on implicit
> inclusion of <linux/mod_devicetable.h>, which comes from
> <linux/of_platform.h>.

It is actually included from of.h now (since patch 1) and I wonder
whether there is a need for it to be included explicitly. As a user it
feels like "of.h" should already include whatever is needed for us (and
it's the case). Looking at the numbers, about 25% of the drivers do
include it explicitly. But either ways I'm fine.

Thanks,
Miquèl
Re: [PATCH 2/3] mtd: spi-nor: explicitly include <linux/mod_devicetable.h>
Posted by Tudor Ambarus 11 months, 1 week ago

On 3/7/25 8:22 AM, Miquel Raynal wrote:
> Hello Tudor,

Hi, Miquel!
> 
> On 07/03/2025 at 09:09:06 +02, Tudor Ambarus <tudor.ambarus@linaro.org> wrote:
> 
>> The core driver is using 'struct of_device_id' and relies on implicit
>> inclusion of <linux/mod_devicetable.h>, which comes from
>> <linux/of_platform.h>.
> 
> It is actually included from of.h now (since patch 1) and I wonder
> whether there is a need for it to be included explicitly. As a user it
> feels like "of.h" should already include whatever is needed for us (and

Seems so. I'll drop this patch. Thanks!
ta