Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4036
b: refs/heads/master
c: afdce75
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Jun 30, 2005
1 parent fed9ef4 commit bf98ac8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 151ef38f7c0ec1b0420f04438b0316e3a30bf2e4
refs/heads/master: afdce75f1eaebcf358b7594ba7969aade105c3b0
1 change: 1 addition & 0 deletions trunk/drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern int bus_add_driver(struct device_driver *);
extern void bus_remove_driver(struct device_driver *);

extern void driver_detach(struct device_driver * drv);
extern int driver_probe_device(struct device_driver *, struct device *);

static inline struct class_device *to_class_dev(struct kobject *obj)
{
Expand Down
26 changes: 26 additions & 0 deletions trunk/drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,30 @@ static ssize_t driver_unbind(struct device_driver *drv,
}
static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);

/*
* Manually attach a device to a driver.
* Note: the driver must want to bind to the device,
* it is not possible to override the driver's id table.
*/
static ssize_t driver_bind(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 == NULL)) {
down(&dev->sem);
err = driver_probe_device(drv, dev);
up(&dev->sem);
put_device(dev);
}
return err;
}
static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);


static struct device * next_device(struct klist_iter * i)
{
Expand Down Expand Up @@ -425,6 +449,7 @@ int bus_add_driver(struct device_driver * drv)

driver_add_attrs(bus, drv);
driver_create_file(drv, &driver_attr_unbind);
driver_create_file(drv, &driver_attr_bind);
}
return error;
}
Expand All @@ -442,6 +467,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_bind);
driver_remove_file(drv, &driver_attr_unbind);
driver_remove_attrs(drv->bus, drv);
klist_remove(&drv->knode_bus);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void device_bind_driver(struct device * dev)
*
* This function must be called with @dev->sem held.
*/
static int driver_probe_device(struct device_driver * drv, struct device * dev)
int driver_probe_device(struct device_driver * drv, struct device * dev)
{
int ret = 0;

Expand Down

0 comments on commit bf98ac8

Please sign in to comment.