Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] IDE core: driver layer error checking

Check driver layer return values in IDE core.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Randy Dunlap and committed by
Linus Torvalds
349ae23f 5ac24697

+46 -9
+21 -4
drivers/ide/ide-probe.c
··· 623 623 624 624 static void hwif_register (ide_hwif_t *hwif) 625 625 { 626 + int ret; 627 + 626 628 /* register with global device tree */ 627 629 strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); 628 630 hwif->gendev.driver_data = hwif; ··· 636 634 hwif->gendev.parent = NULL; 637 635 } 638 636 hwif->gendev.release = hwif_release_dev; 639 - device_register(&hwif->gendev); 637 + ret = device_register(&hwif->gendev); 638 + if (ret < 0) 639 + printk(KERN_WARNING "IDE: %s: device_register error: %d\n", 640 + __FUNCTION__, ret); 640 641 } 641 642 642 643 static int wait_hwif_ready(ide_hwif_t *hwif) ··· 889 884 890 885 if (hwif->present) { 891 886 u16 unit = 0; 887 + int ret; 888 + 892 889 for (unit = 0; unit < MAX_DRIVES; ++unit) { 893 890 ide_drive_t *drive = &hwif->drives[unit]; 894 891 /* For now don't attach absent drives, we may 895 892 want them on default or a new "empty" class 896 893 for hotplug reprobing ? */ 897 894 if (drive->present) { 898 - device_register(&drive->gendev); 895 + ret = device_register(&drive->gendev); 896 + if (ret < 0) 897 + printk(KERN_WARNING "IDE: %s: " 898 + "device_register error: %d\n", 899 + __FUNCTION__, ret); 899 900 } 900 901 } 901 902 } ··· 1420 1409 if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) 1421 1410 hwif->chipset = ide_generic; 1422 1411 for (unit = 0; unit < MAX_DRIVES; ++unit) 1423 - if (hwif->drives[unit].present) 1424 - device_register(&hwif->drives[unit].gendev); 1412 + if (hwif->drives[unit].present) { 1413 + int ret = device_register( 1414 + &hwif->drives[unit].gendev); 1415 + if (ret < 0) 1416 + printk(KERN_WARNING "IDE: %s: " 1417 + "device_register error: %d\n", 1418 + __FUNCTION__, ret); 1419 + } 1425 1420 } 1426 1421 } 1427 1422 return 0;
+18 -4
drivers/ide/ide-proc.c
··· 326 326 { 327 327 struct device *dev = &drive->gendev; 328 328 int ret = 1; 329 + int err; 329 330 330 331 down_write(&dev->bus->subsys.rwsem); 331 332 device_release_driver(dev); 332 333 /* FIXME: device can still be in use by previous driver */ 333 334 strlcpy(drive->driver_req, driver, sizeof(drive->driver_req)); 334 - device_attach(dev); 335 + err = device_attach(dev); 336 + if (err < 0) 337 + printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", 338 + __FUNCTION__, err); 335 339 drive->driver_req[0] = 0; 336 - if (dev->driver == NULL) 337 - device_attach(dev); 340 + if (dev->driver == NULL) { 341 + err = device_attach(dev); 342 + if (err < 0) 343 + printk(KERN_WARNING 344 + "IDE: %s: device_attach(2) error: %d\n", 345 + __FUNCTION__, err); 346 + } 338 347 if (dev->driver && !strcmp(dev->driver->name, driver)) 339 348 ret = 0; 340 349 up_write(&dev->bus->subsys.rwsem); ··· 535 526 536 527 static int ide_drivers_show(struct seq_file *s, void *p) 537 528 { 538 - bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); 529 + int err; 530 + 531 + err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); 532 + if (err < 0) 533 + printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", 534 + __FUNCTION__, err); 539 535 return 0; 540 536 } 541 537
+7 -1
drivers/ide/ide.c
··· 1997 1997 */ 1998 1998 static int __init ide_init(void) 1999 1999 { 2000 + int ret; 2001 + 2000 2002 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); 2001 2003 system_bus_speed = ide_system_bus_speed(); 2002 2004 2003 - bus_register(&ide_bus_type); 2005 + ret = bus_register(&ide_bus_type); 2006 + if (ret < 0) { 2007 + printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); 2008 + return ret; 2009 + } 2004 2010 2005 2011 init_ide_data(); 2006 2012