hwmon: (tmp102) Drop unnecessary __maybe_unused
PATCH 1/1 hwmon: (tmp102) Drop unnecessary __maybe_unused
tmp102_of_match is used unconditionally in tmp102_driver, so there is no need for __maybe_unused.
--- drivers/hwmon/tmp102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/tmp102.c +1 -1
@@ -401,7 +401,7 @@ static const struct i2c_device_id tmp102_id[] = { };MODULE_DEVICE_TABLE (i2c, tmp102_id); -static const struct of_device_id __maybe_unused tmp102_of_match[] = { +static const struct of_device_id tmp102_of_match[] = { { .compatible ="ti,tmp102" }, { }, };
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Removing `__maybe_unused` without also removing `of_match_ptr()` resurrects a build warning on…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Removing __maybe_unused without also removing of_match_ptr() resurrects a build warning on !CONFIG_OF builds. --
commit 48f4abeb993e88df34017f1f7dacc66c48dc3d0e
Author: Flaviu Nistor <[email protected]>
hwmon: (tmp102) Drop unnecessary __maybe_unused
The commit removes the __maybe_unused annotation from the tmp102_of_match array. It states that the array is used unconditionally in tmp102_driver.
Quoted 2 lines
tmp102_of_matchis used unconditionally intmp102_driver, so there is no need for__maybe_unused.
Is this description accurate? Looking at tmp102_driver, the array assignment remains wrapped in the of_match_ptr() macro:
static struct i2c_driver tmp102_driver = {
.driver.name = DRIVER_NAME,
.driver.of_match_table = of_match_ptr(tmp102_of_match),
...When the kernel is compiled with CONFIG_OF disabled, of_match_ptr() evaluates to NULL and tmp102_of_match is left completely unreferenced.
drivers/hwmon/tmp102.c static const struct i2c_device_id tmp102_id[] = { · line 406
Quoted 13 lines
drivers/hwmon/tmp102.c +1
-1@@ -400,7 +400,7 @@ static const struct i2c_device_id tmp102_id[] = { };MODULE_DEVICE_TABLE (i2c, tmp102_id); -static const struct of_device_id __maybe_unused tmp102_of_match[] = { +static const struct of_device_id tmp102_of_match[] = { { .compatible ="ti,tmp102" }, { }, };
Does this removal resurrect the -Wunused-const-variable build warning on !CONFIG_OF builds?
To safely drop __maybe_unused and make the usage truly unconditional, should the of_match_ptr() wrapper also be removed?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 4 lines · Flaviu Nistor
tmp102_of_matchis used unconditionally intmp102_driver, so there is no need for__maybe_unused.Signed-off-by Flaviu Nistor <[email protected]>
I'll squash this patch into the preceding patch.
Thanks,
Guenter