From: "Arnd Bergmann" <arnd@arndb.de>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: "Arnd Bergmann" <arnd@kernel.org>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Yu Jiaoliang" <yujiaoliang@vivo.com>,
"Oliver Graute" <oliver.graute@kococonnector.com>,
linux-input@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] Input: stmpe-ts - mark OF related data as maybe unused
Date: Tue, 25 Feb 2025 22:27:24 +0100 [thread overview]
Message-ID: <181dbdb8-c050-4966-8cb4-2f39495ff3f9@app.fastmail.com> (raw)
In-Reply-To: <ccjng5mrvqngfg6eujq6mtl6dj2sz5vsqvjoqz6gm5ntcibduz@wqoc6zhchrvv>
On Tue, Feb 25, 2025, at 21:17, Uwe Kleine-König wrote:
> On Tue, Feb 25, 2025 at 05:25:05PM +0100, Arnd Bergmann wrote:
>> On Tue, Feb 25, 2025, at 16:47, Uwe Kleine-König wrote:
>> > On Tue, Feb 25, 2025 at 03:53:26PM +0100, Arnd Bergmann wrote:
>> > the warning goes away and stmpe_ts_ids isn't included in the .o file
>> > without having to add __maybe_unused to the driver.
>> >
>> > I would consider that a superior approach.
>>
>> Not sure, I can see how this avoids some warnings, but this is
>> currently the only remaining instance of this problem (I fixed
>> another two recently), and in most cases a MODULE_DEVICE_TABLE()
>> entry that is completely unused ends up pointing to a real bug,
>> where there is a table but it's not also part of the
>> device_driver definition.
>
> It might be the only instance without __maybe_unused and so triggering a
> warning. But there is also:
>
> $ git grep -E 'of_device_id.*__maybe_unused' | wc -l
> 231
>
> $ git grep -E 'mdio_device_id.*__maybe_unused' | wc -l
> 58
I'm not really worried about these at the moment, other than not
wanting to pile on to that mess with more __maybe_unused
annotations.
My goal here is to get the point of enabling -Wunused-const-variable
by default in order to find other bugs before they make it into
the kernel.
Andy Shevchenko really wants to remove the of_match_ptr()
macro so we can stop adding pointless __maybe_unused annotations
for every driver that accidentally uses of_match_ptr(). This
is certainly a good idea as well, just not what I'm trying to
do this time.
Apparently we have already accumulated a bunch of drivers that
ended up with __maybe_unused but no actual reference from
of_match_ptr():
$ git grep -l 'of_device_id.*__maybe_unused' |xargs grep -Lw of_match_ptr | wc -l
but only a couple of drivers that don't use of_match_ptr()
or of_match_node():
$ git grep -l 'of_device_id.*__maybe_unused' |xargs grep -Lw 'of_match_table\|of_match_node'
drivers/cpufreq/armada-37xx-cpufreq.c
drivers/cpufreq/armada-8k-cpufreq.c
drivers/cpufreq/highbank-cpufreq.c
drivers/cpufreq/sti-cpufreq.c
drivers/hwmon/isl28022.c
drivers/input/touchscreen/stmpe-ts.c
drivers/mfd/twl6030-irq.c
drivers/tty/serial/sc16is7xx.c
I do think it makes sense to change of_match_node() to have a
reference to its arguments, as in the patch below. That
probably needs a few extra fixups.
Arnd
diff --git a/include/linux/of.h b/include/linux/of.h
index 9d6b8a61607f..83cfa6c26ee4 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -907,7 +907,11 @@ static inline const void *of_device_get_match_data(const struct device *dev)
}
#define of_match_ptr(_ptr) NULL
-#define of_match_node(_matches, _node) NULL
+static inline const struct of_device_id *of_match_node(
+ const struct of_device_id *matches, const struct device_node *node)
+{
+ return NULL;
+}
#endif /* CONFIG_OF */
/* Default string compare functions, Allow arch asm/prom.h to override */
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index d4b39184dbdb..bd418dea586d 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -80,7 +80,6 @@ static void build_deinstantiation_desc(u32 *desc, int handle)
append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT);
}
-#ifdef CONFIG_OF
static const struct of_device_id imx8m_machine_match[] = {
{ .compatible = "fsl,imx8mm", },
{ .compatible = "fsl,imx8mn", },
@@ -89,7 +88,6 @@ static const struct of_device_id imx8m_machine_match[] = {
{ .compatible = "fsl,imx8ulp", },
{ }
};
-#endif
/*
* run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of
diff --git a/drivers/dma/dw/rzn1-dmamux.c b/drivers/dma/dw/rzn1-dmamux.c
index 4fb8508419db..9dcba3a3ffaa 100644
--- a/drivers/dma/dw/rzn1-dmamux.c
+++ b/drivers/dma/dw/rzn1-dmamux.c
@@ -104,12 +104,10 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
return ERR_PTR(ret);
}
-#ifdef CONFIG_OF
static const struct of_device_id rzn1_dmac_match[] = {
{ .compatible = "renesas,rzn1-dma" },
{}
};
-#endif
static int rzn1_dmamux_probe(struct platform_device *pdev)
{
diff --git a/drivers/i2c/busses/i2c-at91-core.c b/drivers/i2c/busses/i2c-at91-core.c
index edc047e3e535..3a9be06dd967 100644
--- a/drivers/i2c/busses/i2c-at91-core.c
+++ b/drivers/i2c/busses/i2c-at91-core.c
@@ -108,7 +108,6 @@ static const struct platform_device_id at91_twi_devtypes[] = {
}
};
-#if defined(CONFIG_OF)
static struct at91_twi_pdata at91sam9x5_config = {
.clk_max_div = 7,
.clk_offset = 4,
@@ -178,7 +177,6 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
}
};
MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
-#endif
static struct at91_twi_pdata *at91_twi_get_driver_data(
struct platform_device *pdev)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index dc1e46d834dc..969e08e4d4f4 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1409,7 +1409,6 @@ static const struct i2c_adapter xiic_adapter = {
.algo = &xiic_algorithm,
};
-#if defined(CONFIG_OF)
static const struct xiic_version_data xiic_2_00 = {
.quirks = DYNAMIC_MODE_READ_BROKEN_BIT,
};
@@ -1420,7 +1419,6 @@ static const struct of_device_id xiic_of_match[] = {
{},
};
MODULE_DEVICE_TABLE(of, xiic_of_match);
-#endif
static int xiic_i2c_probe(struct platform_device *pdev)
{
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 35a196341534..3db592f3b451 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -111,7 +111,6 @@ static const struct platform_device_id atmel_ssc_devtypes[] = {
}
};
-#ifdef CONFIG_OF
static const struct of_device_id atmel_ssc_dt_ids[] = {
{
.compatible = "atmel,at91rm9200-ssc",
@@ -127,7 +126,6 @@ static const struct of_device_id atmel_ssc_dt_ids[] = {
}
};
MODULE_DEVICE_TABLE(of, atmel_ssc_dt_ids);
-#endif
static inline const struct atmel_ssc_platform_data *
atmel_ssc_get_driver_data(struct platform_device *pdev)
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 191707d7e3da..9fbbf3587b0c 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1013,7 +1013,6 @@ static const struct attribute_group at91_sysfs_attr_group = {
.attrs = at91_sysfs_attrs,
};
-#if defined(CONFIG_OF)
static const struct of_device_id at91_can_dt_ids[] = {
{
.compatible = "atmel,at91sam9x5-can",
@@ -1026,7 +1025,6 @@ static const struct of_device_id at91_can_dt_ids[] = {
}
};
MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
-#endif
static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
{
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 6c462de81f20..f942c6e54a1b 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4425,7 +4425,6 @@ static const struct macb_usrio_config macb_default_usrio = {
.refclk = MACB_BIT(CLKEN),
};
-#if defined(CONFIG_OF)
/* 1518 rounded up */
#define AT91ETHER_MAX_RBUFF_SZ 0x600
/* max number of receive buffers */
@@ -5144,7 +5143,6 @@ static const struct of_device_id macb_dt_ids[] = {
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, macb_dt_ids);
-#endif /* CONFIG_OF */
static const struct macb_config default_gem_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
prev parent reply other threads:[~2025-02-25 21:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 14:53 Arnd Bergmann
2025-02-25 15:47 ` Uwe Kleine-König
2025-02-25 16:25 ` Arnd Bergmann
2025-02-25 20:17 ` Uwe Kleine-König
2025-02-25 21:27 ` Arnd Bergmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=181dbdb8-c050-4966-8cb4-2f39495ff3f9@app.fastmail.com \
--to=arnd@arndb.de \
--cc=alexandre.torgue@foss.st.com \
--cc=arnd@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=oliver.graute@kococonnector.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=yujiaoliang@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®