lkml.org 
[lkml]   [2018]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 3/3] driver-core: print bus registration error value
    Date
    Signed-off-by: Florian Schmaus <flo@geekplace.eu>
    ---

    Notes:
    - Use correct member name 'bus_register_error'
    - Only print out error code if it is non-zero

    drivers/base/bus.c | 4 +++-
    drivers/base/driver.c | 13 ++++++++++---
    2 files changed, 13 insertions(+), 4 deletions(-)

    diff --git a/drivers/base/bus.c b/drivers/base/bus.c
    index dce677dddba4..5814ecb07648 100644
    --- a/drivers/base/bus.c
    +++ b/drivers/base/bus.c
    @@ -849,8 +849,10 @@ int bus_register(struct bus_type *bus)
    struct lock_class_key *key = &bus->lock_key;

    priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL);
    - if (!priv)
    + if (!priv) {
    + bus->bus_register_error = -ENOMEM;
    return -ENOMEM;
    + }

    priv->bus = bus;
    bus->p = priv;
    diff --git a/drivers/base/driver.c b/drivers/base/driver.c
    index 203fa731e3ee..a798aeae08c7 100644
    --- a/drivers/base/driver.c
    +++ b/drivers/base/driver.c
    @@ -149,9 +149,16 @@ int driver_register(struct device_driver *drv)
    struct device_driver *other;

    if (!drv->bus->p) {
    - pr_err("Driver '%s' was unable to register with bus_type '%s'"
    - " because it was not initialized.\n",
    - drv->name, drv->bus->name);
    + if (drv->bus->bus_register_error) {
    + pr_err("Driver '%s' was unable to register with bus_type '%s'",
    + " (error: %d).\n",
    + drv->name, drv->bus->name,
    + drv->bus->bus_register_error);
    + } else {
    + pr_err("Driver '%s' was unable to register with bus_type '%s'",
    + " because it was not initialized.\n",
    + drv->name, drv->bus->name);
    + }
    return -EINVAL;
    }

    --
    2.16.1
    \
     
     \ /
      Last update: 2018-05-16 14:06    [W:5.595 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site