Re: [PATCH v4 3/3] driver-core: print bus registration error value

From: kbuild test robot
Date: Thu May 17 2018 - 03:13:50 EST


Hi Florian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on v4.17-rc5 next-20180516]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Florian-Schmaus/return-EINVAL-error-instead-of-BUG_ON/20180517-145147
config: x86_64-randconfig-x002-201819 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/device.h:16,
from drivers/base/driver.c:11:
drivers/base/driver.c: In function 'driver_register':
>> include/linux/kern_levels.h:5:18: warning: too many arguments for format [-Wformat-extra-args]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
>> include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/base/driver.c:153:4: note: in expansion of macro 'pr_err'
pr_err("Driver '%s' was unable to register with bus_type '%s'",
^~~~~~
>> include/linux/kern_levels.h:5:18: warning: too many arguments for format [-Wformat-extra-args]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
>> include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
drivers/base/driver.c:158:4: note: in expansion of macro 'pr_err'
pr_err("Driver '%s' was unable to register with bus_type '%s'",
^~~~~~
--
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/device.h:16,
from drivers//base/driver.c:11:
drivers//base/driver.c: In function 'driver_register':
>> include/linux/kern_levels.h:5:18: warning: too many arguments for format [-Wformat-extra-args]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
>> include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
drivers//base/driver.c:153:4: note: in expansion of macro 'pr_err'
pr_err("Driver '%s' was unable to register with bus_type '%s'",
^~~~~~
>> include/linux/kern_levels.h:5:18: warning: too many arguments for format [-Wformat-extra-args]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
>> include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
drivers//base/driver.c:158:4: note: in expansion of macro 'pr_err'
pr_err("Driver '%s' was unable to register with bus_type '%s'",
^~~~~~

vim +/pr_err +153 drivers/base/driver.c

137
138 /**
139 * driver_register - register driver with bus
140 * @drv: driver to register
141 *
142 * We pass off most of the work to the bus_add_driver() call,
143 * since most of the things we have to do deal with the bus
144 * structures.
145 */
146 int driver_register(struct device_driver *drv)
147 {
148 int ret;
149 struct device_driver *other;
150
151 if (!drv->bus->p) {
152 if (drv->bus->bus_register_error) {
> 153 pr_err("Driver '%s' was unable to register with bus_type '%s'",
154 " (error: %d).\n",
155 drv->name, drv->bus->name,
156 drv->bus->bus_register_error);
157 } else {
158 pr_err("Driver '%s' was unable to register with bus_type '%s'",
159 " because it was not initialized.\n",
160 drv->name, drv->bus->name);
161 }
162 return -EINVAL;
163 }
164
165 if ((drv->bus->probe && drv->probe) ||
166 (drv->bus->remove && drv->remove) ||
167 (drv->bus->shutdown && drv->shutdown))
168 printk(KERN_WARNING "Driver '%s' needs updating - please use "
169 "bus_type methods\n", drv->name);
170
171 other = driver_find(drv->name, drv->bus);
172 if (other) {
173 printk(KERN_ERR "Error: Driver '%s' is already registered, "
174 "aborting...\n", drv->name);
175 return -EBUSY;
176 }
177
178 ret = bus_add_driver(drv);
179 if (ret)
180 return ret;
181 ret = driver_add_groups(drv, drv->groups);
182 if (ret) {
183 bus_remove_driver(drv);
184 return ret;
185 }
186 kobject_uevent(&drv->p->kobj, KOBJ_ADD);
187
188 return ret;
189 }
190 EXPORT_SYMBOL_GPL(driver_register);
191

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip