diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-14 10:42:40 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-14 10:42:40 -0800 |
commit | 3e2b32b69308e974cd1167beaf266d3c716e4734 (patch) | |
tree | 0f1b24dcb7b066a6322d33235b95655d885695ac /drivers | |
parent | 3824ba7df91745da6ebac703c87c3b801c34fdd0 (diff) | |
parent | 9c08a938ce5a3e1c9d5f764dc6ae844cb1af76ff (diff) | |
download | op-kernel-dev-3e2b32b69308e974cd1167beaf266d3c716e4734.zip op-kernel-dev-3e2b32b69308e974cd1167beaf266d3c716e4734.tar.gz |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'drivers')
36 files changed, 285 insertions, 193 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 2b90501..730a9ce 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -78,7 +78,13 @@ int driver_probe_device(struct device_driver * drv, struct device * dev) pr_debug("%s: Matched Device %s with Driver %s\n", drv->bus->name, dev->bus_id, drv->name); dev->driver = drv; - if (drv->probe) { + if (dev->bus->probe) { + ret = dev->bus->probe(dev); + if (ret) { + dev->driver = NULL; + goto ProbeFailed; + } + } else if (drv->probe) { ret = drv->probe(dev); if (ret) { dev->driver = NULL; @@ -203,7 +209,9 @@ static void __device_release_driver(struct device * dev) sysfs_remove_link(&dev->kobj, "driver"); klist_remove(&dev->knode_driver); - if (drv->remove) + if (dev->bus->remove) + dev->bus->remove(dev); + else if (drv->remove) drv->remove(dev); dev->driver = NULL; put_driver(drv); diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 161f3a3..b400314 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -171,6 +171,11 @@ static void klist_devices_put(struct klist_node *n) */ int driver_register(struct device_driver * drv) { + if ((drv->bus->probe && drv->probe) || + (drv->bus->remove && drv->remove) || + (drv->bus->shutdown && drv->shutdown)) { + printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name); + } klist_init(&drv->klist_devices, klist_devices_get, klist_devices_put); init_completion(&drv->unloaded); return bus_add_driver(drv); diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 0f81731..461554a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -327,7 +327,7 @@ EXPORT_SYMBOL_GPL(platform_device_register); * @pdev: platform device we're unregistering * * Unregistration is done in 2 steps. Fisrt we release all resources - * and remove it from the sybsystem, then we drop reference count by + * and remove it from the subsystem, then we drop reference count by * calling platform_device_put(). */ void platform_device_unregister(struct platform_device * pdev) diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c index f50a08b..c2475f3 100644 --- a/drivers/base/power/shutdown.c +++ b/drivers/base/power/shutdown.c @@ -35,12 +35,15 @@ extern int sysdev_shutdown(void); */ void device_shutdown(void) { - struct device * dev; + struct device * dev, *devn; down_write(&devices_subsys.rwsem); - list_for_each_entry_reverse(dev, &devices_subsys.kset.list, + list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list, kobj.entry) { - if (dev->driver && dev->driver->shutdown) { + if (dev->bus && dev->bus->shutdown) { + dev_dbg(dev, "shutdown\n"); + dev->bus->shutdown(dev); + } else if (dev->driver && dev->driver->shutdown) { dev_dbg(dev, "shutdown\n"); dev->driver->shutdown(dev); } diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c index ffe6f44..ca8e69d 100644 --- a/drivers/dio/dio-driver.c +++ b/drivers/dio/dio-driver.c @@ -83,7 +83,6 @@ int dio_register_driver(struct dio_driver *drv) /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &dio_bus_type; - drv->driver.probe = dio_device_probe; /* register with core */ count = driver_register(&drv->driver); @@ -145,7 +144,8 @@ static int dio_bus_match(struct device *dev, struct device_driver *drv) struct bus_type dio_bus_type = { .name = "dio", - .match = dio_bus_match + .match = dio_bus_match, + .probe = dio_device_probe, }; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 52b7747..0ce58b5 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -63,13 +63,6 @@ static int i2c_bus_resume(struct device * dev) return rc; } -struct bus_type i2c_bus_type = { - .name = "i2c", - .match = i2c_device_match, - .suspend = i2c_bus_suspend, - .resume = i2c_bus_resume, -}; - static int i2c_device_probe(struct device *dev) { return -ENODEV; @@ -80,6 +73,15 @@ static int i2c_device_remove(struct device *dev) return 0; } +struct bus_type i2c_bus_type = { + .name = "i2c", + .match = i2c_device_match, + .probe = i2c_device_probe, + .remove = i2c_device_remove, + .suspend = i2c_bus_suspend, + .resume = i2c_bus_resume, +}; + void i2c_adapter_dev_release(struct device *dev) { struct i2c_adapter *adap = dev_to_i2c_adapter(dev); @@ -90,8 +92,6 @@ struct device_driver i2c_adapter_driver = { .owner = THIS_MODULE, .name = "i2c_adapter", .bus = &i2c_bus_type, - .probe = i2c_device_probe, - .remove = i2c_device_remove, }; static void i2c_adapter_class_dev_release(struct class_device *dev) @@ -294,8 +294,6 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) /* add the driver to the list of i2c drivers in the driver core */ driver->driver.owner = owner; driver->driver.bus = &i2c_bus_type; - driver->driver.probe = i2c_device_probe; - driver->driver.remove = i2c_device_remove; res = driver_register(&driver->driver); if (res) diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 9b2ebd2..ef09a7e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -3256,9 +3256,8 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive) } #endif -static int ide_cd_remove(struct device *dev) +static void ide_cd_remove(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); struct cdrom_info *info = drive->driver_data; ide_unregister_subdriver(drive, info->driver); @@ -3266,8 +3265,6 @@ static int ide_cd_remove(struct device *dev) del_gendisk(info->disk); ide_cd_put(info); - - return 0; } static void ide_cd_release(struct kref *kref) @@ -3291,7 +3288,7 @@ static void ide_cd_release(struct kref *kref) kfree(info); } -static int ide_cd_probe(struct device *); +static int ide_cd_probe(ide_drive_t *); #ifdef CONFIG_PROC_FS static int proc_idecd_read_capacity @@ -3317,9 +3314,9 @@ static ide_driver_t ide_cdrom_driver = { .owner = THIS_MODULE, .name = "ide-cdrom", .bus = &ide_bus_type, - .probe = ide_cd_probe, - .remove = ide_cd_remove, }, + .probe = ide_cd_probe, + .remove = ide_cd_remove, .version = IDECD_VERSION, .media = ide_cdrom, .supports_dsc_overlap = 1, @@ -3413,9 +3410,8 @@ static char *ignore = NULL; module_param(ignore, charp, 0400); MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); -static int ide_cd_probe(struct device *dev) +static int ide_cd_probe(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); struct cdrom_info *info; struct gendisk *g; struct request_sense sense; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index cab362e..245b508 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -997,9 +997,8 @@ static void ide_cacheflush_p(ide_drive_t *drive) printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); } -static int ide_disk_remove(struct device *dev) +static void ide_disk_remove(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); struct ide_disk_obj *idkp = drive->driver_data; struct gendisk *g = idkp->disk; @@ -1010,8 +1009,6 @@ static int ide_disk_remove(struct device *dev) ide_cacheflush_p(drive); ide_disk_put(idkp); - - return 0; } static void ide_disk_release(struct kref *kref) @@ -1027,12 +1024,10 @@ static void ide_disk_release(struct kref *kref) kfree(idkp); } -static int ide_disk_probe(struct device *dev); +static int ide_disk_probe(ide_drive_t *drive); -static void ide_device_shutdown(struct device *dev) +static void ide_device_shutdown(ide_drive_t *drive) { - ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); - #ifdef CONFIG_ALPHA /* On Alpha, halt(8) doesn't actually turn the machine off, it puts you into the sort of firmware monitor. Typically, @@ -1054,7 +1049,7 @@ static void ide_device_shutdown(struct device *dev) } printk("Shutdown: %s\n", drive->name); - dev->bus->suspend(dev, PMSG_SUSPEND); + drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND); } static ide_driver_t idedisk_driver = { @@ -1062,10 +1057,10 @@ static ide_driver_t idedisk_driver = { .owner = THIS_MODULE, .name = "ide-disk", .bus = &ide_bus_type, - .probe = ide_disk_probe, - .remove = ide_disk_remove, - .shutdown = ide_device_shutdown, }, + .probe = ide_disk_probe, + .remove = ide_disk_remove, + .shutdown = ide_device_shutdown, .version = IDEDISK_VERSION, .media = ide_disk, .supports_dsc_overlap = 0, @@ -1182,9 +1177,8 @@ static struct block_device_operations idedisk_ops = { MODULE_DESCRIPTION("ATA DISK Driver"); -static int ide_disk_probe(struct device *dev) +static int ide_disk_probe(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); struct ide_disk_obj *idkp; struct gendisk *g; diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 5945f55..1f8db9a 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1871,9 +1871,8 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) idefloppy_add_settings(drive); } -static int ide_floppy_remove(struct device *dev) +static void ide_floppy_remove(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); idefloppy_floppy_t *floppy = drive->driver_data; struct gendisk *g = floppy->disk; @@ -1882,8 +1881,6 @@ static int ide_floppy_remove(struct device *dev) del_gendisk(g); ide_floppy_put(floppy); - - return 0; } static void ide_floppy_release(struct kref *kref) @@ -1922,16 +1919,16 @@ static ide_proc_entry_t idefloppy_proc[] = { #endif /* CONFIG_PROC_FS */ -static int ide_floppy_probe(struct device *); +static int ide_floppy_probe(ide_drive_t *); static ide_driver_t idefloppy_driver = { .gen_driver = { .owner = THIS_MODULE, .name = "ide-floppy", .bus = &ide_bus_type, - .probe = ide_floppy_probe, - .remove = ide_floppy_remove, }, + .probe = ide_floppy_probe, + .remove = ide_floppy_remove, .version = IDEFLOPPY_VERSION, .media = ide_floppy, .supports_dsc_overlap = 0, @@ -2136,9 +2133,8 @@ static struct block_device_operations idefloppy_ops = { .revalidate_disk= idefloppy_revalidate_disk }; -static int ide_floppy_probe(struct device *dev) +static int ide_floppy_probe(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); idefloppy_floppy_t *floppy; struct gendisk *g; diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index fab9b2b..0101d0d 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -4682,9 +4682,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) idetape_add_settings(drive); } -static int ide_tape_remove(struct device *dev) +static void ide_tape_remove(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); idetape_tape_t *tape = drive->driver_data; ide_unregister_subdriver(drive, tape->driver); @@ -4692,8 +4691,6 @@ static int ide_tape_remove(struct device *dev) ide_unregister_region(tape->disk); ide_tape_put(tape); - - return 0; } static void ide_tape_release(struct kref *kref) @@ -4745,16 +4742,16 @@ static ide_proc_entry_t idetape_proc[] = { #endif -static int ide_tape_probe(struct device *); +static int ide_tape_probe(ide_drive_t *); static ide_driver_t idetape_driver = { .gen_driver = { .owner = THIS_MODULE, .name = "ide-tape", .bus = &ide_bus_type, - .probe = ide_tape_probe, - .remove = ide_tape_remove, }, + .probe = ide_tape_probe, + .remove = ide_tape_remove, .version = IDETAPE_VERSION, .media = ide_tape, .supports_dsc_overlap = 1, @@ -4825,9 +4822,8 @@ static struct block_device_operations idetape_block_ops = { .ioctl = idetape_ioctl, }; -static int ide_tape_probe(struct device *dev) +static int ide_tape_probe(ide_drive_t *drive) { - ide_drive_t *drive = to_ide_device(dev); idetape_tape_t *tape; struct gendisk *g; int minor; @@ -4883,9 +4879,9 @@ static int ide_tape_probe(struct device *dev) idetape_setup(drive, tape, minor); class_device_create(idetape_sysfs_class, NULL, - MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); + MKDEV(IDETAPE_MAJOR, minor), &drive->gendev, "%s", tape->name); class_device_create(idetape_sysfs_class, NULL, - MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); + MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name); devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), S_IFCHR | S_IRUGO | S_IWUGO, diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index ec5a4cb..afeb02bb 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1949,10 +1949,41 @@ static int ide_uevent(struct device *dev, char **envp, int num_envp, return 0; } +static int generic_ide_probe(struct device *dev) +{ + ide_drive_t *drive = to_ide_device(dev); + ide_driver_t *drv = to_ide_driver(dev->driver); + + return drv->probe ? drv->probe(drive) : -ENODEV; +} + +static int generic_ide_remove(struct device *dev) +{ + ide_drive_t *drive = to_ide_device(dev); + ide_driver_t *drv = to_ide_driver(dev->driver); + + if (drv->remove) + drv->remove(drive); + + return 0; +} + +static void generic_ide_shutdown(struct device *dev) +{ + ide_drive_t *drive = to_ide_device(dev); + ide_driver_t *drv = to_ide_driver(dev->driver); + + if (dev->driver && drv->shutdown) + drv->shutdown(drive); +} + struct bus_type ide_bus_type = { .name = "ide", .match = ide_bus_match, .uevent = ide_uevent, + .probe = generic_ide_probe, + .remove = generic_ide_remove, + .shutdown = generic_ide_shutdown, .dev_attrs = ide_dev_attrs, .suspend = generic_ide_suspend, .resume = generic_ide_resume, diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index caac6d6..b765a155 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c @@ -50,9 +50,7 @@ static DECLARE_MUTEX(gameport_sem); static LIST_HEAD(gameport_list); -static struct bus_type gameport_bus = { - .name = "gameport", -}; +static struct bus_type gameport_bus; static void gameport_add_port(struct gameport *gameport); static void gameport_destroy_port(struct gameport *gameport); @@ -703,11 +701,15 @@ static int gameport_driver_remove(struct device *dev) return 0; } +static struct bus_type gameport_bus = { + .name = "gameport", + .probe = gameport_driver_probe, + .remove = gameport_driver_remove, +}; + void __gameport_register_driver(struct gameport_driver *drv, struct module *owner) { drv->driver.bus = &gameport_bus; - drv->driver.probe = gameport_driver_probe; - drv->driver.remove = gameport_driver_remove; gameport_queue_event(drv, owner, GAMEPORT_REGISTER_DRIVER); } diff --git a/drivers/input/input.c b/drivers/input/input.c index fe33ff3..4fe3da3 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -528,40 +528,56 @@ INPUT_DEV_STRING_ATTR_SHOW(name); INPUT_DEV_STRING_ATTR_SHOW(phys); INPUT_DEV_STRING_ATTR_SHOW(uniq); -static int print_modalias_bits(char *buf, char prefix, unsigned long *arr, +static int print_modalias_bits(char *buf, int size, char prefix, unsigned long *arr, unsigned int min, unsigned int max) { int len, i; - len = sprintf(buf, "%c", prefix); + len = snprintf(buf, size, "%c", prefix); for (i = min; i < max; i++) if (arr[LONG(i)] & BIT(i)) - len += sprintf(buf+len, "%X,", i); + len += snprintf(buf + len, size - len, "%X,", i); return len; } -static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf) +static int print_modalias(char *buf, int size, struct input_dev *id) { - struct input_dev *id = to_input_dev(dev); - ssize_t len = 0; + int len; - len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-", + len = snprintf(buf, size, "input:b%04Xv%04Xp%04Xe%04X-", id->id.bustype, id->id.vendor, id->id.product, id->id.version); - len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX); - len += print_modalias_bits(buf+len, 'k', id->keybit, + len += print_modalias_bits(buf + len, size - len, 'e', id->evbit, + 0, EV_MAX); + len += print_modalias_bits(buf + len, size - len, 'k', id->keybit, KEY_MIN_INTERESTING, KEY_MAX); - len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX); - len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX); - len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX); - len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX); - len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX); - len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX); - len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX); - len += sprintf(buf+len, "\n"); + len += print_modalias_bits(buf + len, size - len, 'r', id->relbit, + 0, REL_MAX); + len += print_modalias_bits(buf + len, size - len, 'a', id->absbit, + 0, ABS_MAX); + len += print_modalias_bits(buf + len, size - len, 'm', id->mscbit, + 0, MSC_MAX); + len += print_modalias_bits(buf + len, size - len, 'l', id->ledbit, + 0, LED_MAX); + len += print_modalias_bits(buf + len, size - len, 's', id->sndbit, + 0, SND_MAX); + len += print_modalias_bits(buf + len, size - len, 'f', id->ffbit, + 0, FF_MAX); + len += print_modalias_bits(buf + len, size - len, 'w', id->swbit, + 0, SW_MAX); + return len; +} + +static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf) +{ + struct input_dev *id = to_input_dev(dev); + ssize_t len; + + len = print_modalias(buf, PAGE_SIZE, id); + len += snprintf(buf + len, PAGE_SIZE-len, "\n"); return len; } static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); @@ -728,8 +744,11 @@ static int input_dev_uevent(struct class_device *cdev, char **envp, if (test_bit(EV_SW, dev->evbit)) INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX); - envp[i] = NULL; + envp[i++] = buffer + len; + len += snprintf(buffer + len, buffer_size - len, "MODALIAS="); + len += print_modalias(buffer + len, buffer_size - len, dev) + 1; + envp[i] = NULL; return 0; } diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 8e530cc..2f76813 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -59,9 +59,7 @@ static DECLARE_MUTEX(serio_sem); static LIST_HEAD(serio_list); -static struct bus_type serio_bus = { - .name = "serio", -}; +static struct bus_type serio_bus; static void serio_add_port(struct serio *serio); static void serio_destroy_port(struct serio *serio); @@ -750,11 +748,15 @@ static int serio_driver_remove(struct device *dev) return 0; } +static struct bus_type serio_bus = { + .name = "serio", + .probe = serio_driver_probe, + .remove = serio_driver_remove, +}; + void __serio_register_driver(struct serio_driver *drv, struct module *owner) { drv->driver.bus = &serio_bus; - drv->driver.probe = serio_driver_probe; - drv->driver.remove = serio_driver_remove; serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER); } diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 2a545ce..ed6d317 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -211,6 +211,9 @@ struct bus_type macio_bus_type = { .name = "macio", .match = macio_bus_match, .uevent = macio_uevent, + .probe = macio_device_probe, + .remove = macio_device_remove, + .shutdown = macio_device_shutdown, .suspend = macio_device_suspend, .resume = macio_device_resume, .dev_attrs = macio_dev_attrs, @@ -528,9 +531,6 @@ int macio_register_driver(struct macio_driver *drv) /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &macio_bus_type; - drv->driver.probe = macio_device_probe; - drv->driver.remove = macio_device_remove; - drv->driver.shutdown = macio_device_shutdown; /* register with core */ count = driver_register(&drv->driver); diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index f65f64b..44fcbe7 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -779,9 +779,8 @@ static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) return 0; } -static int dvb_bt8xx_probe(struct device *dev) +static int dvb_bt8xx_probe(struct bttv_sub_device *sub) { - struct bttv_sub_device *sub = to_bttv_sub_dev(dev); struct dvb_bt8xx_card *card; struct pci_dev* bttv_pci_dev; int ret; @@ -890,13 +889,13 @@ static int dvb_bt8xx_probe(struct device *dev) return ret; } - dev_set_drvdata(dev, card); + dev_set_drvdata(&sub->dev, card); return 0; } -static int dvb_bt8xx_remove(struct device *dev) +static int dvb_bt8xx_remove(struct bttv_sub_device *sub) { - struct dvb_bt8xx_card *card = dev_get_drvdata(dev); + struct dvb_bt8xx_card *card = dev_get_drvdata(&sub->dev); dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr); @@ -919,14 +918,14 @@ static int dvb_bt8xx_remove(struct device *dev) static struct bttv_sub_driver driver = { .drv = { .name = "dvb-bt8xx", - .probe = dvb_bt8xx_probe, - .remove = dvb_bt8xx_remove, - /* FIXME: - * .shutdown = dvb_bt8xx_shutdown, - * .suspend = dvb_bt8xx_suspend, - * .resume = dvb_bt8xx_resume, - */ }, + .probe = dvb_bt8xx_probe, + .remove = dvb_bt8xx_remove, + /* FIXME: + * .shutdown = dvb_bt8xx_shutdown, + * .suspend = dvb_bt8xx_suspend, + * .resume = dvb_bt8xx_resume, + */ }; static int __init dvb_bt8xx_init(void) diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c index d64accc..c4d5e2b 100644 --- a/drivers/media/video/bttv-gpio.c +++ b/drivers/media/video/bttv-gpio.c @@ -47,9 +47,29 @@ static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv) return 0; } +static int bttv_sub_probe(struct device *dev) +{ + struct bttv_sub_device *sdev = to_bttv_sub_dev(dev); + struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver); + + return sub->probe ? sub->probe(sdev) : -ENODEV; +} + +static int bttv_sub_remove(struct device *dev) +{ + struct bttv_sub_device *sdev = to_bttv_sub_dev(dev); + struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver); + + if (sub->remove) + sub->remove(sdev); + return 0; +} + struct bus_type bttv_sub_bus_type = { - .name = "bttv-sub", - .match = &bttv_sub_bus_match, + .name = "bttv-sub", + .match = &bttv_sub_bus_match, + .probe = bttv_sub_probe, + .remove = bttv_sub_remove, }; EXPORT_SYMBOL(bttv_sub_bus_type); diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h index e370d74..9908c8e 100644 --- a/drivers/media/video/bttv.h +++ b/drivers/media/video/bttv.h @@ -365,6 +365,8 @@ struct bttv_sub_device { struct bttv_sub_driver { struct device_driver drv; char wanted[BUS_ID_SIZE]; + int (*probe)(struct bttv_sub_device *sub); + void (*remove)(struct bttv_sub_device *sub); void (*gpio_irq)(struct bttv_sub_device *sub); }; #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv) diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c index 55ba230..75f401d 100644 --- a/drivers/mfd/mcp-core.c +++ b/drivers/mfd/mcp-core.c @@ -77,6 +77,8 @@ static int mcp_bus_resume(struct device *dev) static struct bus_type mcp_bus_type = { .name = "mcp", .match = mcp_bus_match, + .probe = mcp_bus_probe, + .remove = mcp_bus_remove, .suspend = mcp_bus_suspend, .resume = mcp_bus_resume, }; @@ -227,8 +229,6 @@ EXPORT_SYMBOL(mcp_host_unregister); int mcp_driver_register(struct mcp_driver *mcpdrv) { mcpdrv->drv.bus = &mcp_bus_type; - mcpdrv->drv.probe = mcp_bus_probe; - mcpdrv->drv.remove = mcp_bus_remove; return driver_register(&mcpdrv->drv); } EXPORT_SYMBOL(mcp_driver_register); diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c index ec70166..a2a35fd 100644 --- a/drivers/mmc/mmc_sysfs.c +++ b/drivers/mmc/mmc_sysfs.c @@ -136,17 +136,7 @@ static int mmc_bus_resume(struct device *dev) return ret; } -static struct bus_type mmc_bus_type = { - .name = "mmc", - .dev_attrs = mmc_dev_attrs, - .match = mmc_bus_match, - .uevent = mmc_bus_uevent, - .suspend = mmc_bus_suspend, - .resume = mmc_bus_resume, -}; - - -static int mmc_drv_probe(struct device *dev) +static int mmc_bus_probe(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_card *card = dev_to_mmc_card(dev); @@ -154,7 +144,7 @@ static int mmc_drv_probe(struct device *dev) return drv->probe(card); } -static int mmc_drv_remove(struct device *dev) +static int mmc_bus_remove(struct device *dev) { struct mmc_driver *drv = to_mmc_driver(dev->driver); struct mmc_card *card = dev_to_mmc_card(dev); @@ -164,6 +154,16 @@ static int mmc_drv_remove(struct device *dev) return 0; } +static struct bus_type mmc_bus_type = { + .name = "mmc", + .dev_attrs = mmc_dev_attrs, + .match = mmc_bus_match, + .uevent = mmc_bus_uevent, + .probe = mmc_bus_probe, + .remove = mmc_bus_remove, + .suspend = mmc_bus_suspend, + .resume = mmc_bus_resume, +}; /** * mmc_register_driver - register a media driver @@ -172,8 +172,6 @@ static int mmc_drv_remove(struct device *dev) int mmc_register_driver(struct mmc_driver *drv) { drv->drv.bus = &mmc_bus_type; - drv->drv.probe = mmc_drv_probe; - drv->drv.remove = mmc_drv_remove; return driver_register(&drv->drv); } diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 7146b69..0aa14c9 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -380,8 +380,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner) /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &pci_bus_type; - drv->driver.probe = pci_device_probe; - drv->driver.remove = pci_device_remove; /* FIXME, once all of the existing PCI drivers have been fixed to set * the pci shutdown function, this test can go away. */ if (!drv->driver.shutdown) @@ -513,6 +511,8 @@ struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, .uevent = pci_uevent, + .probe = pci_device_probe, + .remove = pci_device_remove, .suspend = pci_device_suspend, .resume = pci_device_resume, .dev_attrs = pci_dev_attrs, diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 621ec45..0a424a4 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -311,8 +311,6 @@ int pcmcia_register_driver(struct pcmcia_driver *driver) /* initialize common fields */ driver->drv.bus = &pcmcia_bus_type; driver->drv.owner = driver->owner; - driver->drv.probe = pcmcia_device_probe; - driver->drv.remove = pcmcia_device_remove; return driver_register(&driver->drv); } @@ -1200,6 +1198,8 @@ struct bus_type pcmcia_bus_type = { .uevent = pcmcia_bus_uevent, .match = pcmcia_bus_match, .dev_attrs = pcmcia_dev_attrs, + .probe = pcmcia_device_probe, + .remove = pcmcia_device_remove, .suspend = pcmcia_dev_suspend, .resume = pcmcia_dev_resume, }; diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 15fb758..7cafacd 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -195,6 +195,8 @@ static int pnp_bus_resume(struct device *dev) struct bus_type pnp_bus_type = { .name = "pnp", .match = pnp_bus_match, + .probe = pnp_device_probe, + .remove = pnp_device_remove, .suspend = pnp_bus_suspend, .resume = pnp_bus_resume, }; @@ -215,8 +217,6 @@ int pnp_register_driver(struct pnp_driver *drv) drv->driver.name = drv->name; drv->driver.bus = &pnp_bus_type; - drv->driver.probe = pnp_device_probe; - drv->driver.remove = pnp_device_remove; count = driver_register(&drv->driver); diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c index dc74960..5480119 100644 --- a/drivers/rapidio/rio-driver.c +++ b/drivers/rapidio/rio-driver.c @@ -147,8 +147,6 @@ int rio_register_driver(struct rio_driver *rdrv) /* initialize common driver fields */ rdrv->driver.name = rdrv->name; rdrv->driver.bus = &rio_bus_type; - rdrv->driver.probe = rio_device_probe; - rdrv->driver.remove = rio_device_remove; /* register with core */ return driver_register(&rdrv->driver); @@ -204,7 +202,9 @@ static struct device rio_bus = { struct bus_type rio_bus_type = { .name = "rapidio", .match = rio_match_bus, - .dev_attrs = rio_dev_attrs + .dev_attrs = rio_dev_attrs, + .probe = rio_device_probe, + .remove = rio_device_remove, }; /** diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index e849289..503a568 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -52,11 +52,7 @@ ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer, return 0; } -static struct bus_type ccwgroup_bus_type = { - .name = "ccwgroup", - .match = ccwgroup_bus_match, - .uevent = ccwgroup_uevent, -}; +static struct bus_type ccwgroup_bus_type; static inline void __ccwgroup_remove_symlinks(struct ccwgroup_device *gdev) @@ -389,6 +385,14 @@ ccwgroup_remove (struct device *dev) return 0; } +static struct bus_type ccwgroup_bus_type = { + .name = "ccwgroup", + .match = ccwgroup_bus_match, + .uevent = ccwgroup_uevent, + .probe = ccwgroup_probe, + .remove = ccwgroup_remove, +}; + int ccwgroup_driver_register (struct ccwgroup_driver *cdriver) { @@ -396,8 +400,6 @@ ccwgroup_driver_register (struct ccwgroup_driver *cdriver) cdriver->driver = (struct device_driver) { .bus = &ccwgroup_bus_type, .name = cdriver->name, - .probe = ccwgroup_probe, - .remove = ccwgroup_remove, }; return driver_register(&cdriver->driver); diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index e565193..2d319fb 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -542,9 +542,41 @@ css_bus_match (struct device *dev, struct device_driver *drv) return 0; } +static int +css_probe (struct device *dev) +{ + struct subchannel *sch; + + sch = to_subchannel(dev); + sch->driver = container_of (dev->driver, struct css_driver, drv); + return (sch->driver->probe ? sch->driver->probe(sch) : 0); +} + +static int +css_remove (struct device *dev) +{ + struct subchannel *sch; + + sch = to_subchannel(dev); + return (sch->driver->remove ? sch->driver->remove(sch) : 0); +} + +static void +css_shutdown (struct device *dev) +{ + struct subchannel *sch; + + sch = to_subchannel(dev); + if (sch->driver->shutdown) + sch->driver->shutdown(sch); +} + struct bus_type css_bus_type = { - .name = "css", - .match = &css_bus_match, + .name = "css", + .match = css_bus_match, + .probe = css_probe, + .remove = css_remove, + .shutdown = css_shutdown, }; subsys_initcall(init_channel_subsystem); diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index 251ebd7..aa5ab5d 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h @@ -115,6 +115,7 @@ struct ccw_device_private { * Currently, we only care about I/O subchannels (type 0), these * have a ccw_device connected to them. */ +struct subchannel; struct css_driver { unsigned int subchannel_type; struct device_driver drv; @@ -122,6 +123,9 @@ struct css_driver { int (*notify)(struct device *, int); void (*verify)(struct device *); void (*termination)(struct device *); + int (*probe)(struct subchannel *); + int (*remove)(struct subchannel *); + void (*shutdown)(struct subchannel *); }; /* diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index fa3e4c0..eb73605 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -107,33 +107,29 @@ ccw_uevent (struct device *dev, char **envp, int num_envp, return 0; } -struct bus_type ccw_bus_type = { - .name = "ccw", - .match = &ccw_bus_match, - .uevent = &ccw_uevent, -}; +struct bus_type ccw_bus_type; -static int io_subchannel_probe (struct device *); -static int io_subchannel_remove (struct device *); +static int io_subchannel_probe (struct subchannel *); +static int io_subchannel_remove (struct subchannel *); void io_subchannel_irq (struct device *); static int io_subchannel_notify(struct device *, int); static void io_subchannel_verify(struct device *); static void io_subchannel_ioterm(struct device *); -static void io_subchannel_shutdown(struct device *); +static void io_subchannel_shutdown(struct subchannel *); struct css_driver io_subchannel_driver = { .subchannel_type = SUBCHANNEL_TYPE_IO, .drv = { .name = "io_subchannel", .bus = &css_bus_type, - .probe = &io_subchannel_probe, - .remove = &io_subchannel_remove, - .shutdown = &io_subchannel_shutdown, }, .irq = io_subchannel_irq, .notify = io_subchannel_notify, .verify = io_subchannel_verify, .termination = io_subchannel_ioterm, + .probe = io_subchannel_probe, + .remove = io_subchannel_remove, + .shutdown = io_subchannel_shutdown, }; struct workqueue_struct *ccw_device_work; @@ -803,14 +799,12 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) } static int -io_subchannel_probe (struct device *pdev) +io_subchannel_probe (struct subchannel *sch) { - struct subchannel *sch; struct ccw_device *cdev; int rc; unsigned long flags; - sch = to_subchannel(pdev); if (sch->dev.driver_data) { /* * This subchannel already has an associated ccw_device. @@ -846,7 +840,7 @@ io_subchannel_probe (struct device *pdev) memset(cdev->private, 0, sizeof(struct ccw_device_private)); atomic_set(&cdev->private->onoff, 0); cdev->dev = (struct device) { - .parent = pdev, + .parent = &sch->dev, .release = ccw_device_release, }; INIT_LIST_HEAD(&cdev->private->kick_work.entry); @@ -859,7 +853,7 @@ io_subchannel_probe (struct device *pdev) return -ENODEV; } - rc = io_subchannel_recog(cdev, to_subchannel(pdev)); + rc = io_subchannel_recog(cdev, sch); if (rc) { spin_lock_irqsave(&sch->lock, flags); sch->dev.driver_data = NULL; @@ -883,17 +877,17 @@ ccw_device_unregister(void *data) } static int -io_subchannel_remove (struct device *dev) +io_subchannel_remove (struct subchannel *sch) { struct ccw_device *cdev; unsigned long flags; - if (!dev->driver_data) + if (!sch->dev.driver_data) return 0; - cdev = dev->driver_data; + cdev = sch->dev.driver_data; /* Set ccw device to not operational and drop reference. */ spin_lock_irqsave(cdev->ccwlock, flags); - dev->driver_data = NULL; + sch->dev.driver_data = NULL; cdev->private->state = DEV_STATE_NOT_OPER; spin_unlock_irqrestore(cdev->ccwlock, flags); /* @@ -948,14 +942,12 @@ io_subchannel_ioterm(struct device *dev) } static void -io_subchannel_shutdown(struct device *dev) +io_subchannel_shutdown(struct subchannel *sch) { - struct subchannel *sch; struct ccw_device *cdev; int ret; - sch = to_subchannel(dev); - cdev = dev->driver_data; + cdev = sch->dev.driver_data; if (cio_is_console(sch->schid)) return; @@ -1129,6 +1121,14 @@ ccw_device_remove (struct device *dev) return 0; } +struct bus_type ccw_bus_type = { + .name = "ccw", + .match = ccw_bus_match, + .uevent = ccw_uevent, + .probe = ccw_device_probe, + .remove = ccw_device_remove, +}; + int ccw_driver_register (struct ccw_driver *cdriver) { @@ -1136,8 +1136,6 @@ ccw_driver_register (struct ccw_driver *cdriver) drv->bus = &ccw_bus_type; drv->name = cdriver->name; - drv->probe = ccw_device_probe; - drv->remove = ccw_device_remove; return driver_register(drv); } diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 3ded9da..0e529f8 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -221,8 +221,6 @@ static struct bus_type pseudo_lld_bus; static struct device_driver sdebug_driverfs_driver = { .name = sdebug_proc_name, .bus = &pseudo_lld_bus, - .probe = sdebug_driver_probe, - .remove = sdebug_driver_remove, }; static const int check_condition_result = @@ -1796,6 +1794,8 @@ static int pseudo_lld_bus_match(struct device *dev, static struct bus_type pseudo_lld_bus = { .name = "pseudo", .match = pseudo_lld_bus_match, + .probe = sdebug_driver_probe, + .remove = sdebug_driver_remove, }; static void sdebug_release_adapter(struct device * dev) diff --git a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c index 7bdab2a..94b2290 100644 --- a/drivers/sh/superhyway/superhyway.c +++ b/drivers/sh/superhyway/superhyway.c @@ -175,8 +175,6 @@ int superhyway_register_driver(struct superhyway_driver *drv) { drv->drv.name = drv->name; drv->drv.bus = &superhyway_bus_type; - drv->drv.probe = superhyway_device_probe; - drv->drv.remove = superhyway_device_remove; return driver_register(&drv->drv); } @@ -213,6 +211,8 @@ struct bus_type superhyway_bus_type = { #ifdef CONFIG_SYSFS .dev_attrs = superhyway_dev_attrs, #endif + .probe = superhyway_device_probe, + .remove = superhyway_device_remove, }; static int __init superhyway_bus_init(void) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 8f402f8..afc84cf 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2534,9 +2534,6 @@ static struct usb_gadget_driver eth_driver = { .driver = { .name = (char *) shortname, .owner = THIS_MODULE, - // .shutdown = ... - // .suspend = ... - // .resume = ... }, }; diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index c6c279d..9a4edc5 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1738,9 +1738,6 @@ static struct usb_gadget_driver gadgetfs_driver = { .driver = { .name = (char *) shortname, - // .shutdown = ... - // .suspend = ... - // .resume = ... }, }; diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 2e6926b..ba9acd5 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -374,9 +374,6 @@ static struct usb_gadget_driver gs_gadget_driver = { .disconnect = gs_disconnect, .driver = { .name = GS_SHORT_NAME, - /* .shutdown = ... */ - /* .suspend = ... */ - /* .resume = ... */ }, }; diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 6c58636..2fc110d 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -1303,9 +1303,6 @@ static struct usb_gadget_driver zero_driver = { .driver = { .name = (char *) shortname, .owner = THIS_MODULE, - // .shutdown = ... - // .suspend = ... - // .resume = ... }, }; diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 664139a..e9f9f4b 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -37,11 +37,6 @@ static int usb_serial_device_match (struct device *dev, struct device_driver *dr return 0; } -struct bus_type usb_serial_bus_type = { - .name = "usb-serial", - .match = usb_serial_device_match, -}; - static int usb_serial_device_probe (struct device *dev) { struct usb_serial_driver *driver; @@ -109,14 +104,18 @@ exit: return retval; } +struct bus_type usb_serial_bus_type = { + .name = "usb-serial", + .match = usb_serial_device_match, + .probe = usb_serial_device_probe, + .remove = usb_serial_device_remove, +}; + int usb_serial_bus_register(struct usb_serial_driver *driver) { int retval; driver->driver.bus = &usb_serial_bus_type; - driver->driver.probe = usb_serial_device_probe; - driver->driver.remove = usb_serial_device_remove; - retval = driver_register(&driver->driver); return retval; diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c index ccba227..fcbee74 100644 --- a/drivers/zorro/zorro-driver.c +++ b/drivers/zorro/zorro-driver.c @@ -77,7 +77,6 @@ int zorro_register_driver(struct zorro_driver *drv) /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &zorro_bus_type; - drv->driver.probe = zorro_device_probe; /* register with core */ count = driver_register(&drv->driver); @@ -132,7 +131,8 @@ static int zorro_bus_match(struct device *dev, struct device_driver *drv) struct bus_type zorro_bus_type = { .name = "zorro", - .match = zorro_bus_match + .match = zorro_bus_match, + .probe = zorro_device_probe, }; |