| .. | .. |
|---|
| 9 | 9 | */ |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | #include <linux/async.h> |
|---|
| 12 | +#include <linux/device/bus.h> |
|---|
| 12 | 13 | #include <linux/device.h> |
|---|
| 13 | 14 | #include <linux/module.h> |
|---|
| 14 | 15 | #include <linux/errno.h> |
|---|
| .. | .. |
|---|
| 226 | 227 | } |
|---|
| 227 | 228 | static DRIVER_ATTR_IGNORE_LOCKDEP(bind, S_IWUSR, NULL, bind_store); |
|---|
| 228 | 229 | |
|---|
| 229 | | -static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf) |
|---|
| 230 | +static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf) |
|---|
| 230 | 231 | { |
|---|
| 231 | | - return sprintf(buf, "%d\n", bus->p->drivers_autoprobe); |
|---|
| 232 | + return sysfs_emit(buf, "%d\n", bus->p->drivers_autoprobe); |
|---|
| 232 | 233 | } |
|---|
| 233 | 234 | |
|---|
| 234 | | -static ssize_t store_drivers_autoprobe(struct bus_type *bus, |
|---|
| 235 | +static ssize_t drivers_autoprobe_store(struct bus_type *bus, |
|---|
| 235 | 236 | const char *buf, size_t count) |
|---|
| 236 | 237 | { |
|---|
| 237 | 238 | if (buf[0] == '0') |
|---|
| .. | .. |
|---|
| 241 | 242 | return count; |
|---|
| 242 | 243 | } |
|---|
| 243 | 244 | |
|---|
| 244 | | -static ssize_t store_drivers_probe(struct bus_type *bus, |
|---|
| 245 | +static ssize_t drivers_probe_store(struct bus_type *bus, |
|---|
| 245 | 246 | const char *buf, size_t count) |
|---|
| 246 | 247 | { |
|---|
| 247 | 248 | struct device *dev; |
|---|
| .. | .. |
|---|
| 323 | 324 | * return to the caller and not iterate over any more devices. |
|---|
| 324 | 325 | */ |
|---|
| 325 | 326 | struct device *bus_find_device(struct bus_type *bus, |
|---|
| 326 | | - struct device *start, void *data, |
|---|
| 327 | | - int (*match)(struct device *dev, void *data)) |
|---|
| 327 | + struct device *start, const void *data, |
|---|
| 328 | + int (*match)(struct device *dev, const void *data)) |
|---|
| 328 | 329 | { |
|---|
| 329 | 330 | struct klist_iter i; |
|---|
| 330 | 331 | struct device *dev; |
|---|
| .. | .. |
|---|
| 341 | 342 | return dev; |
|---|
| 342 | 343 | } |
|---|
| 343 | 344 | EXPORT_SYMBOL_GPL(bus_find_device); |
|---|
| 344 | | - |
|---|
| 345 | | -static int match_name(struct device *dev, void *data) |
|---|
| 346 | | -{ |
|---|
| 347 | | - const char *name = data; |
|---|
| 348 | | - |
|---|
| 349 | | - return sysfs_streq(name, dev_name(dev)); |
|---|
| 350 | | -} |
|---|
| 351 | | - |
|---|
| 352 | | -/** |
|---|
| 353 | | - * bus_find_device_by_name - device iterator for locating a particular device of a specific name |
|---|
| 354 | | - * @bus: bus type |
|---|
| 355 | | - * @start: Device to begin with |
|---|
| 356 | | - * @name: name of the device to match |
|---|
| 357 | | - * |
|---|
| 358 | | - * This is similar to the bus_find_device() function above, but it handles |
|---|
| 359 | | - * searching by a name automatically, no need to write another strcmp matching |
|---|
| 360 | | - * function. |
|---|
| 361 | | - */ |
|---|
| 362 | | -struct device *bus_find_device_by_name(struct bus_type *bus, |
|---|
| 363 | | - struct device *start, const char *name) |
|---|
| 364 | | -{ |
|---|
| 365 | | - return bus_find_device(bus, start, (void *)name, match_name); |
|---|
| 366 | | -} |
|---|
| 367 | | -EXPORT_SYMBOL_GPL(bus_find_device_by_name); |
|---|
| 368 | 345 | |
|---|
| 369 | 346 | /** |
|---|
| 370 | 347 | * subsys_find_device_by_id - find a device with a specific enumeration number |
|---|
| .. | .. |
|---|
| 576 | 553 | driver_remove_file(drv, &driver_attr_unbind); |
|---|
| 577 | 554 | } |
|---|
| 578 | 555 | |
|---|
| 579 | | -static BUS_ATTR(drivers_probe, S_IWUSR, NULL, store_drivers_probe); |
|---|
| 580 | | -static BUS_ATTR(drivers_autoprobe, S_IWUSR | S_IRUGO, |
|---|
| 581 | | - show_drivers_autoprobe, store_drivers_autoprobe); |
|---|
| 556 | +static BUS_ATTR_WO(drivers_probe); |
|---|
| 557 | +static BUS_ATTR_RW(drivers_autoprobe); |
|---|
| 582 | 558 | |
|---|
| 583 | 559 | static int add_probe_files(struct bus_type *bus) |
|---|
| 584 | 560 | { |
|---|
| .. | .. |
|---|
| 645 | 621 | if (drv->bus->p->drivers_autoprobe) { |
|---|
| 646 | 622 | error = driver_attach(drv); |
|---|
| 647 | 623 | if (error) |
|---|
| 648 | | - goto out_unregister; |
|---|
| 624 | + goto out_del_list; |
|---|
| 649 | 625 | } |
|---|
| 650 | 626 | module_add_driver(drv->owner, drv); |
|---|
| 651 | 627 | |
|---|
| .. | .. |
|---|
| 672 | 648 | |
|---|
| 673 | 649 | return 0; |
|---|
| 674 | 650 | |
|---|
| 651 | +out_del_list: |
|---|
| 652 | + klist_del(&priv->knode_bus); |
|---|
| 675 | 653 | out_unregister: |
|---|
| 676 | 654 | kobject_put(&priv->kobj); |
|---|
| 677 | 655 | /* drv->p is freed in driver_release() */ |
|---|
| .. | .. |
|---|
| 806 | 784 | rc = kobject_synth_uevent(&bus->p->subsys.kobj, buf, count); |
|---|
| 807 | 785 | return rc ? rc : count; |
|---|
| 808 | 786 | } |
|---|
| 809 | | -static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); |
|---|
| 787 | +/* |
|---|
| 788 | + * "open code" the old BUS_ATTR() macro here. We want to use BUS_ATTR_WO() |
|---|
| 789 | + * here, but can not use it as earlier in the file we have |
|---|
| 790 | + * DEVICE_ATTR_WO(uevent), which would cause a clash with the with the store |
|---|
| 791 | + * function name. |
|---|
| 792 | + */ |
|---|
| 793 | +static struct bus_attribute bus_attr_uevent = __ATTR(uevent, S_IWUSR, NULL, |
|---|
| 794 | + bus_uevent_store); |
|---|
| 810 | 795 | |
|---|
| 811 | 796 | /** |
|---|
| 812 | 797 | * bus_register - register a driver-core subsystem |
|---|