Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133440
b: refs/heads/master
c: 49b420a
h: refs/heads/master
v: v3
  • Loading branch information
Ming Lei authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent d317c0d commit 2a3ef3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 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: 4a67a1bc0b3a0db017b560cee27370d141c58e25
refs/heads/master: 49b420a13ff95b449947181190b08367348e3e1b
5 changes: 5 additions & 0 deletions trunk/drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ extern void bus_remove_driver(struct device_driver *drv);

extern void driver_detach(struct device_driver *drv);
extern int driver_probe_device(struct device_driver *drv, struct device *dev);
static inline int driver_match_device(struct device_driver *drv,
struct device *dev)
{
return drv->bus->match && drv->bus->match(dev, drv);
}

extern void sysdev_shutdown(void);

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static ssize_t driver_bind(struct device_driver *drv,
int err = -ENODEV;

dev = bus_find_device_by_name(bus, NULL, buf);
if (dev && dev->driver == NULL) {
if (dev && dev->driver == NULL && driver_match_device(drv, dev)) {
if (dev->parent) /* Needed for USB */
down(&dev->parent->sem);
down(&dev->sem);
Expand Down
19 changes: 7 additions & 12 deletions trunk/drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,8 @@ int wait_for_device_probe(void)
* @drv: driver to bind a device to
* @dev: device to try to bind to the driver
*
* First, we call the bus's match function, if one present, which should
* compare the device IDs the driver supports with the device IDs of the
* device. Note we don't do this ourselves because we don't know the
* format of the ID structures, nor what is to be considered a match and
* what is not.
*
* This function returns 1 if a match is found, -ENODEV if the device is
* not registered, and 0 otherwise.
* This function returns -ENODEV if the device is not registered,
* 1 if the device is bound sucessfully and 0 otherwise.
*
* This function must be called with @dev->sem held. When called for a
* USB interface, @dev->parent->sem must be held as well.
Expand All @@ -207,21 +201,22 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)

if (!device_is_registered(dev))
return -ENODEV;
if (drv->bus->match && !drv->bus->match(dev, drv))
goto done;

pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
drv->bus->name, __func__, dev_name(dev), drv->name);

ret = really_probe(dev, drv);

done:
return ret;
}

static int __device_attach(struct device_driver *drv, void *data)
{
struct device *dev = data;

if (!driver_match_device(drv, dev))
return 0;

return driver_probe_device(drv, dev);
}

Expand Down Expand Up @@ -274,7 +269,7 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/

if (drv->bus->match && !drv->bus->match(dev, drv))
if (!driver_match_device(drv, dev))
return 0;

if (dev->parent) /* Needed for USB */
Expand Down

0 comments on commit 2a3ef3e

Please sign in to comment.