mirror of https://gitee.com/openkylin/linux.git
i2c: improve error messages in i2c_register_adapter()
Switch to WARN if no adapter name is given, otherwise we won't know who missed to do that. Add error message if device registration fails. Update error message for missing algo to match style of the others. Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
d3b11d8380
commit
8ddfe4108e
|
@ -1604,14 +1604,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if (unlikely(adap->name[0] == '\0')) {
|
if (WARN(!adap->name[0], "i2c adapter has no name"))
|
||||||
pr_err("i2c-core: Attempt to register an adapter with "
|
|
||||||
"no name!\n");
|
|
||||||
goto out_list;
|
goto out_list;
|
||||||
}
|
|
||||||
if (unlikely(!adap->algo)) {
|
if (!adap->algo) {
|
||||||
pr_err("i2c-core: Attempt to register adapter '%s' with "
|
pr_err("i2c-core: adapter '%s': no algo supplied!\n", adap->name);
|
||||||
"no algo!\n", adap->name);
|
|
||||||
goto out_list;
|
goto out_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,8 +1631,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
|
||||||
adap->dev.bus = &i2c_bus_type;
|
adap->dev.bus = &i2c_bus_type;
|
||||||
adap->dev.type = &i2c_adapter_type;
|
adap->dev.type = &i2c_adapter_type;
|
||||||
res = device_register(&adap->dev);
|
res = device_register(&adap->dev);
|
||||||
if (res)
|
if (res) {
|
||||||
|
pr_err("i2c-core: adapter '%s': can't register device (%d)\n",
|
||||||
|
adap->name, res);
|
||||||
goto out_list;
|
goto out_list;
|
||||||
|
}
|
||||||
|
|
||||||
dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
|
dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue