• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/base/

Lines Matching refs:bus

2  * bus.c - bus driver management
96 struct bus_type * bus = to_bus(kobj);
100 ret = bus_attr->show(bus, buf);
109 struct bus_type * bus = to_bus(kobj);
113 ret = bus_attr->store(bus, buf, count);
122 int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
125 if (get_bus(bus)) {
126 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
127 put_bus(bus);
133 void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
135 if (get_bus(bus)) {
136 sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
137 put_bus(bus);
146 static decl_subsys(bus, &ktype_bus, NULL);
163 struct bus_type *bus = get_bus(drv->bus);
167 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
177 put_bus(bus);
190 struct bus_type *bus = get_bus(drv->bus);
194 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
210 put_bus(bus);
215 static ssize_t show_drivers_autoprobe(struct bus_type *bus, char *buf)
217 return sprintf(buf, "%d\n", bus->drivers_autoprobe);
220 static ssize_t store_drivers_autoprobe(struct bus_type *bus,
224 bus->drivers_autoprobe = 0;
226 bus->drivers_autoprobe = 1;
230 static ssize_t store_drivers_probe(struct bus_type *bus,
235 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
252 * @bus: bus type.
257 * Iterate over @bus's list of devices, and call @fn for each,
270 int bus_for_each_dev(struct bus_type * bus, struct device * start,
277 if (!bus)
280 klist_iter_init_node(&bus->klist_devices, &i,
290 * @bus: bus type
303 struct device * bus_find_device(struct bus_type *bus,
310 if (!bus)
313 klist_iter_init_node(&bus->klist_devices, &i,
331 * @bus: bus we're dealing with.
337 * We iterate over each driver that belongs to @bus, and call
349 int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
356 if (!bus)
359 klist_iter_init_node(&bus->klist_drivers, &i,
367 static int device_add_attrs(struct bus_type *bus, struct device *dev)
372 if (!bus->dev_attrs)
375 for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
376 error = device_create_file(dev,&bus->dev_attrs[i]);
379 device_remove_file(dev, &bus->dev_attrs[i]);
386 static void device_remove_attrs(struct bus_type * bus, struct device * dev)
390 if (bus->dev_attrs) {
391 for (i = 0; attr_name(bus->dev_attrs[i]); i++)
392 device_remove_file(dev,&bus->dev_attrs[i]);
400 &dev->bus->subsys.kobj, "bus");
405 sysfs_remove_link(&dev->kobj, "bus");
413 * bus_add_device - add device to bus
416 * - Add the device to its bus's list of devices.
417 * - Create link to device's bus.
421 struct bus_type * bus = get_bus(dev->bus);
424 if (bus) {
425 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
426 error = device_add_attrs(bus, dev);
429 error = sysfs_create_link(&bus->devices.kobj,
434 &dev->bus->subsys.kobj, "subsystem");
446 sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
448 device_remove_attrs(bus, dev);
450 put_bus(dev->bus);
455 * bus_attach_device - add device to bus
458 * - Add device to bus's list of devices.
463 struct bus_type *bus = dev->bus;
466 if (bus) {
468 if (bus->drivers_autoprobe)
472 klist_add_tail(&dev->knode_bus, &bus->klist_devices);
479 * bus_remove_device - remove device from bus
482 * - Remove symlink from bus's directory.
483 * - Delete device from bus's list.
489 if (dev->bus) {
492 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
493 device_remove_attrs(dev->bus, dev);
498 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
500 put_bus(dev->bus);
504 static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv)
509 if (bus->drv_attrs) {
510 for (i = 0; attr_name(bus->drv_attrs[i]); i++) {
511 error = driver_create_file(drv, &bus->drv_attrs[i]);
520 driver_remove_file(drv, &bus->drv_attrs[i]);
525 static void driver_remove_attrs(struct bus_type * bus, struct device_driver * drv)
529 if (bus->drv_attrs) {
530 for (i = 0; attr_name(bus->drv_attrs[i]); i++)
531 driver_remove_file(drv, &bus->drv_attrs[i]);
559 static int add_probe_files(struct bus_type *bus)
563 bus->drivers_probe_attr.attr.name = "drivers_probe";
564 bus->drivers_probe_attr.attr.mode = S_IWUSR;
565 bus->drivers_probe_attr.attr.owner = bus->owner;
566 bus->drivers_probe_attr.store = store_drivers_probe;
567 retval = bus_create_file(bus, &bus->drivers_probe_attr);
571 bus->drivers_autoprobe_attr.attr.name = "drivers_autoprobe";
572 bus->drivers_autoprobe_attr.attr.mode = S_IWUSR | S_IRUGO;
573 bus->drivers_autoprobe_attr.attr.owner = bus->owner;
574 bus->drivers_autoprobe_attr.show = show_drivers_autoprobe;
575 bus->drivers_autoprobe_attr.store = store_drivers_autoprobe;
576 retval = bus_create_file(bus, &bus->drivers_autoprobe_attr);
578 bus_remove_file(bus, &bus->drivers_probe_attr);
583 static void remove_probe_files(struct bus_type *bus)
585 bus_remove_file(bus, &bus->drivers_autoprobe_attr);
586 bus_remove_file(bus, &bus->drivers_probe_attr);
591 static inline int add_probe_files(struct bus_type *bus) { return 0; }
592 static inline void remove_probe_files(struct bus_type *bus) {}
596 * bus_add_driver - Add a driver to the bus.
602 struct bus_type * bus = get_bus(drv->bus);
605 if (!bus)
608 pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
612 drv->kobj.kset = &bus->drivers;
616 if (drv->bus->drivers_autoprobe) {
621 klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
624 error = driver_add_attrs(bus, drv);
641 put_bus(bus);
646 * bus_remove_driver - delete driver from bus's knowledge.
650 * it from its bus's list of drivers. Finally, we drop the reference
651 * to the bus we took in bus_add_driver().
656 if (!drv->bus)
660 driver_remove_attrs(drv->bus, drv);
662 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
666 put_bus(drv->bus);
687 * bus_rescan_devices - rescan devices on the bus for possible drivers
688 * @bus: the bus to scan.
690 * This function will look for devices on the bus with no driver
694 int bus_rescan_devices(struct bus_type * bus)
696 return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
721 struct bus_type *get_bus(struct bus_type *bus)
723 return bus ? container_of(subsys_get(&bus->subsys),
727 void put_bus(struct bus_type * bus)
729 subsys_put(&bus->subsys);
734 * find_bus - locate bus by name.
735 * @name: name of bus.
738 * find a bus by name. Return bus if found.
740 * Note that kset_find_obj increments bus' reference count.
745 * bus_add_attrs - Add default attributes for this bus.
746 * @bus: Bus that has just been registered.
749 static int bus_add_attrs(struct bus_type * bus)
754 if (bus->bus_attrs) {
755 for (i = 0; attr_name(bus->bus_attrs[i]); i++) {
756 if ((error = bus_create_file(bus,&bus->bus_attrs[i])))
764 bus_remove_file(bus,&bus->bus_attrs[i]);
768 static void bus_remove_attrs(struct bus_type * bus)
772 if (bus->bus_attrs) {
773 for (i = 0; attr_name(bus->bus_attrs[i]); i++)
774 bus_remove_file(bus,&bus->bus_attrs[i]);
793 * bus_register - register a bus with the system.
794 * @bus: bus.
796 * Once we have that, we registered the bus with the kobject
798 * the devices and drivers that belong to the bus.
800 int bus_register(struct bus_type * bus)
804 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
806 retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
810 subsys_set_kset(bus, bus_subsys);
811 retval = subsystem_register(&bus->subsys);
815 kobject_set_name(&bus->devices.kobj, "devices");
816 bus->devices.kobj.parent = &bus->subsys.kobj;
817 retval = kset_register(&bus->devices);
821 kobject_set_name(&bus->drivers.kobj, "drivers");
822 bus->drivers.kobj.parent = &bus->subsys.kobj;
823 bus->drivers.ktype = &ktype_driver;
824 retval = kset_register(&bus->drivers);
828 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
829 klist_init(&bus->klist_drivers, NULL, NULL);
831 bus->drivers_autoprobe = 1;
832 retval = add_probe_files(bus);
836 retval = bus_add_attrs(bus);
840 pr_debug("bus type '%s' registered\n", bus->name);
844 remove_probe_files(bus);
846 kset_unregister(&bus->drivers);
848 kset_unregister(&bus->devices);
850 subsystem_unregister(&bus->subsys);
856 * bus_unregister - remove a bus from the system
857 * @bus: bus.
859 * Unregister the child subsystems and the bus itself.
862 void bus_unregister(struct bus_type * bus)
864 pr_debug("bus %s: unregistering\n", bus->name);
865 bus_remove_attrs(bus);
866 remove_probe_files(bus);
867 kset_unregister(&bus->drivers);
868 kset_unregister(&bus->devices);
869 subsystem_unregister(&bus->subsys);
872 int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
874 return blocking_notifier_chain_register(&bus->bus_notifier, nb);
878 int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
880 return blocking_notifier_chain_unregister(&bus->bus_notifier, nb);