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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6

Trivial manual merge fixup for usb_find_interface clashes.

+878 -823
+16 -15
Documentation/powerpc/eeh-pci-error-recovery.txt
··· 115 115 At this time, a generic EEH recovery mechanism has been implemented, 116 116 so that individual device drivers do not need to be modified to support 117 117 EEH recovery. This generic mechanism piggy-backs on the PCI hotplug 118 - infrastructure, and percolates events up through the hotplug/udev 118 + infrastructure, and percolates events up through the userspace/udev 119 119 infrastructure. Followiing is a detailed description of how this is 120 120 accomplished. 121 121 ··· 172 172 drivers/pci/hotplug/pSeries_pci.c, called handle_eeh_events(). 173 173 It saves the device BAR's and then calls rpaphp_unconfig_pci_adapter(). 174 174 This last call causes the device driver for the card to be stopped, 175 - which causes hotplug events to go out to user space. This triggers 175 + which causes uevents to go out to user space. This triggers 176 176 user-space scripts that might issue commands such as "ifdown eth0" 177 177 for ethernet cards, and so on. This handler then sleeps for 5 seconds, 178 178 hoping to give the user-space scripts enough time to complete. ··· 258 258 calls 259 259 pci_destroy_dev (struct pci_dev *) { 260 260 calls 261 - device_unregister (&dev->dev) { // in /drivers/base/core.c 261 + device_unregister (&dev->dev) { // in /drivers/base/core.c 262 262 calls 263 - device_del(struct device * dev) { // in /drivers/base/core.c 263 + device_del(struct device * dev) { // in /drivers/base/core.c 264 264 calls 265 - kobject_del() { //in /libs/kobject.c 265 + kobject_del() { //in /libs/kobject.c 266 266 calls 267 - kobject_hotplug() { // in /libs/kobject.c 267 + kobject_uevent() { // in /libs/kobject.c 268 268 calls 269 - kset_hotplug() { // in /lib/kobject.c 269 + kset_uevent() { // in /lib/kobject.c 270 270 calls 271 - kset->hotplug_ops->hotplug() which is really just 271 + kset->uevent_ops->uevent() // which is really just 272 272 a call to 273 - dev_hotplug() { // in /drivers/base/core.c 273 + dev_uevent() { // in /drivers/base/core.c 274 274 calls 275 - dev->bus->hotplug() which is really just a call to 276 - pci_hotplug () { // in drivers/pci/hotplug.c 275 + dev->bus->uevent() which is really just a call to 276 + pci_uevent () { // in drivers/pci/hotplug.c 277 277 which prints device name, etc.... 278 278 } 279 279 } 280 - then kset_hotplug() calls 281 - call_usermodehelper () with 282 - argv[0]=hotplug_path[] which is "/sbin/hotplug" 283 - --> event to userspace, 280 + then kobject_uevent() sends a netlink uevent to userspace 281 + --> userspace uevent 282 + (during early boot, nobody listens to netlink events and 283 + kobject_uevent() executes uevent_helper[], which runs the 284 + event process /sbin/hotplug) 284 285 } 285 286 } 286 287 kobject_del() then calls sysfs_remove_dir(), which would
-6
MAINTAINERS
··· 1480 1480 W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/ 1481 1481 S: Maintained 1482 1482 1483 - KERNEL EVENT LAYER (KOBJECT_UEVENT) 1484 - P: Robert Love 1485 - M: rml@novell.com 1486 - L: linux-kernel@vger.kernel.org 1487 - S: Maintained 1488 - 1489 1483 KEXEC 1490 1484 P: Eric Biederman 1491 1485 P: Randy Dunlap
+3 -3
arch/arm/common/amba.c
··· 45 45 } 46 46 47 47 #ifdef CONFIG_HOTPLUG 48 - static int amba_hotplug(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) 48 + static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) 49 49 { 50 50 struct amba_device *pcdev = to_amba_device(dev); 51 51 ··· 58 58 return 0; 59 59 } 60 60 #else 61 - #define amba_hotplug NULL 61 + #define amba_uevent NULL 62 62 #endif 63 63 64 64 static int amba_suspend(struct device *dev, pm_message_t state) ··· 88 88 static struct bus_type amba_bustype = { 89 89 .name = "amba", 90 90 .match = amba_match, 91 - .hotplug = amba_hotplug, 91 + .uevent = amba_uevent, 92 92 .suspend = amba_suspend, 93 93 .resume = amba_resume, 94 94 };
+2 -2
arch/ia64/sn/kernel/tiocx.c
··· 65 65 66 66 } 67 67 68 - static int tiocx_hotplug(struct device *dev, char **envp, int num_envp, 68 + static int tiocx_uevent(struct device *dev, char **envp, int num_envp, 69 69 char *buffer, int buffer_size) 70 70 { 71 71 return -ENODEV; ··· 79 79 struct bus_type tiocx_bus_type = { 80 80 .name = "tiocx", 81 81 .match = tiocx_match, 82 - .hotplug = tiocx_hotplug, 82 + .uevent = tiocx_uevent, 83 83 }; 84 84 85 85 /**
+1 -1
arch/powerpc/kernel/vio.c
··· 293 293 294 294 struct bus_type vio_bus_type = { 295 295 .name = "vio", 296 - .hotplug = vio_hotplug, 296 + .uevent = vio_hotplug, 297 297 .match = vio_bus_match, 298 298 };
+24 -24
block/genhd.c
··· 358 358 static ssize_t disk_uevent_store(struct gendisk * disk, 359 359 const char *buf, size_t count) 360 360 { 361 - kobject_hotplug(&disk->kobj, KOBJ_ADD); 361 + kobject_uevent(&disk->kobj, KOBJ_ADD); 362 362 return count; 363 363 } 364 364 static ssize_t disk_dev_read(struct gendisk * disk, char *page) ··· 455 455 456 456 extern struct kobj_type ktype_part; 457 457 458 - static int block_hotplug_filter(struct kset *kset, struct kobject *kobj) 458 + static int block_uevent_filter(struct kset *kset, struct kobject *kobj) 459 459 { 460 460 struct kobj_type *ktype = get_ktype(kobj); 461 461 462 462 return ((ktype == &ktype_block) || (ktype == &ktype_part)); 463 463 } 464 464 465 - static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 465 + static int block_uevent(struct kset *kset, struct kobject *kobj, char **envp, 466 466 int num_envp, char *buffer, int buffer_size) 467 467 { 468 468 struct kobj_type *ktype = get_ktype(kobj); ··· 474 474 475 475 if (ktype == &ktype_block) { 476 476 disk = container_of(kobj, struct gendisk, kobj); 477 - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 478 - &length, "MINOR=%u", disk->first_minor); 477 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 478 + &length, "MINOR=%u", disk->first_minor); 479 479 } else if (ktype == &ktype_part) { 480 480 disk = container_of(kobj->parent, struct gendisk, kobj); 481 481 part = container_of(kobj, struct hd_struct, kobj); 482 - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 483 - &length, "MINOR=%u", 484 - disk->first_minor + part->partno); 482 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 483 + &length, "MINOR=%u", 484 + disk->first_minor + part->partno); 485 485 } else 486 486 return 0; 487 487 488 - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, 489 - "MAJOR=%u", disk->major); 488 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 489 + "MAJOR=%u", disk->major); 490 490 491 491 /* add physical device, backing this device */ 492 492 physdev = disk->driverfs_dev; 493 493 if (physdev) { 494 494 char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL); 495 495 496 - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 497 - &length, "PHYSDEVPATH=%s", path); 496 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 497 + &length, "PHYSDEVPATH=%s", path); 498 498 kfree(path); 499 499 500 500 if (physdev->bus) 501 - add_hotplug_env_var(envp, num_envp, &i, 502 - buffer, buffer_size, &length, 503 - "PHYSDEVBUS=%s", 504 - physdev->bus->name); 501 + add_uevent_var(envp, num_envp, &i, 502 + buffer, buffer_size, &length, 503 + "PHYSDEVBUS=%s", 504 + physdev->bus->name); 505 505 506 506 if (physdev->driver) 507 - add_hotplug_env_var(envp, num_envp, &i, 508 - buffer, buffer_size, &length, 509 - "PHYSDEVDRIVER=%s", 510 - physdev->driver->name); 507 + add_uevent_var(envp, num_envp, &i, 508 + buffer, buffer_size, &length, 509 + "PHYSDEVDRIVER=%s", 510 + physdev->driver->name); 511 511 } 512 512 513 513 /* terminate, set to next free slot, shrink available space */ ··· 520 520 return 0; 521 521 } 522 522 523 - static struct kset_hotplug_ops block_hotplug_ops = { 524 - .filter = block_hotplug_filter, 525 - .hotplug = block_hotplug, 523 + static struct kset_uevent_ops block_uevent_ops = { 524 + .filter = block_uevent_filter, 525 + .uevent = block_uevent, 526 526 }; 527 527 528 528 /* declare block_subsys. */ 529 - static decl_subsys(block, &ktype_block, &block_hotplug_ops); 529 + static decl_subsys(block, &ktype_block, &block_uevent_ops); 530 530 531 531 532 532 /*
+4 -4
drivers/acpi/container.c
··· 172 172 if (ACPI_FAILURE(status) || !device) { 173 173 result = container_device_add(&device, handle); 174 174 if (!result) 175 - kobject_hotplug(&device->kobj, 176 - KOBJ_ONLINE); 175 + kobject_uevent(&device->kobj, 176 + KOBJ_ONLINE); 177 177 else 178 178 printk("Failed to add container\n"); 179 179 } 180 180 } else { 181 181 if (ACPI_SUCCESS(status)) { 182 182 /* device exist and this is a remove request */ 183 - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 183 + kobject_uevent(&device->kobj, KOBJ_OFFLINE); 184 184 } 185 185 } 186 186 break; 187 187 case ACPI_NOTIFY_EJECT_REQUEST: 188 188 if (!acpi_bus_get_device(handle, &device) && device) { 189 - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 189 + kobject_uevent(&device->kobj, KOBJ_OFFLINE); 190 190 } 191 191 break; 192 192 default:
+4 -4
drivers/acpi/processor_core.c
··· 748 748 return_VALUE(-ENODEV); 749 749 750 750 if ((pr->id >= 0) && (pr->id < NR_CPUS)) { 751 - kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); 751 + kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); 752 752 } 753 753 return_VALUE(0); 754 754 } ··· 788 788 } 789 789 790 790 if (pr->id >= 0 && (pr->id < NR_CPUS)) { 791 - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 791 + kobject_uevent(&device->kobj, KOBJ_OFFLINE); 792 792 break; 793 793 } 794 794 795 795 result = acpi_processor_start(device); 796 796 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { 797 - kobject_hotplug(&device->kobj, KOBJ_ONLINE); 797 + kobject_uevent(&device->kobj, KOBJ_ONLINE); 798 798 } else { 799 799 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 800 800 "Device [%s] failed to start\n", ··· 818 818 } 819 819 820 820 if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) 821 - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 821 + kobject_uevent(&device->kobj, KOBJ_OFFLINE); 822 822 break; 823 823 default: 824 824 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+7 -7
drivers/acpi/scan.c
··· 78 78 .release = acpi_device_release, 79 79 }; 80 80 81 - static int namespace_hotplug(struct kset *kset, struct kobject *kobj, 81 + static int namespace_uevent(struct kset *kset, struct kobject *kobj, 82 82 char **envp, int num_envp, char *buffer, 83 83 int buffer_size) 84 84 { ··· 89 89 if (!dev->driver) 90 90 return 0; 91 91 92 - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 93 - "PHYSDEVDRIVER=%s", dev->driver->name)) 92 + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 93 + "PHYSDEVDRIVER=%s", dev->driver->name)) 94 94 return -ENOMEM; 95 95 96 96 envp[i] = NULL; ··· 98 98 return 0; 99 99 } 100 100 101 - static struct kset_hotplug_ops namespace_hotplug_ops = { 102 - .hotplug = &namespace_hotplug, 101 + static struct kset_uevent_ops namespace_uevent_ops = { 102 + .uevent = &namespace_uevent, 103 103 }; 104 104 105 105 static struct kset acpi_namespace_kset = { ··· 108 108 }, 109 109 .subsys = &acpi_subsys, 110 110 .ktype = &ktype_acpi_ns, 111 - .hotplug_ops = &namespace_hotplug_ops, 111 + .uevent_ops = &namespace_uevent_ops, 112 112 }; 113 113 114 114 static void acpi_device_register(struct acpi_device *device, ··· 347 347 } 348 348 349 349 /* -------------------------------------------------------------------------- 350 - ACPI hotplug sysfs device file support 350 + ACPI sysfs device file support 351 351 -------------------------------------------------------------------------- */ 352 352 static ssize_t acpi_eject_store(struct acpi_device *device, 353 353 const char *buf, size_t count);
+2 -2
drivers/base/Kconfig
··· 19 19 If unsure say Y here. 20 20 21 21 config FW_LOADER 22 - tristate "Hotplug firmware loading support" 22 + tristate "Userspace firmware loading support" 23 23 select HOTPLUG 24 24 ---help--- 25 25 This option is provided for the case where no in-kernel-tree modules 26 - require hotplug firmware loading support, but a module built outside 26 + require userspace firmware loading support, but a module built outside 27 27 the kernel tree does. 28 28 29 29 config DEBUG_DRIVER
+36 -5
drivers/base/bus.c
··· 152 152 153 153 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); 154 154 if (dev && dev->driver == drv) { 155 + if (dev->parent) /* Needed for USB */ 156 + down(&dev->parent->sem); 155 157 device_release_driver(dev); 158 + if (dev->parent) 159 + up(&dev->parent->sem); 156 160 err = count; 157 161 } 158 162 put_device(dev); ··· 179 175 180 176 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); 181 177 if (dev && dev->driver == NULL) { 178 + if (dev->parent) /* Needed for USB */ 179 + down(&dev->parent->sem); 182 180 down(&dev->sem); 183 181 err = driver_probe_device(drv, dev); 184 182 up(&dev->sem); 183 + if (dev->parent) 184 + up(&dev->parent->sem); 185 185 } 186 186 put_device(dev); 187 187 put_bus(bus); ··· 428 420 } 429 421 } 430 422 423 + #ifdef CONFIG_HOTPLUG 424 + /* 425 + * Thanks to drivers making their tables __devinit, we can't allow manual 426 + * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled. 427 + */ 428 + static void add_bind_files(struct device_driver *drv) 429 + { 430 + driver_create_file(drv, &driver_attr_unbind); 431 + driver_create_file(drv, &driver_attr_bind); 432 + } 433 + 434 + static void remove_bind_files(struct device_driver *drv) 435 + { 436 + driver_remove_file(drv, &driver_attr_bind); 437 + driver_remove_file(drv, &driver_attr_unbind); 438 + } 439 + #else 440 + static inline void add_bind_files(struct device_driver *drv) {} 441 + static inline void remove_bind_files(struct device_driver *drv) {} 442 + #endif 431 443 432 444 /** 433 445 * bus_add_driver - Add a driver to the bus. ··· 477 449 module_add_driver(drv->owner, drv); 478 450 479 451 driver_add_attrs(bus, drv); 480 - driver_create_file(drv, &driver_attr_unbind); 481 - driver_create_file(drv, &driver_attr_bind); 452 + add_bind_files(drv); 482 453 } 483 454 return error; 484 455 } ··· 495 468 void bus_remove_driver(struct device_driver * drv) 496 469 { 497 470 if (drv->bus) { 498 - driver_remove_file(drv, &driver_attr_bind); 499 - driver_remove_file(drv, &driver_attr_unbind); 471 + remove_bind_files(drv); 500 472 driver_remove_attrs(drv->bus, drv); 501 473 klist_remove(&drv->knode_bus); 502 474 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); ··· 510 484 /* Helper for bus_rescan_devices's iter */ 511 485 static int bus_rescan_devices_helper(struct device *dev, void *data) 512 486 { 513 - if (!dev->driver) 487 + if (!dev->driver) { 488 + if (dev->parent) /* Needed for USB */ 489 + down(&dev->parent->sem); 514 490 device_attach(dev); 491 + if (dev->parent) 492 + up(&dev->parent->sem); 493 + } 515 494 return 0; 516 495 } 517 496
+33 -33
drivers/base/class.c
··· 178 178 } 179 179 180 180 /* needed to allow these devices to have parent class devices */ 181 - static int class_device_create_hotplug(struct class_device *class_dev, 181 + static int class_device_create_uevent(struct class_device *class_dev, 182 182 char **envp, int num_envp, 183 183 char *buffer, int buffer_size) 184 184 { ··· 331 331 .release = class_dev_release, 332 332 }; 333 333 334 - static int class_hotplug_filter(struct kset *kset, struct kobject *kobj) 334 + static int class_uevent_filter(struct kset *kset, struct kobject *kobj) 335 335 { 336 336 struct kobj_type *ktype = get_ktype(kobj); 337 337 ··· 343 343 return 0; 344 344 } 345 345 346 - static const char *class_hotplug_name(struct kset *kset, struct kobject *kobj) 346 + static const char *class_uevent_name(struct kset *kset, struct kobject *kobj) 347 347 { 348 348 struct class_device *class_dev = to_class_dev(kobj); 349 349 350 350 return class_dev->class->name; 351 351 } 352 352 353 - static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 353 + static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp, 354 354 int num_envp, char *buffer, int buffer_size) 355 355 { 356 356 struct class_device *class_dev = to_class_dev(kobj); ··· 365 365 struct device *dev = class_dev->dev; 366 366 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); 367 367 368 - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 369 - &length, "PHYSDEVPATH=%s", path); 368 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 369 + &length, "PHYSDEVPATH=%s", path); 370 370 kfree(path); 371 371 372 372 if (dev->bus) 373 - add_hotplug_env_var(envp, num_envp, &i, 374 - buffer, buffer_size, &length, 375 - "PHYSDEVBUS=%s", dev->bus->name); 373 + add_uevent_var(envp, num_envp, &i, 374 + buffer, buffer_size, &length, 375 + "PHYSDEVBUS=%s", dev->bus->name); 376 376 377 377 if (dev->driver) 378 - add_hotplug_env_var(envp, num_envp, &i, 379 - buffer, buffer_size, &length, 380 - "PHYSDEVDRIVER=%s", dev->driver->name); 378 + add_uevent_var(envp, num_envp, &i, 379 + buffer, buffer_size, &length, 380 + "PHYSDEVDRIVER=%s", dev->driver->name); 381 381 } 382 382 383 383 if (MAJOR(class_dev->devt)) { 384 - add_hotplug_env_var(envp, num_envp, &i, 385 - buffer, buffer_size, &length, 386 - "MAJOR=%u", MAJOR(class_dev->devt)); 384 + add_uevent_var(envp, num_envp, &i, 385 + buffer, buffer_size, &length, 386 + "MAJOR=%u", MAJOR(class_dev->devt)); 387 387 388 - add_hotplug_env_var(envp, num_envp, &i, 389 - buffer, buffer_size, &length, 390 - "MINOR=%u", MINOR(class_dev->devt)); 388 + add_uevent_var(envp, num_envp, &i, 389 + buffer, buffer_size, &length, 390 + "MINOR=%u", MINOR(class_dev->devt)); 391 391 } 392 392 393 393 /* terminate, set to next free slot, shrink available space */ ··· 397 397 buffer = &buffer[length]; 398 398 buffer_size -= length; 399 399 400 - if (class_dev->hotplug) { 400 + if (class_dev->uevent) { 401 401 /* have the class device specific function add its stuff */ 402 - retval = class_dev->hotplug(class_dev, envp, num_envp, 402 + retval = class_dev->uevent(class_dev, envp, num_envp, 403 403 buffer, buffer_size); 404 404 if (retval) 405 - pr_debug("class_dev->hotplug() returned %d\n", retval); 406 - } else if (class_dev->class->hotplug) { 405 + pr_debug("class_dev->uevent() returned %d\n", retval); 406 + } else if (class_dev->class->uevent) { 407 407 /* have the class specific function add its stuff */ 408 - retval = class_dev->class->hotplug(class_dev, envp, num_envp, 408 + retval = class_dev->class->uevent(class_dev, envp, num_envp, 409 409 buffer, buffer_size); 410 410 if (retval) 411 - pr_debug("class->hotplug() returned %d\n", retval); 411 + pr_debug("class->uevent() returned %d\n", retval); 412 412 } 413 413 414 414 return retval; 415 415 } 416 416 417 - static struct kset_hotplug_ops class_hotplug_ops = { 418 - .filter = class_hotplug_filter, 419 - .name = class_hotplug_name, 420 - .hotplug = class_hotplug, 417 + static struct kset_uevent_ops class_uevent_ops = { 418 + .filter = class_uevent_filter, 419 + .name = class_uevent_name, 420 + .uevent = class_uevent, 421 421 }; 422 422 423 - static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops); 423 + static decl_subsys(class_obj, &ktype_class_device, &class_uevent_ops); 424 424 425 425 426 426 static int class_device_add_attrs(struct class_device * cd) ··· 464 464 static ssize_t store_uevent(struct class_device *class_dev, 465 465 const char *buf, size_t count) 466 466 { 467 - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 467 + kobject_uevent(&class_dev->kobj, KOBJ_ADD); 468 468 return count; 469 469 } 470 470 ··· 559 559 class_name); 560 560 } 561 561 562 - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 562 + kobject_uevent(&class_dev->kobj, KOBJ_ADD); 563 563 564 564 /* notify any interfaces this device is now here */ 565 565 if (parent_class) { ··· 632 632 class_dev->class = cls; 633 633 class_dev->parent = parent; 634 634 class_dev->release = class_device_create_release; 635 - class_dev->hotplug = class_device_create_hotplug; 635 + class_dev->uevent = class_device_create_uevent; 636 636 637 637 va_start(args, fmt); 638 638 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); ··· 674 674 class_device_remove_file(class_dev, class_dev->devt_attr); 675 675 class_device_remove_attrs(class_dev); 676 676 677 - kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); 677 + kobject_uevent(&class_dev->kobj, KOBJ_REMOVE); 678 678 kobject_del(&class_dev->kobj); 679 679 680 680 class_device_put(parent_device);
+21 -21
drivers/base/core.c
··· 90 90 }; 91 91 92 92 93 - static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj) 93 + static int dev_uevent_filter(struct kset *kset, struct kobject *kobj) 94 94 { 95 95 struct kobj_type *ktype = get_ktype(kobj); 96 96 ··· 102 102 return 0; 103 103 } 104 104 105 - static const char *dev_hotplug_name(struct kset *kset, struct kobject *kobj) 105 + static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) 106 106 { 107 107 struct device *dev = to_dev(kobj); 108 108 109 109 return dev->bus->name; 110 110 } 111 111 112 - static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 112 + static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp, 113 113 int num_envp, char *buffer, int buffer_size) 114 114 { 115 115 struct device *dev = to_dev(kobj); ··· 119 119 120 120 /* add bus name of physical device */ 121 121 if (dev->bus) 122 - add_hotplug_env_var(envp, num_envp, &i, 123 - buffer, buffer_size, &length, 124 - "PHYSDEVBUS=%s", dev->bus->name); 122 + add_uevent_var(envp, num_envp, &i, 123 + buffer, buffer_size, &length, 124 + "PHYSDEVBUS=%s", dev->bus->name); 125 125 126 126 /* add driver name of physical device */ 127 127 if (dev->driver) 128 - add_hotplug_env_var(envp, num_envp, &i, 129 - buffer, buffer_size, &length, 130 - "PHYSDEVDRIVER=%s", dev->driver->name); 128 + add_uevent_var(envp, num_envp, &i, 129 + buffer, buffer_size, &length, 130 + "PHYSDEVDRIVER=%s", dev->driver->name); 131 131 132 132 /* terminate, set to next free slot, shrink available space */ 133 133 envp[i] = NULL; ··· 136 136 buffer = &buffer[length]; 137 137 buffer_size -= length; 138 138 139 - if (dev->bus && dev->bus->hotplug) { 139 + if (dev->bus && dev->bus->uevent) { 140 140 /* have the bus specific function add its stuff */ 141 - retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); 141 + retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size); 142 142 if (retval) { 143 - pr_debug ("%s - hotplug() returned %d\n", 143 + pr_debug ("%s - uevent() returned %d\n", 144 144 __FUNCTION__, retval); 145 145 } 146 146 } ··· 148 148 return retval; 149 149 } 150 150 151 - static struct kset_hotplug_ops device_hotplug_ops = { 152 - .filter = dev_hotplug_filter, 153 - .name = dev_hotplug_name, 154 - .hotplug = dev_hotplug, 151 + static struct kset_uevent_ops device_uevent_ops = { 152 + .filter = dev_uevent_filter, 153 + .name = dev_uevent_name, 154 + .uevent = dev_uevent, 155 155 }; 156 156 157 157 static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, 158 158 const char *buf, size_t count) 159 159 { 160 - kobject_hotplug(&dev->kobj, KOBJ_ADD); 160 + kobject_uevent(&dev->kobj, KOBJ_ADD); 161 161 return count; 162 162 } 163 163 ··· 165 165 * device_subsys - structure to be registered with kobject core. 166 166 */ 167 167 168 - decl_subsys(devices, &ktype_device, &device_hotplug_ops); 168 + decl_subsys(devices, &ktype_device, &device_uevent_ops); 169 169 170 170 171 171 /** ··· 274 274 dev->uevent_attr.store = store_uevent; 275 275 device_create_file(dev, &dev->uevent_attr); 276 276 277 - kobject_hotplug(&dev->kobj, KOBJ_ADD); 277 + kobject_uevent(&dev->kobj, KOBJ_ADD); 278 278 if ((error = device_pm_add(dev))) 279 279 goto PMError; 280 280 if ((error = bus_add_device(dev))) ··· 291 291 BusError: 292 292 device_pm_remove(dev); 293 293 PMError: 294 - kobject_hotplug(&dev->kobj, KOBJ_REMOVE); 294 + kobject_uevent(&dev->kobj, KOBJ_REMOVE); 295 295 kobject_del(&dev->kobj); 296 296 Error: 297 297 if (parent) ··· 374 374 platform_notify_remove(dev); 375 375 bus_remove_device(dev); 376 376 device_pm_remove(dev); 377 - kobject_hotplug(&dev->kobj, KOBJ_REMOVE); 377 + kobject_uevent(&dev->kobj, KOBJ_REMOVE); 378 378 kobject_del(&dev->kobj); 379 379 if (parent) 380 380 put_device(parent);
+2 -2
drivers/base/cpu.c
··· 41 41 case '0': 42 42 ret = cpu_down(cpu->sysdev.id); 43 43 if (!ret) 44 - kobject_hotplug(&dev->kobj, KOBJ_OFFLINE); 44 + kobject_uevent(&dev->kobj, KOBJ_OFFLINE); 45 45 break; 46 46 case '1': 47 47 ret = smp_prepare_cpu(cpu->sysdev.id); 48 48 if (!ret) 49 49 ret = cpu_up(cpu->sysdev.id); 50 50 if (!ret) 51 - kobject_hotplug(&dev->kobj, KOBJ_ONLINE); 51 + kobject_uevent(&dev->kobj, KOBJ_ONLINE); 52 52 break; 53 53 default: 54 54 ret = -EINVAL;
+14 -1
drivers/base/dd.c
··· 65 65 * This function returns 1 if a match is found, an error if one 66 66 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise. 67 67 * 68 - * This function must be called with @dev->sem held. 68 + * This function must be called with @dev->sem held. When called 69 + * for a USB interface, @dev->parent->sem must be held as well. 69 70 */ 70 71 int driver_probe_device(struct device_driver * drv, struct device * dev) 71 72 { ··· 124 123 * 125 124 * Returns 1 if the device was bound to a driver; 126 125 * 0 if no matching device was found; error code otherwise. 126 + * 127 + * When called for a USB interface, @dev->parent->sem must be held. 127 128 */ 128 129 int device_attach(struct device * dev) 129 130 { ··· 155 152 * is an error. 156 153 */ 157 154 155 + if (dev->parent) /* Needed for USB */ 156 + down(&dev->parent->sem); 158 157 down(&dev->sem); 159 158 if (!dev->driver) 160 159 driver_probe_device(drv, dev); 161 160 up(&dev->sem); 161 + if (dev->parent) 162 + up(&dev->parent->sem); 162 163 163 164 return 0; 164 165 } ··· 188 181 * Manually detach device from driver. 189 182 * 190 183 * __device_release_driver() must be called with @dev->sem held. 184 + * When called for a USB interface, @dev->parent->sem must be held 185 + * as well. 191 186 */ 192 187 193 188 static void __device_release_driver(struct device * dev) ··· 242 233 get_device(dev); 243 234 spin_unlock(&drv->klist_devices.k_lock); 244 235 236 + if (dev->parent) /* Needed for USB */ 237 + down(&dev->parent->sem); 245 238 down(&dev->sem); 246 239 if (dev->driver == drv) 247 240 __device_release_driver(dev); 248 241 up(&dev->sem); 242 + if (dev->parent) 243 + up(&dev->parent->sem); 249 244 put_device(dev); 250 245 } 251 246 }
+22 -23
drivers/base/firmware_class.c
··· 85 85 static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 86 86 87 87 static void fw_class_dev_release(struct class_device *class_dev); 88 - int firmware_class_hotplug(struct class_device *dev, char **envp, 88 + int firmware_class_uevent(struct class_device *dev, char **envp, 89 89 int num_envp, char *buffer, int buffer_size); 90 90 91 91 static struct class firmware_class = { 92 92 .name = "firmware", 93 - .hotplug = firmware_class_hotplug, 93 + .uevent = firmware_class_uevent, 94 94 .release = fw_class_dev_release, 95 95 }; 96 96 97 97 int 98 - firmware_class_hotplug(struct class_device *class_dev, char **envp, 98 + firmware_class_uevent(struct class_device *class_dev, char **envp, 99 99 int num_envp, char *buffer, int buffer_size) 100 100 { 101 101 struct firmware_priv *fw_priv = class_get_devdata(class_dev); ··· 104 104 if (!test_bit(FW_STATUS_READY, &fw_priv->status)) 105 105 return -ENODEV; 106 106 107 - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 108 - "FIRMWARE=%s", fw_priv->fw_id)) 107 + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 108 + "FIRMWARE=%s", fw_priv->fw_id)) 109 109 return -ENOMEM; 110 - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 111 - "TIMEOUT=%i", loading_timeout)) 110 + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 111 + "TIMEOUT=%i", loading_timeout)) 112 112 return -ENOMEM; 113 - 114 113 envp[i] = NULL; 115 114 116 115 return 0; ··· 351 352 352 353 static int 353 354 fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, 354 - const char *fw_name, struct device *device, int hotplug) 355 + const char *fw_name, struct device *device, int uevent) 355 356 { 356 357 struct class_device *class_dev; 357 358 struct firmware_priv *fw_priv; ··· 383 384 goto error_unreg; 384 385 } 385 386 386 - if (hotplug) 387 + if (uevent) 387 388 set_bit(FW_STATUS_READY, &fw_priv->status); 388 389 else 389 390 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status); ··· 398 399 399 400 static int 400 401 _request_firmware(const struct firmware **firmware_p, const char *name, 401 - struct device *device, int hotplug) 402 + struct device *device, int uevent) 402 403 { 403 404 struct class_device *class_dev; 404 405 struct firmware_priv *fw_priv; ··· 417 418 } 418 419 419 420 retval = fw_setup_class_device(firmware, &class_dev, name, device, 420 - hotplug); 421 + uevent); 421 422 if (retval) 422 423 goto error_kfree_fw; 423 424 424 425 fw_priv = class_get_devdata(class_dev); 425 426 426 - if (hotplug) { 427 + if (uevent) { 427 428 if (loading_timeout > 0) { 428 429 fw_priv->timeout.expires = jiffies + loading_timeout * HZ; 429 430 add_timer(&fw_priv->timeout); 430 431 } 431 432 432 - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 433 + kobject_uevent(&class_dev->kobj, KOBJ_ADD); 433 434 wait_for_completion(&fw_priv->completion); 434 435 set_bit(FW_STATUS_DONE, &fw_priv->status); 435 436 del_timer_sync(&fw_priv->timeout); ··· 455 456 } 456 457 457 458 /** 458 - * request_firmware: - request firmware to hotplug and wait for it 459 + * request_firmware: - send firmware request and wait for it 459 460 * @firmware_p: pointer to firmware image 460 461 * @name: name of firmware file 461 462 * @device: device for which firmware is being loaded ··· 465 466 * 466 467 * Should be called from user context where sleeping is allowed. 467 468 * 468 - * @name will be used as $FIRMWARE in the hotplug environment and 469 + * @name will be used as $FIRMWARE in the uevent environment and 469 470 * should be distinctive enough not to be confused with any other 470 471 * firmware image for this or any other device. 471 472 **/ ··· 473 474 request_firmware(const struct firmware **firmware_p, const char *name, 474 475 struct device *device) 475 476 { 476 - int hotplug = 1; 477 - return _request_firmware(firmware_p, name, device, hotplug); 477 + int uevent = 1; 478 + return _request_firmware(firmware_p, name, device, uevent); 478 479 } 479 480 480 481 /** ··· 517 518 struct device *device; 518 519 void *context; 519 520 void (*cont)(const struct firmware *fw, void *context); 520 - int hotplug; 521 + int uevent; 521 522 }; 522 523 523 524 static int ··· 532 533 } 533 534 daemonize("%s/%s", "firmware", fw_work->name); 534 535 ret = _request_firmware(&fw, fw_work->name, fw_work->device, 535 - fw_work->hotplug); 536 + fw_work->uevent); 536 537 if (ret < 0) 537 538 fw_work->cont(NULL, fw_work->context); 538 539 else { ··· 547 548 /** 548 549 * request_firmware_nowait: asynchronous version of request_firmware 549 550 * @module: module requesting the firmware 550 - * @hotplug: invokes hotplug event to copy the firmware image if this flag 551 + * @uevent: sends uevent to copy the firmware image if this flag 551 552 * is non-zero else the firmware copy must be done manually. 552 553 * @name: name of firmware file 553 554 * @device: device for which firmware is being loaded ··· 561 562 **/ 562 563 int 563 564 request_firmware_nowait( 564 - struct module *module, int hotplug, 565 + struct module *module, int uevent, 565 566 const char *name, struct device *device, void *context, 566 567 void (*cont)(const struct firmware *fw, void *context)) 567 568 { ··· 582 583 .device = device, 583 584 .context = context, 584 585 .cont = cont, 585 - .hotplug = hotplug, 586 + .uevent = uevent, 586 587 }; 587 588 588 589 ret = kernel_thread(request_firmware_work_func, fw_work,
+6 -6
drivers/base/memory.c
··· 29 29 set_kset_name(MEMORY_CLASS_NAME), 30 30 }; 31 31 32 - static char *memory_hotplug_name(struct kset *kset, struct kobject *kobj) 32 + static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) 33 33 { 34 34 return MEMORY_CLASS_NAME; 35 35 } 36 36 37 - static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 37 + static int memory_uevent(struct kset *kset, struct kobject *kobj, char **envp, 38 38 int num_envp, char *buffer, int buffer_size) 39 39 { 40 40 int retval = 0; ··· 42 42 return retval; 43 43 } 44 44 45 - static struct kset_hotplug_ops memory_hotplug_ops = { 46 - .name = memory_hotplug_name, 47 - .hotplug = memory_hotplug, 45 + static struct kset_uevent_ops memory_uevent_ops = { 46 + .name = memory_uevent_name, 47 + .uevent = memory_uevent, 48 48 }; 49 49 50 50 static struct notifier_block *memory_chain; ··· 431 431 unsigned int i; 432 432 int ret; 433 433 434 - memory_sysdev_class.kset.hotplug_ops = &memory_hotplug_ops; 434 + memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; 435 435 ret = sysdev_class_register(&memory_sysdev_class); 436 436 437 437 /*
+41 -27
drivers/base/platform.c
··· 25 25 struct device platform_bus = { 26 26 .bus_id = "platform", 27 27 }; 28 + EXPORT_SYMBOL_GPL(platform_bus); 28 29 29 30 /** 30 31 * platform_get_resource - get a resource for a device ··· 50 49 } 51 50 return NULL; 52 51 } 52 + EXPORT_SYMBOL_GPL(platform_get_resource); 53 53 54 54 /** 55 55 * platform_get_irq - get an IRQ for a device ··· 63 61 64 62 return r ? r->start : 0; 65 63 } 64 + EXPORT_SYMBOL_GPL(platform_get_irq); 66 65 67 66 /** 68 67 * platform_get_resource_byname - get a resource for a device by name ··· 87 84 } 88 85 return NULL; 89 86 } 87 + EXPORT_SYMBOL_GPL(platform_get_resource_byname); 90 88 91 89 /** 92 90 * platform_get_irq - get an IRQ for a device ··· 100 96 101 97 return r ? r->start : 0; 102 98 } 99 + EXPORT_SYMBOL_GPL(platform_get_irq_byname); 103 100 104 101 /** 105 102 * platform_add_devices - add a numbers of platform devices ··· 122 117 123 118 return ret; 124 119 } 120 + EXPORT_SYMBOL_GPL(platform_add_devices); 125 121 126 122 struct platform_object { 127 123 struct platform_device pdev; ··· 174 168 pa->pdev.dev.release = platform_device_release; 175 169 } 176 170 177 - return pa ? &pa->pdev : NULL; 171 + return pa ? &pa->pdev : NULL; 178 172 } 179 173 EXPORT_SYMBOL_GPL(platform_device_alloc); 180 174 ··· 263 257 p = &ioport_resource; 264 258 } 265 259 266 - if (p && request_resource(p, r)) { 260 + if (p && insert_resource(p, r)) { 267 261 printk(KERN_ERR 268 262 "%s: failed to claim resource %d\n", 269 263 pdev->dev.bus_id, i); ··· 288 282 EXPORT_SYMBOL_GPL(platform_device_add); 289 283 290 284 /** 291 - * platform_device_register - add a platform-level device 292 - * @pdev: platform device we're adding 293 - * 294 - */ 295 - int platform_device_register(struct platform_device * pdev) 296 - { 297 - device_initialize(&pdev->dev); 298 - return platform_device_add(pdev); 299 - } 300 - 301 - /** 302 - * platform_device_unregister - remove a platform-level device 285 + * platform_device_del - remove a platform-level device 303 286 * @pdev: platform device we're removing 304 287 * 305 288 * Note that this function will also release all memory- and port-based 306 289 * resources owned by the device (@dev->resource). 307 290 */ 308 - void platform_device_unregister(struct platform_device * pdev) 291 + void platform_device_del(struct platform_device *pdev) 309 292 { 310 293 int i; 311 294 ··· 305 310 release_resource(r); 306 311 } 307 312 308 - device_unregister(&pdev->dev); 313 + device_del(&pdev->dev); 309 314 } 310 315 } 316 + EXPORT_SYMBOL_GPL(platform_device_del); 317 + 318 + /** 319 + * platform_device_register - add a platform-level device 320 + * @pdev: platform device we're adding 321 + * 322 + */ 323 + int platform_device_register(struct platform_device * pdev) 324 + { 325 + device_initialize(&pdev->dev); 326 + return platform_device_add(pdev); 327 + } 328 + EXPORT_SYMBOL_GPL(platform_device_register); 329 + 330 + /** 331 + * platform_device_unregister - unregister a platform-level device 332 + * @pdev: platform device we're unregistering 333 + * 334 + * Unregistration is done in 2 steps. Fisrt we release all resources 335 + * and remove it from the sybsystem, then we drop reference count by 336 + * calling platform_device_put(). 337 + */ 338 + void platform_device_unregister(struct platform_device * pdev) 339 + { 340 + platform_device_del(pdev); 341 + platform_device_put(pdev); 342 + } 343 + EXPORT_SYMBOL_GPL(platform_device_unregister); 311 344 312 345 /** 313 346 * platform_device_register_simple ··· 378 355 platform_device_put(pdev); 379 356 return ERR_PTR(retval); 380 357 } 358 + EXPORT_SYMBOL_GPL(platform_device_register_simple); 381 359 382 360 static int platform_drv_probe(struct device *_dev) 383 361 { ··· 500 476 .suspend = platform_suspend, 501 477 .resume = platform_resume, 502 478 }; 479 + EXPORT_SYMBOL_GPL(platform_bus_type); 503 480 504 481 int __init platform_bus_init(void) 505 482 { ··· 529 504 } 530 505 EXPORT_SYMBOL_GPL(dma_get_required_mask); 531 506 #endif 532 - 533 - EXPORT_SYMBOL_GPL(platform_bus); 534 - EXPORT_SYMBOL_GPL(platform_bus_type); 535 - EXPORT_SYMBOL_GPL(platform_add_devices); 536 - EXPORT_SYMBOL_GPL(platform_device_register); 537 - EXPORT_SYMBOL_GPL(platform_device_register_simple); 538 - EXPORT_SYMBOL_GPL(platform_device_unregister); 539 - EXPORT_SYMBOL_GPL(platform_get_irq); 540 - EXPORT_SYMBOL_GPL(platform_get_resource); 541 - EXPORT_SYMBOL_GPL(platform_get_irq_byname); 542 - EXPORT_SYMBOL_GPL(platform_get_resource_byname);
+2
drivers/base/power/runtime.c
··· 64 64 } 65 65 66 66 67 + #if 0 67 68 /** 68 69 * dpm_set_power_state - Update power_state field. 69 70 * @dev: Device. ··· 81 80 dev->power.power_state = state; 82 81 up(&dpm_sem); 83 82 } 83 + #endif /* 0 */
+1
drivers/ide/ide-cd.c
··· 3509 3509 return driver_register(&ide_cdrom_driver.gen_driver); 3510 3510 } 3511 3511 3512 + MODULE_ALIAS("ide:*m-cdrom*"); 3512 3513 module_init(ide_cdrom_init); 3513 3514 module_exit(ide_cdrom_exit); 3514 3515 MODULE_LICENSE("GPL");
+1
drivers/ide/ide-disk.c
··· 1271 1271 return driver_register(&idedisk_driver.gen_driver); 1272 1272 } 1273 1273 1274 + MODULE_ALIAS("ide:*m-disk*"); 1274 1275 module_init(idedisk_init); 1275 1276 module_exit(idedisk_exit); 1276 1277 MODULE_LICENSE("GPL");
+1
drivers/ide/ide-floppy.c
··· 2197 2197 return driver_register(&idefloppy_driver.gen_driver); 2198 2198 } 2199 2199 2200 + MODULE_ALIAS("ide:*m-floppy*"); 2200 2201 module_init(idefloppy_init); 2201 2202 module_exit(idefloppy_exit); 2202 2203 MODULE_LICENSE("GPL");
+1
drivers/ide/ide-tape.c
··· 4947 4947 return error; 4948 4948 } 4949 4949 4950 + MODULE_ALIAS("ide:*m-tape*"); 4950 4951 module_init(idetape_init); 4951 4952 module_exit(idetape_exit); 4952 4953 MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR);
+60
drivers/ide/ide.c
··· 1904 1904 return 1; 1905 1905 } 1906 1906 1907 + static char *media_string(ide_drive_t *drive) 1908 + { 1909 + switch (drive->media) { 1910 + case ide_disk: 1911 + return "disk"; 1912 + case ide_cdrom: 1913 + return "cdrom"; 1914 + case ide_tape: 1915 + return "tape"; 1916 + case ide_floppy: 1917 + return "floppy"; 1918 + default: 1919 + return "UNKNOWN"; 1920 + } 1921 + } 1922 + 1923 + static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf) 1924 + { 1925 + ide_drive_t *drive = to_ide_device(dev); 1926 + return sprintf(buf, "%s\n", media_string(drive)); 1927 + } 1928 + 1929 + static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf) 1930 + { 1931 + ide_drive_t *drive = to_ide_device(dev); 1932 + return sprintf(buf, "%s\n", drive->name); 1933 + } 1934 + 1935 + static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) 1936 + { 1937 + ide_drive_t *drive = to_ide_device(dev); 1938 + return sprintf(buf, "ide:m-%s\n", media_string(drive)); 1939 + } 1940 + 1941 + static struct device_attribute ide_dev_attrs[] = { 1942 + __ATTR_RO(media), 1943 + __ATTR_RO(drivename), 1944 + __ATTR_RO(modalias), 1945 + __ATTR_NULL 1946 + }; 1947 + 1948 + static int ide_uevent(struct device *dev, char **envp, int num_envp, 1949 + char *buffer, int buffer_size) 1950 + { 1951 + ide_drive_t *drive = to_ide_device(dev); 1952 + int i = 0; 1953 + int length = 0; 1954 + 1955 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 1956 + "MEDIA=%s", media_string(drive)); 1957 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 1958 + "DRIVENAME=%s", drive->name); 1959 + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 1960 + "MODALIAS=ide:m-%s", media_string(drive)); 1961 + envp[i] = NULL; 1962 + return 0; 1963 + } 1964 + 1907 1965 struct bus_type ide_bus_type = { 1908 1966 .name = "ide", 1909 1967 .match = ide_bus_match, 1968 + .uevent = ide_uevent, 1969 + .dev_attrs = ide_dev_attrs, 1910 1970 .suspend = generic_ide_suspend, 1911 1971 .resume = generic_ide_resume, 1912 1972 };
+10 -10
drivers/ieee1394/nodemgr.c
··· 121 121 }; 122 122 123 123 static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 124 - static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 125 - char *buffer, int buffer_size); 124 + static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 125 + char *buffer, int buffer_size); 126 126 static void nodemgr_resume_ne(struct node_entry *ne); 127 127 static void nodemgr_remove_ne(struct node_entry *ne); 128 128 static struct node_entry *find_entry_by_guid(u64 guid); ··· 162 162 static struct class nodemgr_ud_class = { 163 163 .name = "ieee1394", 164 164 .release = ud_cls_release, 165 - .hotplug = nodemgr_hotplug, 165 + .uevent = nodemgr_uevent, 166 166 }; 167 167 168 168 static struct hpsb_highlevel nodemgr_highlevel; ··· 966 966 if (ud_child == NULL) 967 967 break; 968 968 969 - /* inherit unspecified values so hotplug picks it up */ 969 + /* inherit unspecified values, the driver core picks it up */ 970 970 if ((ud->flags & UNIT_DIRECTORY_MODEL_ID) && 971 971 !(ud_child->flags & UNIT_DIRECTORY_MODEL_ID)) 972 972 { ··· 1062 1062 1063 1063 #ifdef CONFIG_HOTPLUG 1064 1064 1065 - static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 1066 - char *buffer, int buffer_size) 1065 + static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1066 + char *buffer, int buffer_size) 1067 1067 { 1068 1068 struct unit_directory *ud; 1069 1069 int i = 0; ··· 1112 1112 1113 1113 #else 1114 1114 1115 - static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 1116 - char *buffer, int buffer_size) 1115 + static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1116 + char *buffer, int buffer_size) 1117 1117 { 1118 1118 return -ENODEV; 1119 1119 } ··· 1618 1618 1619 1619 /* Scan our nodes to get the bus options and create node 1620 1620 * entries. This does not do the sysfs stuff, since that 1621 - * would trigger hotplug callbacks and such, which is a 1622 - * bad idea at this point. */ 1621 + * would trigger uevents and such, which is a bad idea at 1622 + * this point. */ 1623 1623 nodemgr_node_scan(hi, generation); 1624 1624 1625 1625 /* This actually does the full probe, with sysfs
+8 -8
drivers/infiniband/core/sysfs.c
··· 434 434 kfree(dev); 435 435 } 436 436 437 - static int ib_device_hotplug(struct class_device *cdev, char **envp, 438 - int num_envp, char *buf, int size) 437 + static int ib_device_uevent(struct class_device *cdev, char **envp, 438 + int num_envp, char *buf, int size) 439 439 { 440 440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 441 441 int i = 0, len = 0; 442 442 443 - if (add_hotplug_env_var(envp, num_envp, &i, buf, size, &len, 444 - "NAME=%s", dev->name)) 443 + if (add_uevent_var(envp, num_envp, &i, buf, size, &len, 444 + "NAME=%s", dev->name)) 445 445 return -ENOMEM; 446 446 447 447 /* 448 - * It might be nice to pass the node GUID to hotplug, but 448 + * It might be nice to pass the node GUID with the event, but 449 449 * right now the only way to get it is to query the device 450 450 * provider, and this can crash during device removal because 451 451 * we are will be running after driver removal has started. 452 452 * We could add a node_guid field to struct ib_device, or we 453 - * could just let the hotplug script read the node GUID from 454 - * sysfs when devices are added. 453 + * could just let userspace read the node GUID from sysfs when 454 + * devices are added. 455 455 */ 456 456 457 457 envp[i] = NULL; ··· 653 653 static struct class ib_class = { 654 654 .name = "infiniband", 655 655 .release = ib_device_release, 656 - .hotplug = ib_device_hotplug, 656 + .uevent = ib_device_uevent, 657 657 }; 658 658 659 659 int ib_device_register_sysfs(struct ib_device *device)
+46 -8
drivers/input/input.c
··· 18 18 #include <linux/random.h> 19 19 #include <linux/major.h> 20 20 #include <linux/proc_fs.h> 21 - #include <linux/kobject_uevent.h> 22 21 #include <linux/interrupt.h> 23 22 #include <linux/poll.h> 24 23 #include <linux/device.h> ··· 528 529 INPUT_DEV_STRING_ATTR_SHOW(phys); 529 530 INPUT_DEV_STRING_ATTR_SHOW(uniq); 530 531 532 + static int print_modalias_bits(char *buf, char prefix, unsigned long *arr, 533 + unsigned int min, unsigned int max) 534 + { 535 + int len, i; 536 + 537 + len = sprintf(buf, "%c", prefix); 538 + for (i = min; i < max; i++) 539 + if (arr[LONG(i)] & BIT(i)) 540 + len += sprintf(buf+len, "%X,", i); 541 + return len; 542 + } 543 + 544 + static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf) 545 + { 546 + struct input_dev *id = to_input_dev(dev); 547 + ssize_t len = 0; 548 + 549 + len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-", 550 + id->id.bustype, 551 + id->id.vendor, 552 + id->id.product, 553 + id->id.version); 554 + 555 + len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX); 556 + len += print_modalias_bits(buf+len, 'k', id->keybit, 557 + KEY_MIN_INTERESTING, KEY_MAX); 558 + len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX); 559 + len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX); 560 + len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX); 561 + len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX); 562 + len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX); 563 + len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX); 564 + len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX); 565 + len += sprintf(buf+len, "\n"); 566 + return len; 567 + } 568 + static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 569 + 531 570 static struct attribute *input_dev_attrs[] = { 532 571 &class_device_attr_name.attr, 533 572 &class_device_attr_phys.attr, 534 573 &class_device_attr_uniq.attr, 574 + &class_device_attr_modalias.attr, 535 575 NULL 536 576 }; 537 577 ··· 649 611 } 650 612 651 613 /* 652 - * Input hotplugging interface - loading event handlers based on 614 + * Input uevent interface - loading event handlers based on 653 615 * device bitfields. 654 616 */ 655 - static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, 617 + static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index, 656 618 char *buffer, int buffer_size, int *cur_len, 657 619 const char *name, unsigned long *bitmap, int max) 658 620 { ··· 677 639 678 640 #define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ 679 641 do { \ 680 - int err = add_hotplug_env_var(envp, num_envp, &i, \ 642 + int err = add_uevent_var(envp, num_envp, &i, \ 681 643 buffer, buffer_size, &len, \ 682 644 fmt, val); \ 683 645 if (err) \ ··· 686 648 687 649 #define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ 688 650 do { \ 689 - int err = input_add_hotplug_bm_var(envp, num_envp, &i, \ 651 + int err = input_add_uevent_bm_var(envp, num_envp, &i, \ 690 652 buffer, buffer_size, &len, \ 691 653 name, bm, max); \ 692 654 if (err) \ 693 655 return err; \ 694 656 } while (0) 695 657 696 - static int input_dev_hotplug(struct class_device *cdev, char **envp, 697 - int num_envp, char *buffer, int buffer_size) 658 + static int input_dev_uevent(struct class_device *cdev, char **envp, 659 + int num_envp, char *buffer, int buffer_size) 698 660 { 699 661 struct input_dev *dev = to_input_dev(cdev); 700 662 int i = 0; ··· 736 698 struct class input_class = { 737 699 .name = "input", 738 700 .release = input_dev_release, 739 - .hotplug = input_dev_hotplug, 701 + .uevent = input_dev_uevent, 740 702 }; 741 703 742 704 struct input_dev *input_allocate_device(void)
+11 -11
drivers/input/serio/serio.c
··· 800 800 801 801 #ifdef CONFIG_HOTPLUG 802 802 803 - #define SERIO_ADD_HOTPLUG_VAR(fmt, val...) \ 803 + #define SERIO_ADD_UEVENT_VAR(fmt, val...) \ 804 804 do { \ 805 - int err = add_hotplug_env_var(envp, num_envp, &i, \ 805 + int err = add_uevent_var(envp, num_envp, &i, \ 806 806 buffer, buffer_size, &len, \ 807 807 fmt, val); \ 808 808 if (err) \ 809 809 return err; \ 810 810 } while (0) 811 811 812 - static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 812 + static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 813 813 { 814 814 struct serio *serio; 815 815 int i = 0; ··· 820 820 821 821 serio = to_serio_port(dev); 822 822 823 - SERIO_ADD_HOTPLUG_VAR("SERIO_TYPE=%02x", serio->id.type); 824 - SERIO_ADD_HOTPLUG_VAR("SERIO_PROTO=%02x", serio->id.proto); 825 - SERIO_ADD_HOTPLUG_VAR("SERIO_ID=%02x", serio->id.id); 826 - SERIO_ADD_HOTPLUG_VAR("SERIO_EXTRA=%02x", serio->id.extra); 827 - SERIO_ADD_HOTPLUG_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", 823 + SERIO_ADD_UEVENT_VAR("SERIO_TYPE=%02x", serio->id.type); 824 + SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto); 825 + SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id); 826 + SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); 827 + SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", 828 828 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); 829 829 envp[i] = NULL; 830 830 831 831 return 0; 832 832 } 833 - #undef SERIO_ADD_HOTPLUG_VAR 833 + #undef SERIO_ADD_UEVENT_VAR 834 834 835 835 #else 836 836 837 - static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 837 + static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 838 838 { 839 839 return -ENODEV; 840 840 } ··· 908 908 serio_bus.dev_attrs = serio_device_attrs; 909 909 serio_bus.drv_attrs = serio_driver_attrs; 910 910 serio_bus.match = serio_bus_match; 911 - serio_bus.hotplug = serio_hotplug; 911 + serio_bus.uevent = serio_uevent; 912 912 serio_bus.resume = serio_resume; 913 913 bus_register(&serio_bus); 914 914
+2 -2
drivers/macintosh/macio_asic.c
··· 128 128 return 0; 129 129 } 130 130 131 - static int macio_hotplug (struct device *dev, char **envp, int num_envp, 131 + static int macio_uevent(struct device *dev, char **envp, int num_envp, 132 132 char *buffer, int buffer_size) 133 133 { 134 134 struct macio_dev * macio_dev; ··· 203 203 struct bus_type macio_bus_type = { 204 204 .name = "macio", 205 205 .match = macio_bus_match, 206 - .hotplug = macio_hotplug, 206 + .uevent = macio_uevent, 207 207 .suspend = macio_device_suspend, 208 208 .resume = macio_device_resume, 209 209 .dev_attrs = macio_dev_attrs,
+2 -2
drivers/mmc/mmc_sysfs.c
··· 80 80 } 81 81 82 82 static int 83 - mmc_bus_hotplug(struct device *dev, char **envp, int num_envp, char *buf, 83 + mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf, 84 84 int buf_size) 85 85 { 86 86 struct mmc_card *card = dev_to_mmc_card(dev); ··· 140 140 .name = "mmc", 141 141 .dev_attrs = mmc_dev_attrs, 142 142 .match = mmc_bus_match, 143 - .hotplug = mmc_bus_hotplug, 143 + .uevent = mmc_bus_uevent, 144 144 .suspend = mmc_bus_suspend, 145 145 .resume = mmc_bus_resume, 146 146 };
+22 -22
drivers/pci/hotplug.c
··· 3 3 #include <linux/module.h> 4 4 #include "pci.h" 5 5 6 - int pci_hotplug (struct device *dev, char **envp, int num_envp, 7 - char *buffer, int buffer_size) 6 + int pci_uevent(struct device *dev, char **envp, int num_envp, 7 + char *buffer, int buffer_size) 8 8 { 9 9 struct pci_dev *pdev; 10 10 int i = 0; ··· 17 17 if (!pdev) 18 18 return -ENODEV; 19 19 20 - if (add_hotplug_env_var(envp, num_envp, &i, 21 - buffer, buffer_size, &length, 22 - "PCI_CLASS=%04X", pdev->class)) 20 + if (add_uevent_var(envp, num_envp, &i, 21 + buffer, buffer_size, &length, 22 + "PCI_CLASS=%04X", pdev->class)) 23 23 return -ENOMEM; 24 24 25 - if (add_hotplug_env_var(envp, num_envp, &i, 26 - buffer, buffer_size, &length, 27 - "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) 25 + if (add_uevent_var(envp, num_envp, &i, 26 + buffer, buffer_size, &length, 27 + "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) 28 28 return -ENOMEM; 29 29 30 - if (add_hotplug_env_var(envp, num_envp, &i, 31 - buffer, buffer_size, &length, 32 - "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, 33 - pdev->subsystem_device)) 30 + if (add_uevent_var(envp, num_envp, &i, 31 + buffer, buffer_size, &length, 32 + "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, 33 + pdev->subsystem_device)) 34 34 return -ENOMEM; 35 35 36 - if (add_hotplug_env_var(envp, num_envp, &i, 37 - buffer, buffer_size, &length, 38 - "PCI_SLOT_NAME=%s", pci_name(pdev))) 36 + if (add_uevent_var(envp, num_envp, &i, 37 + buffer, buffer_size, &length, 38 + "PCI_SLOT_NAME=%s", pci_name(pdev))) 39 39 return -ENOMEM; 40 40 41 - if (add_hotplug_env_var(envp, num_envp, &i, 42 - buffer, buffer_size, &length, 43 - "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", 44 - pdev->vendor, pdev->device, 45 - pdev->subsystem_vendor, pdev->subsystem_device, 46 - (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 47 - (u8)(pdev->class))) 41 + if (add_uevent_var(envp, num_envp, &i, 42 + buffer, buffer_size, &length, 43 + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", 44 + pdev->vendor, pdev->device, 45 + pdev->subsystem_vendor, pdev->subsystem_device, 46 + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 47 + (u8)(pdev->class))) 48 48 return -ENOMEM; 49 49 50 50 envp[i] = NULL;
+3 -3
drivers/pci/pci-driver.c
··· 502 502 } 503 503 504 504 #ifndef CONFIG_HOTPLUG 505 - int pci_hotplug (struct device *dev, char **envp, int num_envp, 506 - char *buffer, int buffer_size) 505 + int pci_uevent(struct device *dev, char **envp, int num_envp, 506 + char *buffer, int buffer_size) 507 507 { 508 508 return -ENODEV; 509 509 } ··· 512 512 struct bus_type pci_bus_type = { 513 513 .name = "pci", 514 514 .match = pci_bus_match, 515 - .hotplug = pci_hotplug, 515 + .uevent = pci_uevent, 516 516 .suspend = pci_device_suspend, 517 517 .resume = pci_device_resume, 518 518 .dev_attrs = pci_dev_attrs,
+2 -2
drivers/pci/pci.h
··· 1 1 /* Functions internal to the PCI core code */ 2 2 3 - extern int pci_hotplug (struct device *dev, char **envp, int num_envp, 4 - char *buffer, int buffer_size); 3 + extern int pci_uevent(struct device *dev, char **envp, int num_envp, 4 + char *buffer, int buffer_size); 5 5 extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 6 6 extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 7 7 extern void pci_cleanup_rom(struct pci_dev *dev);
+5 -5
drivers/pcmcia/cs.c
··· 901 901 EXPORT_SYMBOL(pcmcia_insert_card); 902 902 903 903 904 - static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, 905 - int num_envp, char *buffer, int buffer_size) 904 + static int pcmcia_socket_uevent(struct class_device *dev, char **envp, 905 + int num_envp, char *buffer, int buffer_size) 906 906 { 907 907 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); 908 908 int i = 0, length = 0; 909 909 910 - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 911 - &length, "SOCKET_NO=%u", s->sock)) 910 + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, 911 + &length, "SOCKET_NO=%u", s->sock)) 912 912 return -ENOMEM; 913 913 914 914 envp[i] = NULL; ··· 927 927 928 928 struct class pcmcia_socket_class = { 929 929 .name = "pcmcia_socket", 930 - .hotplug = pcmcia_socket_hotplug, 930 + .uevent = pcmcia_socket_uevent, 931 931 .release = pcmcia_release_socket, 932 932 .class_release = pcmcia_release_socket_class, 933 933 };
+25 -25
drivers/pcmcia/ds.c
··· 779 779 780 780 #ifdef CONFIG_HOTPLUG 781 781 782 - static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, 783 - char *buffer, int buffer_size) 782 + static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 783 + char *buffer, int buffer_size) 784 784 { 785 785 struct pcmcia_device *p_dev; 786 786 int i, length = 0; ··· 800 800 801 801 i = 0; 802 802 803 - if (add_hotplug_env_var(envp, num_envp, &i, 804 - buffer, buffer_size, &length, 805 - "SOCKET_NO=%u", 806 - p_dev->socket->sock)) 803 + if (add_uevent_var(envp, num_envp, &i, 804 + buffer, buffer_size, &length, 805 + "SOCKET_NO=%u", 806 + p_dev->socket->sock)) 807 807 return -ENOMEM; 808 808 809 - if (add_hotplug_env_var(envp, num_envp, &i, 810 - buffer, buffer_size, &length, 811 - "DEVICE_NO=%02X", 812 - p_dev->device_no)) 809 + if (add_uevent_var(envp, num_envp, &i, 810 + buffer, buffer_size, &length, 811 + "DEVICE_NO=%02X", 812 + p_dev->device_no)) 813 813 return -ENOMEM; 814 814 815 - if (add_hotplug_env_var(envp, num_envp, &i, 816 - buffer, buffer_size, &length, 817 - "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" 818 - "pa%08Xpb%08Xpc%08Xpd%08X", 819 - p_dev->has_manf_id ? p_dev->manf_id : 0, 820 - p_dev->has_card_id ? p_dev->card_id : 0, 821 - p_dev->has_func_id ? p_dev->func_id : 0, 822 - p_dev->func, 823 - p_dev->device_no, 824 - hash[0], 825 - hash[1], 826 - hash[2], 827 - hash[3])) 815 + if (add_uevent_var(envp, num_envp, &i, 816 + buffer, buffer_size, &length, 817 + "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" 818 + "pa%08Xpb%08Xpc%08Xpd%08X", 819 + p_dev->has_manf_id ? p_dev->manf_id : 0, 820 + p_dev->has_card_id ? p_dev->card_id : 0, 821 + p_dev->has_func_id ? p_dev->func_id : 0, 822 + p_dev->func, 823 + p_dev->device_no, 824 + hash[0], 825 + hash[1], 826 + hash[2], 827 + hash[3])) 828 828 return -ENOMEM; 829 829 830 830 envp[i] = NULL; ··· 834 834 835 835 #else 836 836 837 - static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, 837 + static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 838 838 char *buffer, int buffer_size) 839 839 { 840 840 return -ENODEV; ··· 1223 1223 1224 1224 struct bus_type pcmcia_bus_type = { 1225 1225 .name = "pcmcia", 1226 - .hotplug = pcmcia_bus_hotplug, 1226 + .uevent = pcmcia_bus_uevent, 1227 1227 .match = pcmcia_bus_match, 1228 1228 .dev_attrs = pcmcia_dev_attrs, 1229 1229 };
+3 -5
drivers/pnp/pnpbios/core.c
··· 56 56 #include <linux/mm.h> 57 57 #include <linux/smp.h> 58 58 #include <linux/slab.h> 59 - #include <linux/kobject_uevent.h> 60 59 #include <linux/completion.h> 61 60 #include <linux/spinlock.h> 62 61 #include <linux/dmi.h> ··· 105 106 char *argv [3], **envp, *buf, *scratch; 106 107 int i = 0, value; 107 108 108 - if (!hotplug_path [0]) 109 - return -ENOENT; 110 109 if (!current->fs->root) { 111 110 return -EAGAIN; 112 111 } ··· 116 119 return -ENOMEM; 117 120 } 118 121 119 - /* only one standardized param to hotplug command: type */ 120 - argv [0] = hotplug_path; 122 + /* FIXME: if there are actual users of this, it should be integrated into 123 + * the driver core and use the usual infrastructure like sysfs and uevents */ 124 + argv [0] = "/sbin/pnpbios"; 121 125 argv [1] = "dock"; 122 126 argv [2] = NULL; 123 127
+2 -2
drivers/s390/cio/ccwgroup.c
··· 45 45 return 0; 46 46 } 47 47 static int 48 - ccwgroup_hotplug (struct device *dev, char **envp, int num_envp, char *buffer, 48 + ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer, 49 49 int buffer_size) 50 50 { 51 51 /* TODO */ ··· 55 55 static struct bus_type ccwgroup_bus_type = { 56 56 .name = "ccwgroup", 57 57 .match = ccwgroup_bus_match, 58 - .hotplug = ccwgroup_hotplug, 58 + .uevent = ccwgroup_uevent, 59 59 }; 60 60 61 61 static inline void
+2 -2
drivers/s390/cio/device.c
··· 59 59 * Heavily modeled on pci and usb hotplug. 60 60 */ 61 61 static int 62 - ccw_hotplug (struct device *dev, char **envp, int num_envp, 62 + ccw_uevent (struct device *dev, char **envp, int num_envp, 63 63 char *buffer, int buffer_size) 64 64 { 65 65 struct ccw_device *cdev = to_ccwdev(dev); ··· 110 110 struct bus_type ccw_bus_type = { 111 111 .name = "ccw", 112 112 .match = &ccw_bus_match, 113 - .hotplug = &ccw_hotplug, 113 + .uevent = &ccw_uevent, 114 114 }; 115 115 116 116 static int io_subchannel_probe (struct device *);
-1
drivers/s390/crypto/z90main.c
··· 34 34 #include <linux/miscdevice.h> 35 35 #include <linux/module.h> 36 36 #include <linux/moduleparam.h> 37 - #include <linux/kobject_uevent.h> 38 37 #include <linux/proc_fs.h> 39 38 #include <linux/syscalls.h> 40 39 #include "z90crypt.h"
+1 -1
drivers/scsi/ipr.c
··· 2132 2132 } 2133 2133 2134 2134 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 2135 - kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE, NULL); 2135 + kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); 2136 2136 LEAVE; 2137 2137 } 2138 2138
+41 -43
drivers/usb/core/usb.c
··· 192 192 iface->condition = USB_INTERFACE_UNBOUND; 193 193 mark_quiesced(iface); 194 194 } 195 + 195 196 struct find_interface_arg { 196 197 int minor; 197 198 struct usb_interface *interface; ··· 237 236 #ifdef CONFIG_HOTPLUG 238 237 239 238 /* 240 - * USB hotplugging invokes what /proc/sys/kernel/hotplug says 241 - * (normally /sbin/hotplug) when USB devices get added or removed. 242 - * 243 - * This invokes a user mode policy agent, typically helping to load driver 239 + * This sends an uevent to userspace, typically helping to load driver 244 240 * or other modules, configure the device, and more. Drivers can provide 245 241 * a MODULE_DEVICE_TABLE to help with module loading subtasks. 246 242 * ··· 246 248 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the 247 249 * device (and this configuration!) are still present. 248 250 */ 249 - static int usb_hotplug (struct device *dev, char **envp, int num_envp, 250 - char *buffer, int buffer_size) 251 + static int usb_uevent(struct device *dev, char **envp, int num_envp, 252 + char *buffer, int buffer_size) 251 253 { 252 254 struct usb_interface *intf; 253 255 struct usb_device *usb_dev; ··· 259 261 return -ENODEV; 260 262 261 263 /* driver is often null here; dev_dbg() would oops */ 262 - pr_debug ("usb %s: hotplug\n", dev->bus_id); 264 + pr_debug ("usb %s: uevent\n", dev->bus_id); 263 265 264 266 /* Must check driver_data here, as on remove driver is always NULL */ 265 267 if ((dev->driver == &usb_generic_driver) || ··· 286 288 * 287 289 * FIXME reduce hardwired intelligence here 288 290 */ 289 - if (add_hotplug_env_var(envp, num_envp, &i, 290 - buffer, buffer_size, &length, 291 - "DEVICE=/proc/bus/usb/%03d/%03d", 292 - usb_dev->bus->busnum, usb_dev->devnum)) 291 + if (add_uevent_var(envp, num_envp, &i, 292 + buffer, buffer_size, &length, 293 + "DEVICE=/proc/bus/usb/%03d/%03d", 294 + usb_dev->bus->busnum, usb_dev->devnum)) 293 295 return -ENOMEM; 294 296 #endif 295 297 296 298 /* per-device configurations are common */ 297 - if (add_hotplug_env_var(envp, num_envp, &i, 298 - buffer, buffer_size, &length, 299 - "PRODUCT=%x/%x/%x", 300 - le16_to_cpu(usb_dev->descriptor.idVendor), 301 - le16_to_cpu(usb_dev->descriptor.idProduct), 302 - le16_to_cpu(usb_dev->descriptor.bcdDevice))) 299 + if (add_uevent_var(envp, num_envp, &i, 300 + buffer, buffer_size, &length, 301 + "PRODUCT=%x/%x/%x", 302 + le16_to_cpu(usb_dev->descriptor.idVendor), 303 + le16_to_cpu(usb_dev->descriptor.idProduct), 304 + le16_to_cpu(usb_dev->descriptor.bcdDevice))) 303 305 return -ENOMEM; 304 306 305 307 /* class-based driver binding models */ 306 - if (add_hotplug_env_var(envp, num_envp, &i, 307 - buffer, buffer_size, &length, 308 - "TYPE=%d/%d/%d", 309 - usb_dev->descriptor.bDeviceClass, 310 - usb_dev->descriptor.bDeviceSubClass, 311 - usb_dev->descriptor.bDeviceProtocol)) 308 + if (add_uevent_var(envp, num_envp, &i, 309 + buffer, buffer_size, &length, 310 + "TYPE=%d/%d/%d", 311 + usb_dev->descriptor.bDeviceClass, 312 + usb_dev->descriptor.bDeviceSubClass, 313 + usb_dev->descriptor.bDeviceProtocol)) 312 314 return -ENOMEM; 313 315 314 - if (add_hotplug_env_var(envp, num_envp, &i, 315 - buffer, buffer_size, &length, 316 - "INTERFACE=%d/%d/%d", 317 - alt->desc.bInterfaceClass, 318 - alt->desc.bInterfaceSubClass, 319 - alt->desc.bInterfaceProtocol)) 316 + if (add_uevent_var(envp, num_envp, &i, 317 + buffer, buffer_size, &length, 318 + "INTERFACE=%d/%d/%d", 319 + alt->desc.bInterfaceClass, 320 + alt->desc.bInterfaceSubClass, 321 + alt->desc.bInterfaceProtocol)) 320 322 return -ENOMEM; 321 323 322 - if (add_hotplug_env_var(envp, num_envp, &i, 323 - buffer, buffer_size, &length, 324 - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 325 - le16_to_cpu(usb_dev->descriptor.idVendor), 326 - le16_to_cpu(usb_dev->descriptor.idProduct), 327 - le16_to_cpu(usb_dev->descriptor.bcdDevice), 328 - usb_dev->descriptor.bDeviceClass, 329 - usb_dev->descriptor.bDeviceSubClass, 330 - usb_dev->descriptor.bDeviceProtocol, 331 - alt->desc.bInterfaceClass, 332 - alt->desc.bInterfaceSubClass, 333 - alt->desc.bInterfaceProtocol)) 324 + if (add_uevent_var(envp, num_envp, &i, 325 + buffer, buffer_size, &length, 326 + "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 327 + le16_to_cpu(usb_dev->descriptor.idVendor), 328 + le16_to_cpu(usb_dev->descriptor.idProduct), 329 + le16_to_cpu(usb_dev->descriptor.bcdDevice), 330 + usb_dev->descriptor.bDeviceClass, 331 + usb_dev->descriptor.bDeviceSubClass, 332 + usb_dev->descriptor.bDeviceProtocol, 333 + alt->desc.bInterfaceClass, 334 + alt->desc.bInterfaceSubClass, 335 + alt->desc.bInterfaceProtocol)) 334 336 return -ENOMEM; 335 337 336 338 envp[i] = NULL; ··· 340 342 341 343 #else 342 344 343 - static int usb_hotplug (struct device *dev, char **envp, 345 + static int usb_uevent(struct device *dev, char **envp, 344 346 int num_envp, char *buffer, int buffer_size) 345 347 { 346 348 return -ENODEV; ··· 1091 1093 struct bus_type usb_bus_type = { 1092 1094 .name = "usb", 1093 1095 .match = usb_device_match, 1094 - .hotplug = usb_hotplug, 1096 + .uevent = usb_uevent, 1095 1097 .suspend = usb_generic_suspend, 1096 1098 .resume = usb_generic_resume, 1097 1099 };
+1 -1
drivers/usb/host/hc_crisv10.c
··· 4397 4397 device_initialize(&fake_device); 4398 4398 kobject_set_name(&fake_device.kobj, "etrax_usb"); 4399 4399 kobject_add(&fake_device.kobj); 4400 - kobject_hotplug(&fake_device.kobj, KOBJ_ADD); 4400 + kobject_uevent(&fake_device.kobj, KOBJ_ADD); 4401 4401 hc->bus->controller = &fake_device; 4402 4402 usb_register_bus(hc->bus); 4403 4403
+7 -7
drivers/w1/w1.c
··· 142 142 /* Default family */ 143 143 static struct w1_family w1_default_family; 144 144 145 - static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); 145 + static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); 146 146 147 147 static struct bus_type w1_bus_type = { 148 148 .name = "w1", 149 149 .match = w1_master_match, 150 - .hotplug = w1_hotplug, 150 + .uevent = w1_uevent, 151 151 }; 152 152 153 153 struct device_driver w1_master_driver = { ··· 361 361 } 362 362 363 363 #ifdef CONFIG_HOTPLUG 364 - static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 364 + static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 365 365 { 366 366 struct w1_master *md = NULL; 367 367 struct w1_slave *sl = NULL; ··· 377 377 event_owner = "slave"; 378 378 name = sl->name; 379 379 } else { 380 - dev_dbg(dev, "Unknown hotplug event.\n"); 380 + dev_dbg(dev, "Unknown event.\n"); 381 381 return -EINVAL; 382 382 } 383 383 ··· 386 386 if (dev->driver != &w1_slave_driver || !sl) 387 387 return 0; 388 388 389 - err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); 389 + err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); 390 390 if (err) 391 391 return err; 392 392 393 - err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); 393 + err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); 394 394 if (err) 395 395 return err; 396 396 397 397 return 0; 398 398 }; 399 399 #else 400 - static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 400 + static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 401 401 { 402 402 return 0; 403 403 }
+28 -5
fs/partitions/check.c
··· 226 226 static ssize_t part_uevent_store(struct hd_struct * p, 227 227 const char *page, size_t count) 228 228 { 229 - kobject_hotplug(&p->kobj, KOBJ_ADD); 229 + kobject_uevent(&p->kobj, KOBJ_ADD); 230 230 return count; 231 231 } 232 232 static ssize_t part_dev_read(struct hd_struct * p, char *page) ··· 336 336 disk->part[part-1] = p; 337 337 } 338 338 339 + static char *make_block_name(struct gendisk *disk) 340 + { 341 + char *name; 342 + static char *block_str = "block:"; 343 + int size; 344 + 345 + size = strlen(block_str) + strlen(disk->disk_name) + 1; 346 + name = kmalloc(size, GFP_KERNEL); 347 + if (!name) 348 + return NULL; 349 + strcpy(name, block_str); 350 + strcat(name, disk->disk_name); 351 + return name; 352 + } 353 + 339 354 static void disk_sysfs_symlinks(struct gendisk *disk) 340 355 { 341 356 struct device *target = get_device(disk->driverfs_dev); 342 357 if (target) { 358 + char *disk_name = make_block_name(disk); 343 359 sysfs_create_link(&disk->kobj,&target->kobj,"device"); 344 - sysfs_create_link(&target->kobj,&disk->kobj,"block"); 360 + if (disk_name) { 361 + sysfs_create_link(&target->kobj,&disk->kobj,disk_name); 362 + kfree(disk_name); 363 + } 345 364 } 346 365 } 347 366 ··· 379 360 if ((err = kobject_add(&disk->kobj))) 380 361 return; 381 362 disk_sysfs_symlinks(disk); 382 - kobject_hotplug(&disk->kobj, KOBJ_ADD); 363 + kobject_uevent(&disk->kobj, KOBJ_ADD); 383 364 384 365 /* No minors to use for partitions */ 385 366 if (disk->minors == 1) { ··· 480 461 devfs_remove_disk(disk); 481 462 482 463 if (disk->driverfs_dev) { 464 + char *disk_name = make_block_name(disk); 483 465 sysfs_remove_link(&disk->kobj, "device"); 484 - sysfs_remove_link(&disk->driverfs_dev->kobj, "block"); 466 + if (disk_name) { 467 + sysfs_remove_link(&disk->driverfs_dev->kobj, disk_name); 468 + kfree(disk_name); 469 + } 485 470 put_device(disk->driverfs_dev); 486 471 } 487 - kobject_hotplug(&disk->kobj, KOBJ_REMOVE); 472 + kobject_uevent(&disk->kobj, KOBJ_REMOVE); 488 473 kobject_del(&disk->kobj); 489 474 }
+1 -14
fs/super.c
··· 665 665 return (void *)s->s_bdev == data; 666 666 } 667 667 668 - static void bdev_uevent(struct block_device *bdev, enum kobject_action action) 669 - { 670 - if (bdev->bd_disk) { 671 - if (bdev->bd_part) 672 - kobject_uevent(&bdev->bd_part->kobj, action, NULL); 673 - else 674 - kobject_uevent(&bdev->bd_disk->kobj, action, NULL); 675 - } 676 - } 677 - 678 668 struct super_block *get_sb_bdev(struct file_system_type *fs_type, 679 669 int flags, const char *dev_name, void *data, 680 670 int (*fill_super)(struct super_block *, void *, int)) ··· 707 717 up_write(&s->s_umount); 708 718 deactivate_super(s); 709 719 s = ERR_PTR(error); 710 - } else { 720 + } else 711 721 s->s_flags |= MS_ACTIVE; 712 - bdev_uevent(bdev, KOBJ_MOUNT); 713 - } 714 722 } 715 723 716 724 return s; ··· 724 736 { 725 737 struct block_device *bdev = sb->s_bdev; 726 738 727 - bdev_uevent(bdev, KOBJ_UMOUNT); 728 739 generic_shutdown_super(sb); 729 740 sync_blockdev(bdev); 730 741 close_bdev_excl(bdev);
+5 -1
fs/sysfs/dir.c
··· 112 112 } 113 113 } 114 114 if (error && (error != -EEXIST)) { 115 - sysfs_put((*d)->d_fsdata); 115 + struct sysfs_dirent *sd = (*d)->d_fsdata; 116 + if (sd) { 117 + list_del_init(&sd->s_sibling); 118 + sysfs_put(sd); 119 + } 116 120 d_drop(*d); 117 121 } 118 122 dput(*d);
+7 -7
include/linux/device.h
··· 47 47 struct driver_attribute * drv_attrs; 48 48 49 49 int (*match)(struct device * dev, struct device_driver * drv); 50 - int (*hotplug) (struct device *dev, char **envp, 51 - int num_envp, char *buffer, int buffer_size); 50 + int (*uevent)(struct device *dev, char **envp, 51 + int num_envp, char *buffer, int buffer_size); 52 52 int (*suspend)(struct device * dev, pm_message_t state); 53 53 int (*resume)(struct device * dev); 54 54 }; ··· 151 151 struct class_attribute * class_attrs; 152 152 struct class_device_attribute * class_dev_attrs; 153 153 154 - int (*hotplug)(struct class_device *dev, char **envp, 154 + int (*uevent)(struct class_device *dev, char **envp, 155 155 int num_envp, char *buffer, int buffer_size); 156 156 157 157 void (*release)(struct class_device *dev); ··· 209 209 * set, this will be called instead of the class specific release function. 210 210 * Only use this if you want to override the default release function, like 211 211 * when you are nesting class_device structures. 212 - * @hotplug: pointer to a hotplug function for this struct class_device. If 213 - * set, this will be called instead of the class specific hotplug function. 214 - * Only use this if you want to override the default hotplug function, like 212 + * @uevent: pointer to a uevent function for this struct class_device. If 213 + * set, this will be called instead of the class specific uevent function. 214 + * Only use this if you want to override the default uevent function, like 215 215 * when you are nesting class_device structures. 216 216 */ 217 217 struct class_device { ··· 227 227 struct class_device *parent; /* parent of this child device, if there is one */ 228 228 229 229 void (*release)(struct class_device *dev); 230 - int (*hotplug)(struct class_device *dev, char **envp, 230 + int (*uevent)(struct class_device *dev, char **envp, 231 231 int num_envp, char *buffer, int buffer_size); 232 232 char class_id[BUS_ID_SIZE]; /* unique to this class */ 233 233 };
+1 -1
include/linux/firmware.h
··· 14 14 int request_firmware(const struct firmware **fw, const char *name, 15 15 struct device *device); 16 16 int request_firmware_nowait( 17 - struct module *module, int hotplug, 17 + struct module *module, int uevent, 18 18 const char *name, struct device *device, void *context, 19 19 void (*cont)(const struct firmware *fw, void *context)); 20 20
+41 -38
include/linux/input.h
··· 13 13 #include <linux/time.h> 14 14 #include <linux/list.h> 15 15 #include <linux/device.h> 16 + #include <linux/mod_devicetable.h> 16 17 #else 17 18 #include <sys/time.h> 18 19 #include <sys/ioctl.h> ··· 512 511 #define KEY_FN_S 0x1e3 513 512 #define KEY_FN_B 0x1e4 514 513 514 + /* We avoid low common keys in module aliases so they don't get huge. */ 515 + #define KEY_MIN_INTERESTING KEY_MUTE 515 516 #define KEY_MAX 0x1ff 516 517 517 518 /* ··· 796 793 797 794 #define FF_MAX 0x7f 798 795 796 + struct input_device_id { 797 + 798 + kernel_ulong_t flags; 799 + 800 + struct input_id id; 801 + 802 + kernel_ulong_t evbit[EV_MAX/BITS_PER_LONG+1]; 803 + kernel_ulong_t keybit[KEY_MAX/BITS_PER_LONG+1]; 804 + kernel_ulong_t relbit[REL_MAX/BITS_PER_LONG+1]; 805 + kernel_ulong_t absbit[ABS_MAX/BITS_PER_LONG+1]; 806 + kernel_ulong_t mscbit[MSC_MAX/BITS_PER_LONG+1]; 807 + kernel_ulong_t ledbit[LED_MAX/BITS_PER_LONG+1]; 808 + kernel_ulong_t sndbit[SND_MAX/BITS_PER_LONG+1]; 809 + kernel_ulong_t ffbit[FF_MAX/BITS_PER_LONG+1]; 810 + kernel_ulong_t swbit[SW_MAX/BITS_PER_LONG+1]; 811 + 812 + kernel_ulong_t driver_info; 813 + }; 814 + 815 + /* 816 + * Structure for hotplug & device<->driver matching. 817 + */ 818 + 819 + #define INPUT_DEVICE_ID_MATCH_BUS 1 820 + #define INPUT_DEVICE_ID_MATCH_VENDOR 2 821 + #define INPUT_DEVICE_ID_MATCH_PRODUCT 4 822 + #define INPUT_DEVICE_ID_MATCH_VERSION 8 823 + 824 + #define INPUT_DEVICE_ID_MATCH_EVBIT 0x010 825 + #define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020 826 + #define INPUT_DEVICE_ID_MATCH_RELBIT 0x040 827 + #define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080 828 + #define INPUT_DEVICE_ID_MATCH_MSCIT 0x100 829 + #define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 830 + #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 831 + #define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 832 + #define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 833 + 799 834 #ifdef __KERNEL__ 800 835 801 836 /* ··· 942 901 }; 943 902 #define to_input_dev(d) container_of(d, struct input_dev, cdev) 944 903 945 - /* 946 - * Structure for hotplug & device<->driver matching. 947 - */ 948 - 949 - #define INPUT_DEVICE_ID_MATCH_BUS 1 950 - #define INPUT_DEVICE_ID_MATCH_VENDOR 2 951 - #define INPUT_DEVICE_ID_MATCH_PRODUCT 4 952 - #define INPUT_DEVICE_ID_MATCH_VERSION 8 953 - 954 - #define INPUT_DEVICE_ID_MATCH_EVBIT 0x010 955 - #define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020 956 - #define INPUT_DEVICE_ID_MATCH_RELBIT 0x040 957 - #define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080 958 - #define INPUT_DEVICE_ID_MATCH_MSCIT 0x100 959 - #define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 960 - #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 961 - #define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 962 - #define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 963 - 964 904 #define INPUT_DEVICE_ID_MATCH_DEVICE\ 965 905 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) 966 906 #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\ 967 907 (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) 968 - 969 - struct input_device_id { 970 - 971 - unsigned long flags; 972 - 973 - struct input_id id; 974 - 975 - unsigned long evbit[NBITS(EV_MAX)]; 976 - unsigned long keybit[NBITS(KEY_MAX)]; 977 - unsigned long relbit[NBITS(REL_MAX)]; 978 - unsigned long absbit[NBITS(ABS_MAX)]; 979 - unsigned long mscbit[NBITS(MSC_MAX)]; 980 - unsigned long ledbit[NBITS(LED_MAX)]; 981 - unsigned long sndbit[NBITS(SND_MAX)]; 982 - unsigned long ffbit[NBITS(FF_MAX)]; 983 - unsigned long swbit[NBITS(SW_MAX)]; 984 - 985 - unsigned long driver_info; 986 - }; 987 908 988 909 struct input_handle; 989 910
+34 -20
include/linux/kobject.h
··· 23 23 #include <linux/spinlock.h> 24 24 #include <linux/rwsem.h> 25 25 #include <linux/kref.h> 26 - #include <linux/kobject_uevent.h> 27 26 #include <linux/kernel.h> 28 27 #include <asm/atomic.h> 29 28 30 - #define KOBJ_NAME_LEN 20 29 + #define KOBJ_NAME_LEN 20 30 + #define UEVENT_HELPER_PATH_LEN 256 31 31 32 - /* counter to tag the hotplug event, read only except for the kobject core */ 33 - extern u64 hotplug_seqnum; 32 + /* path to the userspace helper executed on an event */ 33 + extern char uevent_helper[]; 34 + 35 + /* counter to tag the uevent, read only except for the kobject core */ 36 + extern u64 uevent_seqnum; 37 + 38 + /* the actions here must match the proper string in lib/kobject_uevent.c */ 39 + typedef int __bitwise kobject_action_t; 40 + enum kobject_action { 41 + KOBJ_ADD = (__force kobject_action_t) 0x01, /* exclusive to core */ 42 + KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* exclusive to core */ 43 + KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* device state change */ 44 + KOBJ_OFFLINE = (__force kobject_action_t) 0x04, /* device offline */ 45 + KOBJ_ONLINE = (__force kobject_action_t) 0x05, /* device online */ 46 + }; 34 47 35 48 struct kobject { 36 49 const char * k_name; ··· 100 87 * of object; multiple ksets can belong to one subsystem. All 101 88 * ksets of a subsystem share the subsystem's lock. 102 89 * 103 - * Each kset can support hotplugging; if it does, it will be given 104 - * the opportunity to filter out specific kobjects from being 105 - * reported, as well as to add its own "data" elements to the 106 - * environment being passed to the hotplug helper. 90 + * Each kset can support specific event variables; it can 91 + * supress the event generation or add subsystem specific 92 + * variables carried with the event. 107 93 */ 108 - struct kset_hotplug_ops { 94 + struct kset_uevent_ops { 109 95 int (*filter)(struct kset *kset, struct kobject *kobj); 110 96 const char *(*name)(struct kset *kset, struct kobject *kobj); 111 - int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp, 97 + int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp, 112 98 int num_envp, char *buffer, int buffer_size); 113 99 }; 114 100 ··· 117 105 struct list_head list; 118 106 spinlock_t list_lock; 119 107 struct kobject kobj; 120 - struct kset_hotplug_ops * hotplug_ops; 108 + struct kset_uevent_ops * uevent_ops; 121 109 }; 122 110 123 111 ··· 165 153 struct rw_semaphore rwsem; 166 154 }; 167 155 168 - #define decl_subsys(_name,_type,_hotplug_ops) \ 156 + #define decl_subsys(_name,_type,_uevent_ops) \ 169 157 struct subsystem _name##_subsys = { \ 170 158 .kset = { \ 171 159 .kobj = { .name = __stringify(_name) }, \ 172 160 .ktype = _type, \ 173 - .hotplug_ops =_hotplug_ops, \ 161 + .uevent_ops =_uevent_ops, \ 174 162 } \ 175 163 } 176 - #define decl_subsys_name(_varname,_name,_type,_hotplug_ops) \ 164 + #define decl_subsys_name(_varname,_name,_type,_uevent_ops) \ 177 165 struct subsystem _varname##_subsys = { \ 178 166 .kset = { \ 179 167 .kobj = { .name = __stringify(_name) }, \ 180 168 .ktype = _type, \ 181 - .hotplug_ops =_hotplug_ops, \ 169 + .uevent_ops =_uevent_ops, \ 182 170 } \ 183 171 } 184 172 ··· 253 241 extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); 254 242 extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *); 255 243 256 - #ifdef CONFIG_HOTPLUG 257 - void kobject_hotplug(struct kobject *kobj, enum kobject_action action); 258 - int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 244 + #if defined(CONFIG_HOTPLUG) & defined(CONFIG_NET) 245 + void kobject_uevent(struct kobject *kobj, enum kobject_action action); 246 + 247 + int add_uevent_var(char **envp, int num_envp, int *cur_index, 259 248 char *buffer, int buffer_size, int *cur_len, 260 249 const char *format, ...) 261 250 __attribute__((format (printf, 7, 8))); 262 251 #else 263 - static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { } 264 - static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 252 + static inline void kobject_uevent(struct kobject *kobj, enum kobject_action action) { } 253 + 254 + static inline int add_uevent_var(char **envp, int num_envp, int *cur_index, 265 255 char *buffer, int buffer_size, int *cur_len, 266 256 const char *format, ...) 267 257 { return 0; }
-57
include/linux/kobject_uevent.h
··· 1 - /* 2 - * kobject_uevent.h - list of kobject user events that can be generated 3 - * 4 - * Copyright (C) 2004 IBM Corp. 5 - * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> 6 - * 7 - * This file is released under the GPLv2. 8 - * 9 - */ 10 - 11 - #ifndef _KOBJECT_EVENT_H_ 12 - #define _KOBJECT_EVENT_H_ 13 - 14 - #define HOTPLUG_PATH_LEN 256 15 - 16 - /* path to the hotplug userspace helper executed on an event */ 17 - extern char hotplug_path[]; 18 - 19 - /* 20 - * If you add an action here, you must also add the proper string to the 21 - * lib/kobject_uevent.c file. 22 - */ 23 - typedef int __bitwise kobject_action_t; 24 - enum kobject_action { 25 - KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ 26 - KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ 27 - KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ 28 - KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */ 29 - KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */ 30 - KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* offline event for hotplug devices */ 31 - KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* online event for hotplug devices */ 32 - }; 33 - 34 - 35 - #ifdef CONFIG_KOBJECT_UEVENT 36 - int kobject_uevent(struct kobject *kobj, 37 - enum kobject_action action, 38 - struct attribute *attr); 39 - int kobject_uevent_atomic(struct kobject *kobj, 40 - enum kobject_action action, 41 - struct attribute *attr); 42 - #else 43 - static inline int kobject_uevent(struct kobject *kobj, 44 - enum kobject_action action, 45 - struct attribute *attr) 46 - { 47 - return 0; 48 - } 49 - static inline int kobject_uevent_atomic(struct kobject *kobj, 50 - enum kobject_action action, 51 - struct attribute *attr) 52 - { 53 - return 0; 54 - } 55 - #endif 56 - 57 - #endif
+1
include/linux/platform_device.h
··· 41 41 extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 42 42 extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); 43 43 extern int platform_device_add(struct platform_device *pdev); 44 + extern void platform_device_del(struct platform_device *pdev); 44 45 extern void platform_device_put(struct platform_device *pdev); 45 46 46 47 struct platform_driver {
+1 -1
include/linux/sysctl.h
··· 124 124 KERN_OVERFLOWUID=46, /* int: overflow UID */ 125 125 KERN_OVERFLOWGID=47, /* int: overflow GID */ 126 126 KERN_SHMPATH=48, /* string: path to shm fs */ 127 - KERN_HOTPLUG=49, /* string: path to hotplug policy agent */ 127 + KERN_HOTPLUG=49, /* string: path to uevent helper (deprecated) */ 128 128 KERN_IEEE_EMULATION_WARNINGS=50, /* int: unimplemented ieee instructions */ 129 129 KERN_S390_USER_DEBUG_LOGGING=51, /* int: dumps of user faults */ 130 130 KERN_CORE_USES_PID=52, /* int: use core or core.%pid */
+1 -1
include/linux/usb.h
··· 225 225 * Device drivers should not attempt to activate configurations. The choice 226 226 * of which configuration to install is a policy decision based on such 227 227 * considerations as available power, functionality provided, and the user's 228 - * desires (expressed through hotplug scripts). However, drivers can call 228 + * desires (expressed through userspace tools). However, drivers can call 229 229 * usb_reset_configuration() to reinitialize the current configuration and 230 230 * all its interfaces. 231 231 */
+9 -27
init/Kconfig
··· 197 197 can be used independently or with another kernel subsystem, 198 198 such as SELinux. 199 199 200 - config HOTPLUG 201 - bool "Support for hot-pluggable devices" if !ARCH_S390 202 - default ARCH_S390 203 - help 204 - This option is provided for the case where no in-kernel-tree 205 - modules require HOTPLUG functionality, but a module built 206 - outside the kernel tree does. Such modules require Y here. 207 - 208 - config KOBJECT_UEVENT 209 - bool "Kernel Userspace Events" if EMBEDDED 210 - depends on NET 211 - default y 212 - help 213 - This option enables the kernel userspace event layer, which is a 214 - simple mechanism for kernel-to-user communication over a netlink 215 - socket. 216 - The goal of the kernel userspace events layer is to provide a simple 217 - and efficient events system, that notifies userspace about kobject 218 - state changes. This will enable applications to just listen for 219 - events instead of polling system devices and files. 220 - Hotplug events (kobject addition and removal) are also available on 221 - the netlink socket in addition to the execution of /sbin/hotplug if 222 - CONFIG_HOTPLUG is enabled. 223 - 224 - Say Y, unless you are building a system requiring minimal memory 225 - consumption. 226 - 227 200 config IKCONFIG 228 201 bool "Kernel .config support" 229 202 ---help--- ··· 280 307 reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while 281 308 you wait for kallsyms to be fixed. 282 309 310 + 311 + config HOTPLUG 312 + bool "Support for hot-pluggable devices" if EMBEDDED 313 + default y 314 + help 315 + This option is provided for the case where no hotplug or uevent 316 + capabilities is wanted by the kernel. You should only consider 317 + disabling this option for embedded systems that do not use modules, a 318 + dynamic /dev tree, or dynamic device discovery. Just say Y. 283 319 284 320 config PRINTK 285 321 default y
+26 -4
kernel/ksysfs.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/init.h> 17 17 18 + u64 uevent_seqnum; 19 + char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug"; 20 + 18 21 #define KERNEL_ATTR_RO(_name) \ 19 22 static struct subsys_attribute _name##_attr = __ATTR_RO(_name) 20 23 ··· 26 23 __ATTR(_name, 0644, _name##_show, _name##_store) 27 24 28 25 #ifdef CONFIG_HOTPLUG 29 - static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page) 26 + /* current uevent sequence number */ 27 + static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page) 30 28 { 31 - return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum); 29 + return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum); 32 30 } 33 - KERNEL_ATTR_RO(hotplug_seqnum); 31 + KERNEL_ATTR_RO(uevent_seqnum); 32 + 33 + /* uevent helper program, used during early boo */ 34 + static ssize_t uevent_helper_show(struct subsystem *subsys, char *page) 35 + { 36 + return sprintf(page, "%s\n", uevent_helper); 37 + } 38 + static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, size_t count) 39 + { 40 + if (count+1 > UEVENT_HELPER_PATH_LEN) 41 + return -ENOENT; 42 + memcpy(uevent_helper, page, count); 43 + uevent_helper[count] = '\0'; 44 + if (count && uevent_helper[count-1] == '\n') 45 + uevent_helper[count-1] = '\0'; 46 + return count; 47 + } 48 + KERNEL_ATTR_RW(uevent_helper); 34 49 #endif 35 50 36 51 #ifdef CONFIG_KEXEC ··· 66 45 67 46 static struct attribute * kernel_attrs[] = { 68 47 #ifdef CONFIG_HOTPLUG 69 - &hotplug_seqnum_attr.attr, 48 + &uevent_seqnum_attr.attr, 49 + &uevent_helper_attr.attr, 70 50 #endif 71 51 #ifdef CONFIG_KEXEC 72 52 &crash_notes_attr.attr,
+3 -5
kernel/sysctl.c
··· 31 31 #include <linux/smp_lock.h> 32 32 #include <linux/init.h> 33 33 #include <linux/kernel.h> 34 + #include <linux/kobject.h> 34 35 #include <linux/net.h> 35 36 #include <linux/sysrq.h> 36 37 #include <linux/highuid.h> ··· 83 82 84 83 #ifdef CONFIG_KMOD 85 84 extern char modprobe_path[]; 86 - #endif 87 - #ifdef CONFIG_HOTPLUG 88 - extern char hotplug_path[]; 89 85 #endif 90 86 #ifdef CONFIG_CHR_DEV_SG 91 87 extern int sg_big_buff; ··· 395 397 { 396 398 .ctl_name = KERN_HOTPLUG, 397 399 .procname = "hotplug", 398 - .data = &hotplug_path, 399 - .maxlen = HOTPLUG_PATH_LEN, 400 + .data = &uevent_helper, 401 + .maxlen = UEVENT_HELPER_PATH_LEN, 400 402 .mode = 0644, 401 403 .proc_handler = &proc_dostring, 402 404 .strategy = &sysctl_string,
+2
lib/klist.c
··· 199 199 i->i_klist = k; 200 200 i->i_head = &k->k_list; 201 201 i->i_cur = n; 202 + if (n) 203 + kref_get(&n->n_ref); 202 204 } 203 205 204 206 EXPORT_SYMBOL_GPL(klist_iter_init_node);
+2 -2
lib/kobject.c
··· 207 207 kobject_name(kobj),error); 208 208 dump_stack(); 209 209 } else 210 - kobject_hotplug(kobj, KOBJ_ADD); 210 + kobject_uevent(kobj, KOBJ_ADD); 211 211 } else 212 212 error = -EINVAL; 213 213 return error; ··· 312 312 void kobject_unregister(struct kobject * kobj) 313 313 { 314 314 pr_debug("kobject %s: unregistering\n",kobject_name(kobj)); 315 - kobject_hotplug(kobj, KOBJ_REMOVE); 315 + kobject_uevent(kobj, KOBJ_REMOVE); 316 316 kobject_del(kobj); 317 317 kobject_put(kobj); 318 318 }
+129 -238
lib/kobject_uevent.c
··· 19 19 #include <linux/skbuff.h> 20 20 #include <linux/netlink.h> 21 21 #include <linux/string.h> 22 - #include <linux/kobject_uevent.h> 23 22 #include <linux/kobject.h> 24 23 #include <net/sock.h> 25 24 26 - #define BUFFER_SIZE 1024 /* buffer for the hotplug env */ 25 + #define BUFFER_SIZE 1024 /* buffer for the variables */ 27 26 #define NUM_ENVP 32 /* number of env pointers */ 28 27 29 - #if defined(CONFIG_KOBJECT_UEVENT) || defined(CONFIG_HOTPLUG) 28 + #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 29 + static DEFINE_SPINLOCK(sequence_lock); 30 + static struct sock *uevent_sock; 31 + 30 32 static char *action_to_string(enum kobject_action action) 31 33 { 32 34 switch (action) { ··· 38 36 return "remove"; 39 37 case KOBJ_CHANGE: 40 38 return "change"; 41 - case KOBJ_MOUNT: 42 - return "mount"; 43 - case KOBJ_UMOUNT: 44 - return "umount"; 45 39 case KOBJ_OFFLINE: 46 40 return "offline"; 47 41 case KOBJ_ONLINE: ··· 46 48 return NULL; 47 49 } 48 50 } 49 - #endif 50 - 51 - #ifdef CONFIG_KOBJECT_UEVENT 52 - static struct sock *uevent_sock; 53 51 54 52 /** 55 - * send_uevent - notify userspace by sending event through netlink socket 53 + * kobject_uevent - notify userspace by ending an uevent 56 54 * 57 - * @signal: signal name 58 - * @obj: object path (kobject) 59 - * @envp: possible hotplug environment to pass with the message 60 - * @gfp_mask: 61 - */ 62 - static int send_uevent(const char *signal, const char *obj, 63 - char **envp, gfp_t gfp_mask) 64 - { 65 - struct sk_buff *skb; 66 - char *pos; 67 - int len; 68 - 69 - if (!uevent_sock) 70 - return -EIO; 71 - 72 - len = strlen(signal) + 1; 73 - len += strlen(obj) + 1; 74 - 75 - /* allocate buffer with the maximum possible message size */ 76 - skb = alloc_skb(len + BUFFER_SIZE, gfp_mask); 77 - if (!skb) 78 - return -ENOMEM; 79 - 80 - pos = skb_put(skb, len); 81 - sprintf(pos, "%s@%s", signal, obj); 82 - 83 - /* copy the environment key by key to our continuous buffer */ 84 - if (envp) { 85 - int i; 86 - 87 - for (i = 2; envp[i]; i++) { 88 - len = strlen(envp[i]) + 1; 89 - pos = skb_put(skb, len); 90 - strcpy(pos, envp[i]); 91 - } 92 - } 93 - 94 - NETLINK_CB(skb).dst_group = 1; 95 - return netlink_broadcast(uevent_sock, skb, 0, 1, gfp_mask); 96 - } 97 - 98 - static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action, 99 - struct attribute *attr, gfp_t gfp_mask) 100 - { 101 - char *path; 102 - char *attrpath; 103 - char *signal; 104 - int len; 105 - int rc = -ENOMEM; 106 - 107 - path = kobject_get_path(kobj, gfp_mask); 108 - if (!path) 109 - return -ENOMEM; 110 - 111 - signal = action_to_string(action); 112 - if (!signal) 113 - return -EINVAL; 114 - 115 - if (attr) { 116 - len = strlen(path); 117 - len += strlen(attr->name) + 2; 118 - attrpath = kmalloc(len, gfp_mask); 119 - if (!attrpath) 120 - goto exit; 121 - sprintf(attrpath, "%s/%s", path, attr->name); 122 - rc = send_uevent(signal, attrpath, NULL, gfp_mask); 123 - kfree(attrpath); 124 - } else 125 - rc = send_uevent(signal, path, NULL, gfp_mask); 126 - 127 - exit: 128 - kfree(path); 129 - return rc; 130 - } 131 - 132 - /** 133 - * kobject_uevent - notify userspace by sending event through netlink socket 134 - * 135 - * @signal: signal name 136 - * @kobj: struct kobject that the event is happening to 137 - * @attr: optional struct attribute the event belongs to 138 - */ 139 - int kobject_uevent(struct kobject *kobj, enum kobject_action action, 140 - struct attribute *attr) 141 - { 142 - return do_kobject_uevent(kobj, action, attr, GFP_KERNEL); 143 - } 144 - EXPORT_SYMBOL_GPL(kobject_uevent); 145 - 146 - int kobject_uevent_atomic(struct kobject *kobj, enum kobject_action action, 147 - struct attribute *attr) 148 - { 149 - return do_kobject_uevent(kobj, action, attr, GFP_ATOMIC); 150 - } 151 - EXPORT_SYMBOL_GPL(kobject_uevent_atomic); 152 - 153 - static int __init kobject_uevent_init(void) 154 - { 155 - uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, 156 - THIS_MODULE); 157 - 158 - if (!uevent_sock) { 159 - printk(KERN_ERR 160 - "kobject_uevent: unable to create netlink socket!\n"); 161 - return -ENODEV; 162 - } 163 - 164 - return 0; 165 - } 166 - 167 - postcore_initcall(kobject_uevent_init); 168 - 169 - #else 170 - static inline int send_uevent(const char *signal, const char *obj, 171 - char **envp, int gfp_mask) 172 - { 173 - return 0; 174 - } 175 - 176 - #endif /* CONFIG_KOBJECT_UEVENT */ 177 - 178 - 179 - #ifdef CONFIG_HOTPLUG 180 - char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; 181 - u64 hotplug_seqnum; 182 - static DEFINE_SPINLOCK(sequence_lock); 183 - 184 - /** 185 - * kobject_hotplug - notify userspace by executing /sbin/hotplug 186 - * 187 - * @action: action that is happening (usually "ADD" or "REMOVE") 55 + * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE) 188 56 * @kobj: struct kobject that the action is happening to 189 57 */ 190 - void kobject_hotplug(struct kobject *kobj, enum kobject_action action) 58 + void kobject_uevent(struct kobject *kobj, enum kobject_action action) 191 59 { 192 - char *argv [3]; 193 - char **envp = NULL; 194 - char *buffer = NULL; 195 - char *seq_buff; 60 + char **envp; 61 + char *buffer; 196 62 char *scratch; 63 + const char *action_string; 64 + const char *devpath = NULL; 65 + const char *subsystem; 66 + struct kobject *top_kobj; 67 + struct kset *kset; 68 + struct kset_uevent_ops *uevent_ops; 69 + u64 seq; 70 + char *seq_buff; 197 71 int i = 0; 198 72 int retval; 199 - char *kobj_path = NULL; 200 - const char *name = NULL; 201 - char *action_string; 202 - u64 seq; 203 - struct kobject *top_kobj = kobj; 204 - struct kset *kset; 205 - static struct kset_hotplug_ops null_hotplug_ops; 206 - struct kset_hotplug_ops *hotplug_ops = &null_hotplug_ops; 207 73 208 - /* If this kobj does not belong to a kset, 209 - try to find a parent that does. */ 210 - if (!top_kobj->kset && top_kobj->parent) { 211 - do { 212 - top_kobj = top_kobj->parent; 213 - } while (!top_kobj->kset && top_kobj->parent); 214 - } 215 - 216 - if (top_kobj->kset) 217 - kset = top_kobj->kset; 218 - else 219 - return; 220 - 221 - if (kset->hotplug_ops) 222 - hotplug_ops = kset->hotplug_ops; 223 - 224 - /* If the kset has a filter operation, call it. 225 - Skip the event, if the filter returns zero. */ 226 - if (hotplug_ops->filter) { 227 - if (!hotplug_ops->filter(kset, kobj)) 228 - return; 229 - } 230 - 231 - pr_debug ("%s\n", __FUNCTION__); 74 + pr_debug("%s\n", __FUNCTION__); 232 75 233 76 action_string = action_to_string(action); 234 77 if (!action_string) 235 78 return; 236 79 237 - envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); 80 + /* search the kset we belong to */ 81 + top_kobj = kobj; 82 + if (!top_kobj->kset && top_kobj->parent) { 83 + do { 84 + top_kobj = top_kobj->parent; 85 + } while (!top_kobj->kset && top_kobj->parent); 86 + } 87 + if (!top_kobj->kset) 88 + return; 89 + 90 + kset = top_kobj->kset; 91 + uevent_ops = kset->uevent_ops; 92 + 93 + /* skip the event, if the filter returns zero. */ 94 + if (uevent_ops && uevent_ops->filter) 95 + if (!uevent_ops->filter(kset, kobj)) 96 + return; 97 + 98 + /* environment index */ 99 + envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); 238 100 if (!envp) 239 101 return; 240 - memset (envp, 0x00, NUM_ENVP * sizeof (char *)); 241 102 103 + /* environment values */ 242 104 buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL); 243 105 if (!buffer) 244 106 goto exit; 245 107 246 - if (hotplug_ops->name) 247 - name = hotplug_ops->name(kset, kobj); 248 - if (name == NULL) 249 - name = kobject_name(&kset->kobj); 250 - 251 - argv [0] = hotplug_path; 252 - argv [1] = (char *)name; /* won't be changed but 'const' has to go */ 253 - argv [2] = NULL; 254 - 255 - /* minimal command environment */ 256 - envp [i++] = "HOME=/"; 257 - envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 258 - 259 - scratch = buffer; 260 - 261 - envp [i++] = scratch; 262 - scratch += sprintf(scratch, "ACTION=%s", action_string) + 1; 263 - 264 - kobj_path = kobject_get_path(kobj, GFP_KERNEL); 265 - if (!kobj_path) 108 + /* complete object path */ 109 + devpath = kobject_get_path(kobj, GFP_KERNEL); 110 + if (!devpath) 266 111 goto exit; 267 112 268 - envp [i++] = scratch; 269 - scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1; 113 + /* originating subsystem */ 114 + if (uevent_ops && uevent_ops->name) 115 + subsystem = uevent_ops->name(kset, kobj); 116 + else 117 + subsystem = kobject_name(&kset->kobj); 270 118 271 - envp [i++] = scratch; 272 - scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1; 119 + /* event environemnt for helper process only */ 120 + envp[i++] = "HOME=/"; 121 + envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 273 122 274 - /* reserve space for the sequence, 275 - * put the real one in after the hotplug call */ 123 + /* default keys */ 124 + scratch = buffer; 125 + envp [i++] = scratch; 126 + scratch += sprintf(scratch, "ACTION=%s", action_string) + 1; 127 + envp [i++] = scratch; 128 + scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1; 129 + envp [i++] = scratch; 130 + scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1; 131 + 132 + /* just reserve the space, overwrite it after kset call has returned */ 276 133 envp[i++] = seq_buff = scratch; 277 134 scratch += strlen("SEQNUM=18446744073709551616") + 1; 278 135 279 - if (hotplug_ops->hotplug) { 280 - /* have the kset specific function add its stuff */ 281 - retval = hotplug_ops->hotplug (kset, kobj, 136 + /* let the kset specific function add its stuff */ 137 + if (uevent_ops && uevent_ops->uevent) { 138 + retval = uevent_ops->uevent(kset, kobj, 282 139 &envp[i], NUM_ENVP - i, scratch, 283 140 BUFFER_SIZE - (scratch - buffer)); 284 141 if (retval) { 285 - pr_debug ("%s - hotplug() returned %d\n", 142 + pr_debug ("%s - uevent() returned %d\n", 286 143 __FUNCTION__, retval); 287 144 goto exit; 288 145 } 289 146 } 290 147 148 + /* we will send an event, request a new sequence number */ 291 149 spin_lock(&sequence_lock); 292 - seq = ++hotplug_seqnum; 150 + seq = ++uevent_seqnum; 293 151 spin_unlock(&sequence_lock); 294 152 sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq); 295 153 296 - pr_debug ("%s: %s %s seq=%llu %s %s %s %s %s\n", 297 - __FUNCTION__, argv[0], argv[1], (unsigned long long)seq, 298 - envp[0], envp[1], envp[2], envp[3], envp[4]); 154 + /* send netlink message */ 155 + if (uevent_sock) { 156 + struct sk_buff *skb; 157 + size_t len; 299 158 300 - send_uevent(action_string, kobj_path, envp, GFP_KERNEL); 159 + /* allocate message with the maximum possible size */ 160 + len = strlen(action_string) + strlen(devpath) + 2; 161 + skb = alloc_skb(len + BUFFER_SIZE, GFP_KERNEL); 162 + if (skb) { 163 + /* add header */ 164 + scratch = skb_put(skb, len); 165 + sprintf(scratch, "%s@%s", action_string, devpath); 301 166 302 - if (!hotplug_path[0]) 303 - goto exit; 167 + /* copy keys to our continuous event payload buffer */ 168 + for (i = 2; envp[i]; i++) { 169 + len = strlen(envp[i]) + 1; 170 + scratch = skb_put(skb, len); 171 + strcpy(scratch, envp[i]); 172 + } 304 173 305 - retval = call_usermodehelper (argv[0], argv, envp, 0); 306 - if (retval) 307 - pr_debug ("%s - call_usermodehelper returned %d\n", 308 - __FUNCTION__, retval); 174 + NETLINK_CB(skb).dst_group = 1; 175 + netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL); 176 + } 177 + } 178 + 179 + /* call uevent_helper, usually only enabled during early boot */ 180 + if (uevent_helper[0]) { 181 + char *argv [3]; 182 + 183 + argv [0] = uevent_helper; 184 + argv [1] = (char *)subsystem; 185 + argv [2] = NULL; 186 + call_usermodehelper (argv[0], argv, envp, 0); 187 + } 309 188 310 189 exit: 311 - kfree(kobj_path); 190 + kfree(devpath); 312 191 kfree(buffer); 313 192 kfree(envp); 314 193 return; 315 194 } 316 - EXPORT_SYMBOL(kobject_hotplug); 195 + EXPORT_SYMBOL_GPL(kobject_uevent); 317 196 318 197 /** 319 - * add_hotplug_env_var - helper for creating hotplug environment variables 198 + * add_uevent_var - helper for creating event variables 320 199 * @envp: Pointer to table of environment variables, as passed into 321 - * hotplug() method. 200 + * uevent() method. 322 201 * @num_envp: Number of environment variable slots available, as 323 - * passed into hotplug() method. 202 + * passed into uevent() method. 324 203 * @cur_index: Pointer to current index into @envp. It should be 325 - * initialized to 0 before the first call to add_hotplug_env_var(), 204 + * initialized to 0 before the first call to add_uevent_var(), 326 205 * and will be incremented on success. 327 206 * @buffer: Pointer to buffer for environment variables, as passed 328 - * into hotplug() method. 329 - * @buffer_size: Length of @buffer, as passed into hotplug() method. 207 + * into uevent() method. 208 + * @buffer_size: Length of @buffer, as passed into uevent() method. 330 209 * @cur_len: Pointer to current length of space used in @buffer. 331 210 * Should be initialized to 0 before the first call to 332 - * add_hotplug_env_var(), and will be incremented on success. 211 + * add_uevent_var(), and will be incremented on success. 333 212 * @format: Format for creating environment variable (of the form 334 213 * "XXX=%x") for snprintf(). 335 214 * 336 215 * Returns 0 if environment variable was added successfully or -ENOMEM 337 216 * if no space was available. 338 217 */ 339 - int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 340 - char *buffer, int buffer_size, int *cur_len, 341 - const char *format, ...) 218 + int add_uevent_var(char **envp, int num_envp, int *cur_index, 219 + char *buffer, int buffer_size, int *cur_len, 220 + const char *format, ...) 342 221 { 343 222 va_list args; 344 223 345 224 /* 346 225 * We check against num_envp - 1 to make sure there is at 347 - * least one slot left after we return, since the hotplug 348 - * method needs to set the last slot to NULL. 226 + * least one slot left after we return, since kobject_uevent() 227 + * needs to set the last slot to NULL. 349 228 */ 350 229 if (*cur_index >= num_envp - 1) 351 230 return -ENOMEM; ··· 241 366 (*cur_index)++; 242 367 return 0; 243 368 } 244 - EXPORT_SYMBOL(add_hotplug_env_var); 369 + EXPORT_SYMBOL_GPL(add_uevent_var); 370 + 371 + static int __init kobject_uevent_init(void) 372 + { 373 + uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, 374 + THIS_MODULE); 375 + 376 + if (!uevent_sock) { 377 + printk(KERN_ERR 378 + "kobject_uevent: unable to create netlink socket!\n"); 379 + return -ENODEV; 380 + } 381 + 382 + return 0; 383 + } 384 + 385 + postcore_initcall(kobject_uevent_init); 245 386 246 387 #endif /* CONFIG_HOTPLUG */
+2 -2
net/bluetooth/hci_sysfs.c
··· 78 78 }; 79 79 80 80 #ifdef CONFIG_HOTPLUG 81 - static int bt_hotplug(struct class_device *cdev, char **envp, int num_envp, char *buf, int size) 81 + static int bt_uevent(struct class_device *cdev, char **envp, int num_envp, char *buf, int size) 82 82 { 83 83 struct hci_dev *hdev = class_get_devdata(cdev); 84 84 int n, i = 0; ··· 107 107 .name = "bluetooth", 108 108 .release = bt_release, 109 109 #ifdef CONFIG_HOTPLUG 110 - .hotplug = bt_hotplug, 110 + .uevent = bt_uevent, 111 111 #endif 112 112 }; 113 113
+2 -2
net/bridge/br_sysfs_if.c
··· 248 248 if (err) 249 249 goto out2; 250 250 251 - kobject_hotplug(&p->kobj, KOBJ_ADD); 251 + kobject_uevent(&p->kobj, KOBJ_ADD); 252 252 return 0; 253 253 out2: 254 254 kobject_del(&p->kobj); ··· 260 260 { 261 261 pr_debug("br_sysfs_removeif\n"); 262 262 sysfs_remove_link(&p->br->ifobj, p->dev->name); 263 - kobject_hotplug(&p->kobj, KOBJ_REMOVE); 263 + kobject_uevent(&p->kobj, KOBJ_REMOVE); 264 264 kobject_del(&p->kobj); 265 265 } 266 266
+25 -51
net/core/net-sysfs.c
··· 84 84 return ret; 85 85 } 86 86 87 - /* generate a read-only network device class attribute */ 88 - #define NETDEVICE_ATTR(field, format_string) \ 89 - NETDEVICE_SHOW(field, format_string) \ 90 - static CLASS_DEVICE_ATTR(field, S_IRUGO, show_##field, NULL) \ 91 - 92 - NETDEVICE_ATTR(addr_len, fmt_dec); 93 - NETDEVICE_ATTR(iflink, fmt_dec); 94 - NETDEVICE_ATTR(ifindex, fmt_dec); 95 - NETDEVICE_ATTR(features, fmt_long_hex); 96 - NETDEVICE_ATTR(type, fmt_dec); 87 + NETDEVICE_SHOW(addr_len, fmt_dec); 88 + NETDEVICE_SHOW(iflink, fmt_dec); 89 + NETDEVICE_SHOW(ifindex, fmt_dec); 90 + NETDEVICE_SHOW(features, fmt_long_hex); 91 + NETDEVICE_SHOW(type, fmt_dec); 97 92 98 93 /* use same locking rules as GIFHWADDR ioctl's */ 99 94 static ssize_t format_addr(char *buf, const unsigned char *addr, int len) ··· 131 136 return -EINVAL; 132 137 } 133 138 134 - static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL); 135 - static CLASS_DEVICE_ATTR(broadcast, S_IRUGO, show_broadcast, NULL); 136 - static CLASS_DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL); 137 - 138 139 /* read-write attributes */ 139 140 NETDEVICE_SHOW(mtu, fmt_dec); 140 141 ··· 144 153 return netdev_store(dev, buf, len, change_mtu); 145 154 } 146 155 147 - static CLASS_DEVICE_ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu); 148 - 149 156 NETDEVICE_SHOW(flags, fmt_hex); 150 157 151 158 static int change_flags(struct net_device *net, unsigned long new_flags) ··· 155 166 { 156 167 return netdev_store(dev, buf, len, change_flags); 157 168 } 158 - 159 - static CLASS_DEVICE_ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags); 160 169 161 170 NETDEVICE_SHOW(tx_queue_len, fmt_ulong); 162 171 ··· 169 182 return netdev_store(dev, buf, len, change_tx_queue_len); 170 183 } 171 184 172 - static CLASS_DEVICE_ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, 173 - store_tx_queue_len); 174 - 175 185 NETDEVICE_SHOW(weight, fmt_dec); 176 186 177 187 static int change_weight(struct net_device *net, unsigned long new_weight) ··· 182 198 return netdev_store(dev, buf, len, change_weight); 183 199 } 184 200 185 - static CLASS_DEVICE_ATTR(weight, S_IRUGO | S_IWUSR, show_weight, 186 - store_weight); 187 - 188 - 189 - static struct class_device_attribute *net_class_attributes[] = { 190 - &class_device_attr_ifindex, 191 - &class_device_attr_iflink, 192 - &class_device_attr_addr_len, 193 - &class_device_attr_tx_queue_len, 194 - &class_device_attr_features, 195 - &class_device_attr_mtu, 196 - &class_device_attr_flags, 197 - &class_device_attr_weight, 198 - &class_device_attr_type, 199 - &class_device_attr_address, 200 - &class_device_attr_broadcast, 201 - &class_device_attr_carrier, 202 - NULL 201 + static struct class_device_attribute net_class_attributes[] = { 202 + __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), 203 + __ATTR(iflink, S_IRUGO, show_iflink, NULL), 204 + __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), 205 + __ATTR(features, S_IRUGO, show_features, NULL), 206 + __ATTR(type, S_IRUGO, show_type, NULL), 207 + __ATTR(address, S_IRUGO, show_address, NULL), 208 + __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), 209 + __ATTR(carrier, S_IRUGO, show_carrier, NULL), 210 + __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), 211 + __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), 212 + __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, 213 + store_tx_queue_len), 214 + __ATTR(weight, S_IRUGO | S_IWUSR, show_weight, store_weight), 215 + {} 203 216 }; 204 217 205 218 /* Show a given an attribute in the statistics group */ ··· 350 369 #endif 351 370 352 371 #ifdef CONFIG_HOTPLUG 353 - static int netdev_hotplug(struct class_device *cd, char **envp, 354 - int num_envp, char *buf, int size) 372 + static int netdev_uevent(struct class_device *cd, char **envp, 373 + int num_envp, char *buf, int size) 355 374 { 356 375 struct net_device *dev = to_net_dev(cd); 357 376 int i = 0; 358 377 int n; 359 378 360 - /* pass interface in env to hotplug. */ 379 + /* pass interface to uevent. */ 361 380 envp[i++] = buf; 362 381 n = snprintf(buf, size, "INTERFACE=%s", dev->name) + 1; 363 382 buf += n; ··· 388 407 static struct class net_class = { 389 408 .name = "net", 390 409 .release = netdev_release, 410 + .class_dev_attrs = net_class_attributes, 391 411 #ifdef CONFIG_HOTPLUG 392 - .hotplug = netdev_hotplug, 412 + .uevent = netdev_uevent, 393 413 #endif 394 414 }; 395 415 ··· 413 431 int netdev_register_sysfs(struct net_device *net) 414 432 { 415 433 struct class_device *class_dev = &(net->class_dev); 416 - int i; 417 - struct class_device_attribute *attr; 418 434 int ret; 419 435 420 436 class_dev->class = &net_class; ··· 421 441 strlcpy(class_dev->class_id, net->name, BUS_ID_SIZE); 422 442 if ((ret = class_device_register(class_dev))) 423 443 goto out; 424 - 425 - for (i = 0; (attr = net_class_attributes[i]) != NULL; i++) { 426 - if ((ret = class_device_create_file(class_dev, attr))) 427 - goto out_unreg; 428 - } 429 - 430 444 431 445 if (net->get_stats && 432 446 (ret = sysfs_create_group(&class_dev->kobj, &netstat_group)))
+61 -1
scripts/mod/file2alias.c
··· 16 16 * use either stdint.h or inttypes.h for the rest. */ 17 17 #if KERNEL_ELFCLASS == ELFCLASS32 18 18 typedef Elf32_Addr kernel_ulong_t; 19 + #define BITS_PER_LONG 32 19 20 #else 20 21 typedef Elf64_Addr kernel_ulong_t; 22 + #define BITS_PER_LONG 64 21 23 #endif 22 24 #ifdef __sun__ 23 25 #include <inttypes.h> ··· 37 35 * even potentially has different endianness and word sizes, since 38 36 * we handle those differences explicitly below */ 39 37 #include "../../include/linux/mod_devicetable.h" 38 + #include "../../include/linux/input.h" 40 39 41 40 #define ADD(str, sep, cond, field) \ 42 41 do { \ ··· 369 366 return 1; 370 367 } 371 368 369 + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 370 + 371 + static void do_input(char *alias, 372 + kernel_ulong_t *arr, unsigned int min, unsigned int max) 373 + { 374 + unsigned int i; 375 + for (i = min; i < max; i++) { 376 + if (arr[i/BITS_PER_LONG] & (1 << (i%BITS_PER_LONG))) 377 + sprintf(alias+strlen(alias), "%X,*", i); 378 + } 379 + } 380 + 381 + /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ 382 + static int do_input_entry(const char *filename, struct input_device_id *id, 383 + char *alias) 384 + { 385 + sprintf(alias, "input:"); 386 + 387 + ADD(alias, "b", id->flags&INPUT_DEVICE_ID_MATCH_BUS, id->id.bustype); 388 + ADD(alias, "v", id->flags&INPUT_DEVICE_ID_MATCH_VENDOR, id->id.vendor); 389 + ADD(alias, "p", id->flags&INPUT_DEVICE_ID_MATCH_PRODUCT, 390 + id->id.product); 391 + ADD(alias, "e", id->flags&INPUT_DEVICE_ID_MATCH_VERSION, 392 + id->id.version); 393 + 394 + sprintf(alias + strlen(alias), "-e*"); 395 + if (id->flags&INPUT_DEVICE_ID_MATCH_EVBIT) 396 + do_input(alias, id->evbit, 0, EV_MAX); 397 + sprintf(alias + strlen(alias), "k*"); 398 + if (id->flags&INPUT_DEVICE_ID_MATCH_KEYBIT) 399 + do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX); 400 + sprintf(alias + strlen(alias), "r*"); 401 + if (id->flags&INPUT_DEVICE_ID_MATCH_RELBIT) 402 + do_input(alias, id->relbit, 0, REL_MAX); 403 + sprintf(alias + strlen(alias), "a*"); 404 + if (id->flags&INPUT_DEVICE_ID_MATCH_ABSBIT) 405 + do_input(alias, id->absbit, 0, ABS_MAX); 406 + sprintf(alias + strlen(alias), "m*"); 407 + if (id->flags&INPUT_DEVICE_ID_MATCH_MSCIT) 408 + do_input(alias, id->mscbit, 0, MSC_MAX); 409 + sprintf(alias + strlen(alias), "l*"); 410 + if (id->flags&INPUT_DEVICE_ID_MATCH_LEDBIT) 411 + do_input(alias, id->ledbit, 0, LED_MAX); 412 + sprintf(alias + strlen(alias), "s*"); 413 + if (id->flags&INPUT_DEVICE_ID_MATCH_SNDBIT) 414 + do_input(alias, id->sndbit, 0, SND_MAX); 415 + sprintf(alias + strlen(alias), "f*"); 416 + if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT) 417 + do_input(alias, id->ffbit, 0, SND_MAX); 418 + sprintf(alias + strlen(alias), "w*"); 419 + if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT) 420 + do_input(alias, id->swbit, 0, SW_MAX); 421 + return 1; 422 + } 423 + 372 424 /* Ignore any prefix, eg. v850 prepends _ */ 373 425 static inline int sym_is(const char *symbol, const char *name) 374 426 { ··· 511 453 else if (sym_is(symname, "__mod_i2c_device_table")) 512 454 do_table(symval, sym->st_size, sizeof(struct i2c_device_id), 513 455 do_i2c_entry, mod); 514 - 456 + else if (sym_is(symname, "__mod_input_device_table")) 457 + do_table(symval, sym->st_size, sizeof(struct input_device_id), 458 + do_input_entry, mod); 515 459 } 516 460 517 461 /* Now add out buffered information to the generated C source */