driver: core: Log probe failure as error and with device metadata
authorNícolas F. R. A. Prado <nfraprado@collabora.com>
Tue, 5 Mar 2024 22:21:36 +0000 (17:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Mar 2024 22:10:31 +0000 (22:10 +0000)
Drivers can return -ENODEV or -ENXIO from their probe to reject a device
match, and return -EPROBE_DEFER if probe should be retried. Any other
error code is not expected during normal behavior and indicates an
issue occurred, so it should be logged at the error level.

Also make use of the device variant, dev_err(), so that the device
metadata is attached to the log message.

Signed-off-by: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
Link: https://lore.kernel.org/r/20240305-device-probe-error-v1-1-a06d8722bf19@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/dd.c

index 85152537dbf12d005236cf18c721c51f62a5ebd8..0b7cf4516796a5f76eaa51b7366ab9c5c463454d 100644 (file)
@@ -592,8 +592,8 @@ static int call_driver_probe(struct device *dev, struct device_driver *drv)
                break;
        default:
                /* driver matched but the probe failed */
-               pr_warn("%s: probe of %s failed with error %d\n",
-                       drv->name, dev_name(dev), ret);
+               dev_err(dev, "probe with driver %s failed with error %d\n",
+                       drv->name, ret);
                break;
        }