Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4035
b: refs/heads/master
c: 151ef38
h: refs/heads/master
i:
  4033: a877352
  4031: 072f9b8
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Jun 30, 2005
1 parent f1bf24f commit fed9ef4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0edb586049e57c56e625536476931117a57671e9
refs/heads/master: 151ef38f7c0ec1b0420f04438b0316e3a30bf2e4
30 changes: 30 additions & 0 deletions trunk/drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,34 @@ static struct kobj_type ktype_bus = {
decl_subsys(bus, &ktype_bus, NULL);


/* Manually detach a device from it's associated driver. */
static int driver_helper(struct device *dev, void *data)
{
const char *name = data;

if (strcmp(name, dev->bus_id) == 0)
return 1;
return 0;
}

static ssize_t driver_unbind(struct device_driver *drv,
const char *buf, size_t count)
{
struct bus_type *bus = get_bus(drv->bus);
struct device *dev;
int err = -ENODEV;

dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
if ((dev) &&
(dev->driver == drv)) {
device_release_driver(dev);
err = count;
}
return err;
}
static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);


static struct device * next_device(struct klist_iter * i)
{
struct klist_node * n = klist_next(i);
Expand Down Expand Up @@ -396,6 +424,7 @@ int bus_add_driver(struct device_driver * drv)
module_add_driver(drv->owner, drv);

driver_add_attrs(bus, drv);
driver_create_file(drv, &driver_attr_unbind);
}
return error;
}
Expand All @@ -413,6 +442,7 @@ int bus_add_driver(struct device_driver * drv)
void bus_remove_driver(struct device_driver * drv)
{
if (drv->bus) {
driver_remove_file(drv, &driver_attr_unbind);
driver_remove_attrs(drv->bus, drv);
klist_remove(&drv->knode_bus);
pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
Expand Down

0 comments on commit fed9ef4

Please sign in to comment.