Skip to contentSkip to conversation

driver core: show the error number when driver_sysfs_add() fails

PATCH In review Kefeng Wang 2 participants 3 messages Jun 4, 2019 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: show the error number when driver_sysfs_add() fails

If driver_sysfs_add() fails, kernel shows following message,

really_probe: driver_sysfs_add(portman.0) failed
ppdev: probe of portman.0 failed with error 0

It's better to show the error number like other probe_failed path.

---
 drivers/base/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +2 -1
index 0df9b4461766..04ee4e196530 100644
@@ -493,7 +493,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 			goto probe_failed;
 	}
 
-	if (driver_sysfs_add(dev)) {
+	ret = driver_sysfs_add(dev);
+	if (ret) {
 		printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
 			__func__, dev_name(dev));
 		goto probe_failed;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 17 lines · Kefeng Wang

If driver_sysfs_add() fails, kernel shows following message,

really_probe: driver_sysfs_add(portman.0) failed
ppdev: probe of portman.0 failed with error 0

It's better to show the error number like other probe_failed path.

---
 drivers/base/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +0 -0
index 0df9b4461766..04ee4e196530 100644

drivers/base/dd.c static int really_probe(struct device *dev, struct device_driver *drv) · line 499

Quoted 8 lines
drivers/base/dd.c +2 -1
@@ -493,7 +493,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 			goto probe_failed;
 	}
 
-	if (driver_sysfs_add(dev)) {
+	ret = driver_sysfs_add(dev);
+	if (ret) {
 		printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
 			__func__, dev_name(dev));

Shouldn't this be where the error number is shown? No need for all callers to also show the same thing.

thanks,

greg k-h

#2 lore raw
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 lines · Kefeng Wang

If driver_sysfs_add() fails, kernel shows following message,

really_probe: driver_sysfs_add(portman.0) failed
ppdev: probe of portman.0 failed with error 0

It's better to show the error number like other probe_failed path.

---
 drivers/base/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +0 -0
index 0df9b4461766..04ee4e196530 100644
@@ -493,7 +493,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 			goto probe_failed;
 	}
 
Quoted 7 lines

drivers/base/dd.c static int really_probe(struct device *dev, struct device_driver *drv) · line 499

Quoted 5 lines
drivers/base/dd.c +2 -1
-	if (driver_sysfs_add(dev)) {
+	ret = driver_sysfs_add(dev);
+	if (ret) {
 		printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
 			__func__, dev_name(dev));

Shouldn't this be where the error number is shown? No need for all callers to also show the same thing.

Like the message shown as above,  there is a common path to show all the probe error info,

"ppdev: probe of portman.0 failed with error 0"

but the driver_sysfs_add() error handling won't fill with ret, so error '0' is shown. after this patch,

really_probe: driver_sysfs_add(portman.0) failed
ppdev: probe of portman.0 failed with error -12

Quoted 7 lines

thanks,

greg k-h

.