Skip to contentSkip to conversation

hwmon: (tmp102) Drop unnecessary __maybe_unused

PATCH In review Flaviu Nistor 3 participants 3 messages May 18 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

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
index 29e44c8db540..6bd1bed3cdb8 100644
@@ -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
#1 lore raw
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…

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_match is used unconditionally in tmp102_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
index 3aa1a3fbeaa92..23f66f70d5a9a 100644
@@ -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