i2c: parport: Switch to use module_parport_driver()
Subsystems (2)
PATCH 1/1 i2c: parport: Switch to use module_parport_driver()
Switch to use module_parport_driver() to reduce boilerplate code.
--- drivers/i2c/busses/i2c-parport.c | 36 ++++++++++---------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/i2c/busses/i2c-parport.c +11 -25
@@ -267,6 +267,16 @@ static void i2c_parport_attach(struct parport *port)int i;struct pardev_cb i2c_parport_cb; +if (type <0 ) { +pr_warn ("adapter type unspecified\n" ); +return -ENODEV ; + } + +if (type >=ARRAY_SIZE (adapter_parm)) { +pr_warn ("invalid type (%d)\n" , type); +return -ENODEV ; + } +for (i =0 ; i <MAX_DEVICE ; i++) {if (parport[i] ==-1 )continue ;
@@ -392,32 +402,8 @@ static struct parport_driver i2c_parport_driver = { .detach = i2c_parport_detach, .devmodel = true, }; - -/* ----- Module loading, unloading and information ------------------------ */ - -static int __init i2c_parport_init (void ) -{ -if (type <0 ) { -pr_warn ("adapter type unspecified\n" ); -return -ENODEV ; - } - -if (type >=ARRAY_SIZE (adapter_parm)) { -pr_warn ("invalid type (%d)\n" , type); -return -ENODEV ; - } - -return parport_register_driver (&i2c_parport_driver); -} - -static void __exit i2c_parport_exit(void) -{ -parport_unregister_driver (&i2c_parport_driver); -} +module_parport_driver (i2c_parport_driver);MODULE_AUTHOR ("Jean Delvare <[email protected]>" );MODULE_DESCRIPTION ("I2C bus over parallel port" );MODULE_LICENSE ("GPL" ); - -module_init (i2c_parport_init); -module_exit (i2c_parport_exit);
Signature · 1 line
2.30.2
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v5.13-rc7 next-20210618]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/i2c-parport-Switch-to-use-module_parport_driver/20210617-023152 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next config: x86_64-randconfig-a016-20210621 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project e1adf90826a57b674eee79b071fb46c1f5683cd0)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/460eecb7fb1072dc8d5c7e5b3ecac6867957f2fa
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/i2c-parport-Switch-to-use-module_parport_driver/20210617-023152 git checkout 460eecb7fb1072dc8d5c7e5b3ecac6867957f2fa
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/i2c/busses/i2c-parport.c:272:3: error: void function 'i2c_parport_attach' should not return a value [-Wreturn-type]
return -ENODEV;
^ ~~~~~~~
drivers/i2c/busses/i2c-parport.c:277:3: error: void function 'i2c_parport_attach' should not return a value [-Wreturn-type]
return -ENODEV;
^ ~~~~~~~2 errors generated.
vim +/i2c_parport_attach +272 drivers/i2c/busses/i2c-parport.c
263
264 static void i2c_parport_attach(struct parport *port)
265 {
266 struct i2c_par *adapter;
267 int i;
268 struct pardev_cb i2c_parport_cb;
269
270 if (type < 0) {
271 pr_warn("adapter type unspecified\n");
> 272 return -ENODEV;
273 }
274
275 if (type >= ARRAY_SIZE(adapter_parm)) {
276 pr_warn("invalid type (%d)\n", type);
277 return -ENODEV;
278 }
279
280 for (i = 0; i < MAX_DEVICE; i++) {
281 if (parport[i] == -1)
282 continue;
283 if (port->number == parport[i])
284 break;
285 }
286 if (i == MAX_DEVICE) {
287 pr_debug("Not using parport%d.\n", port->number);
288 return;
289 }
290
291 adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
292 if (!adapter)
293 return;
294 memset(&i2c_parport_cb, 0, sizeof(i2c_parport_cb));
295 i2c_parport_cb.flags = PARPORT_FLAG_EXCL;
296 i2c_parport_cb.irq_func = i2c_parport_irq;
297 i2c_parport_cb.private = adapter;
298
299 pr_debug("attaching to %s\n", port->name);
300 parport_disable_irq(port);
301 adapter->pdev = parport_register_dev_model(port, "i2c-parport",
302 &i2c_parport_cb, i);
303 if (!adapter->pdev) {
304 pr_err("Unable to register with parport\n");
305 goto err_free;
306 }
307
308 /* Fill the rest of the structure */
309 adapter->adapter.owner = THIS_MODULE;
310 adapter->adapter.class = I2C_CLASS_HWMON;
311 strlcpy(adapter->adapter.name, "Parallel port adapter",
312 sizeof(adapter->adapter.name));
313 adapter->algo_data = parport_algo_data;
314 /* Slow down if we can't sense SCL */
315 if (!adapter_parm[type].getscl.val) {
316 adapter->algo_data.getscl = NULL;
317 adapter->algo_data.udelay = 50; /* ~10 kbps */
318 }
319 adapter->algo_data.data = port;
320 adapter->adapter.algo_data = &adapter->algo_data;
321 adapter->adapter.dev.parent = port->physport->dev;
322
323 if (parport_claim_or_block(adapter->pdev) < 0) {
324 dev_err(&adapter->pdev->dev,
325 "Could not claim parallel port\n");
326 goto err_unregister;
327 }
328
329 /* Reset hardware to a sane state (SCL and SDA high) */
330 parport_setsda(port, 1);
331 parport_setscl(port, 1);
332 /* Other init if needed (power on...) */
333 if (adapter_parm[type].init.val) {
334 line_set(port, 1, &adapter_parm[type].init);
335 /* Give powered devices some time to settle */
336 msleep(100);
337 }
338
339 if (i2c_bit_add_bus(&adapter->adapter) < 0) {
340 dev_err(&adapter->pdev->dev, "Unable to register with I2C\n");
341 goto err_unregister;
342 }
343
344 /* Setup SMBus alert if supported */
345 if (adapter_parm[type].smbus_alert) {
346 struct i2c_client *ara;
347
348 ara = i2c_new_smbus_alert_device(&adapter->adapter,
349 &adapter->alert_data);
350 if (!IS_ERR(ara)) {
351 adapter->ara = ara;
352 parport_enable_irq(port);
353 } else {
354 dev_warn(&adapter->pdev->dev,
355 "Failed to register ARA client\n");
356 }
357 }
358
359 /* Add the new adapter to the list */
360 mutex_lock(&adapter_list_lock);
361 list_add_tail(&adapter->node, &adapter_list);
362 mutex_unlock(&adapter_list_lock);
363 return;
364
365 err_unregister:
366 parport_release(adapter->pdev);
367 parport_unregister_device(adapter->pdev);
368 err_free:
369 kfree(adapter);
370 }
371
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Hi Andy,
drivers/i2c/busses/i2c-parport.c static void i2c_parport_attach(struct parport *port)
Quoted 12 lines · Andy Shevchenko
Switch to use
module_parport_driver()to reduce boilerplate code.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-parport.c | 36 ++++++++++---------------------- 1 file changed, 11 insertions(+), 25 deletions(-)drivers/i2c/busses/i2c-parport.c +0
-0@@ -267,6 +267,16 @@ static void i2c_parport_attach(struct parport *port)
^^^^
drivers/i2c/busses/i2c-parport.c static void i2c_parport_attach(struct parport *port) · line 272
Quoted 6 lines
drivers/i2c/busses/i2c-parport.c +3
-0int i;struct pardev_cb i2c_parport_cb; +if (type <0 ) { +pr_warn ("adapter type unspecified\n" ); +return -ENODEV ;
^^^^^^^
drivers/i2c/busses/i2c-parport.c static void i2c_parport_attach(struct parport *port) · line 273
Quoted 1 line
drivers/i2c/busses/i2c-parport.c +1
-0+ }
Does not build.
Signature · 2 lines
Jean Delvare SUSE L3 Support