Skip to contentSkip to conversation

hwmon: (asus-ec-sensors) do not print from .probe()

PATCH Superseded Eugene Shalygin 2 participants 7 messages Feb 17, 2022 – Feb 18, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (asus-ec-sensors) do not print from .probe()

Remove the call to dev_info() from the board detection function, which is called from probe(), not only to be in line with hwmon driver rules, but also because the message duplicates the error code returned from probe() for that case (ENODEV).

---
 drivers/hwmon/asus-ec-sensors.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/hwmon/asus-ec-sensors.c +5 -12
index 0701ade16227..cbe1b987144a 100644
@@ -597,18 +597,11 @@ static struct hwmon_chip_info asus_ec_chip_info = {
 	.ops = &asus_ec_hwmon_ops,
 };
 
-static unsigned long __init
-get_board_sensors(const struct device *dev)
+static unsigned long __init get_board_sensors(void)
 {
-	const struct dmi_system_id *dmi_entry;
-
-	dmi_entry = dmi_first_match(asus_ec_dmi_table);
-	if (!dmi_entry) {
-		dev_info(dev, "Unsupported board");
-		return 0;
-	}
-
-	return (unsigned long)dmi_entry->driver_data;
+	const struct dmi_system_id *dmi_entry =
+		dmi_first_match(asus_ec_dmi_table);
+	return dmi_entry ? (unsigned long)dmi_entry->driver_data : 0;
 }
 
 static int __init asus_ec_probe(struct platform_device *pdev)
@@ -625,7 +618,7 @@ static int __init asus_ec_probe(struct platform_device *pdev)
 	struct device *hwdev;
 	unsigned int i;
 
-	board_sensors = get_board_sensors(dev);
+	board_sensors = get_board_sensors();
 	if (!board_sensors)
 		return -ENODEV;
 
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 24 lines · Eugene Shalygin

Remove the call to dev_info() from the board detection function, which is called from probe(), not only to be in line with hwmon driver rules, but also because the message duplicates the error code returned from probe() for that case (ENODEV).

---
  drivers/hwmon/asus-ec-sensors.c | 17 +++++------------
  1 file changed, 5 insertions(+), 12 deletions(-)
drivers/hwmon/asus-ec-sensors.c +1 -4
index 0701ade16227..cbe1b987144a 100644
@@ -597,18 +597,11 @@ static struct hwmon_chip_info asus_ec_chip_info = {
  	.ops = &asus_ec_hwmon_ops,
  };
 
-static unsigned long __init
-get_board_sensors(const struct device *dev)
+static unsigned long __init get_board_sensors(void)
  {
-	const struct dmi_system_id *dmi_entry;
-

drivers/hwmon/asus-ec-sensors.c static struct hwmon_chip_info asus_ec_chip_info = { · line 604

Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c +3 -7
-	dmi_entry = dmi_first_match(asus_ec_dmi_table);
-	if (!dmi_entry) {
-		dev_info(dev, "Unsupported board");
-		return 0;
-	}
-
-	return (unsigned long)dmi_entry->driver_data;
+	const struct dmi_system_id *dmi_entry =
+		dmi_first_match(asus_ec_dmi_table);
+	return dmi_entry ? (unsigned long)dmi_entry->driver_data : 0;

Looks like you did not run checkpatch.

Either case, I think you should just drop this function In probe:

	const struct dmi_system_id *dmi_entry = dmi_first_match(asus_ec_dmi_table);

	...
	if (!dmi_entry)
		return -ENODEV;
	...
	ec_data->board_sensors = (unsigned long)dmi_entry->driver_data;

Guenter

Quoted 12 lines
drivers/hwmon/asus-ec-sensors.c +1 -1
  }
 
  static int __init asus_ec_probe(struct platform_device *pdev)
@@ -625,7 +618,7 @@ static int __init asus_ec_probe(struct platform_device *pdev)
  	struct device *hwdev;
  	unsigned int i;
 
-	board_sensors = get_board_sensors(dev);
+	board_sensors = get_board_sensors();
  	if (!board_sensors)
  		return -ENODEV;
 
author maintainer
#2 lore raw
Quoted 1 line · Guenter Roeck

Looks like you did not run checkpatch.

I did (0 errors/warnings/checks). What needs to be corrected?

Quoted 1 line

Either case, I think you should just drop this function In probe:

Yes, currently that function is tiny, but some tests with motherboards from other families are done by users and if I add other families, the information required for each board model will grow and in that case I'd switch from dmi_system_id array to a custom struct to define all the board-related data at at the same place, and to save some space in the module binary, as unused parts of the dmi_system_id array already take a quarter of the total binary size. So, the function will likely get some more code soon.

Regards,
Eugene

maintainer
#3 lore raw
Quoted 5 lines · Eugene Shalygin
Quoted 1 line · Guenter Roeck

Looks like you did not run checkpatch.

I did (0 errors/warnings/checks). What needs to be corrected?

Interesting. It appears that the continuation line in the declaration confuses it. Otherwise you would get:

WARNING: Missing a blank line after declarations

Quoted 11 lines
Quoted 1 line

Either case, I think you should just drop this function In probe:

Yes, currently that function is tiny, but some tests with motherboards from other families are done by users and if I add other families, the information required for each board model will grow and in that case I'd switch from dmi_system_id array to a custom struct to define all the board-related data at at the same place, and to save some space in the module binary, as unused parts of the dmi_system_id array already take a quarter of the total binary size. So, the function will likely get some more code soon.

Hmm, ok. Wouldn't you still need some kind of dmi match ?

Thanks,
Guenter

Quoted 2 lines

Regards,
Eugene

author maintainer
#4 lore raw
Quoted 5 lines · Guenter Roeck
Quoted 3 lines · Eugene Shalygin
Quoted 1 line · Guenter Roeck

Looks like you did not run checkpatch.

Quoted 7 lines
Quoted 2 lines

I did (0 errors/warnings/checks). What needs to be corrected?

Interesting. It appears that the continuation line in the declaration confuses it. Otherwise you would get:

WARNING: Missing a blank line after declarations

Added in v2, thank you!

Quoted 12 lines
Quoted 11 lines
Quoted 1 line

Either case, I think you should just drop this function In probe:

Yes, currently that function is tiny, but some tests with motherboards from other families are done by users and if I add other families, the information required for each board model will grow and in that case I'd switch from dmi_system_id array to a custom struct to define all the board-related data at at the same place, and to save some space in the module binary, as unused parts of the dmi_system_id array already take a quarter of the total binary size. So, the function will likely get some more code soon.

Quoted 1 line

Hmm, ok. Wouldn't you still need some kind of dmi match ?

Of course, just not via dmi_first_match():
https://github.com/zeule/asus-ec-sensors/blob/feature/prime-x470-pro-no-dmi/asus-ec-sensors.c#L787

Regards,
Eugene

maintainer
#5 lore raw
Quoted 28 lines · Eugene Shalygin
Quoted 5 lines · Guenter Roeck
Quoted 3 lines · Eugene Shalygin
Quoted 1 line · Guenter Roeck

Looks like you did not run checkpatch.

Quoted 7 lines
Quoted 2 lines

I did (0 errors/warnings/checks). What needs to be corrected?

Interesting. It appears that the continuation line in the declaration confuses it. Otherwise you would get:

WARNING: Missing a blank line after declarations

Added in v2, thank you!

Quoted 12 lines
Quoted 11 lines
Quoted 1 line

Either case, I think you should just drop this function In probe:

Yes, currently that function is tiny, but some tests with motherboards from other families are done by users and if I add other families, the information required for each board model will grow and in that case I'd switch from dmi_system_id array to a custom struct to define all the board-related data at at the same place, and to save some space in the module binary, as unused parts of the dmi_system_id array already take a quarter of the total binary size. So, the function will likely get some more code soon.

Quoted 5 lines
Quoted 1 line

Hmm, ok. Wouldn't you still need some kind of dmi match ?

Of course, just not via dmi_first_match():
https://github.com/zeule/asus-ec-sensors/blob/feature/prime-x470-pro-no-dmi/asus-ec-sensors.c#L787

!strcmp(), and, yes, dmi functions can return NULL.

Guenter

author maintainer
#6 lore raw
Quoted 1 line · Guenter Roeck

!strcmp(), and, yes, dmi functions can return NULL.

Thanks!

Regards,
Eugene