Exemple #1
0
/**
 * device_attach - try to attach device to a driver.
 * @dev: device.
 *
 * Walk the list of drivers that the bus has and call
 * driver_probe_device() for each pair. If a compatible
 * pair is found, break out and return.
 *
 * Returns 1 if the device was bound to a driver;
 * 0 if no matching driver was found;
 * -ENODEV if the device is not registered.
 *
 * When called for a USB interface, @dev->parent lock must be held.
 */
int device_attach(struct device *dev)
{
	int ret = 0;

	device_lock(dev);
	if (dev->driver) {
		if (klist_node_attached(&dev->p->knode_driver)) {
			ret = 1;
			goto out_unlock;
		}
		ret = device_bind_driver(dev);
		if (ret == 0)
			ret = 1;
		else {
			dev->driver = NULL;
			ret = 0;
		}
	} else {
		pm_runtime_get_noresume(dev);
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
		pm_runtime_put_sync(dev);
	}
out_unlock:
	device_unlock(dev);
	return ret;
}
Exemple #2
0
static int ide_drivers_show(struct seq_file *s, void *p)
{
    int err;

    err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver);
    if (err < 0)
        printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n",
               __func__, err);
    return 0;
}
Exemple #3
0
static int proc_read_drivers(char *buf, char **start, off_t pos,
                             int count, int *eof, void *data)
{
    char *p = buf;

    bus_for_each_drv(&pcmcia_bus_type, NULL,
                     (void *) &p, proc_read_drivers_callback);

    return (p - buf);
}
Exemple #4
0
/**
 *	device_attach - try to attach device to a driver.
 *	@dev:	device.
 *
 *	Walk the list of drivers that the bus has and call
 *	driver_probe_device() for each pair. If a compatible
 *	pair is found, break out and return.
 *
 *	Returns 1 if the device was bound to a driver;
 *	0 if no matching device was found; error code otherwise.
 *
 *	When called for a USB interface, @dev->parent->sem must be held.
 */
int device_attach(struct device * dev)
{
	int ret = 0;

	down(&dev->sem);
	if (dev->driver) {
		device_bind_driver(dev);
		ret = 1;
	} else
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
	up(&dev->sem);
	return ret;
}
Exemple #5
0
/**
 * device_attach - try to attach device to a driver.
 * @dev: device.
 *
 * Walk the list of drivers that the bus has and call
 * driver_probe_device() for each pair. If a compatible
 * pair is found, break out and return.
 *
 * Returns 1 if the device was bound to a driver;
 * 0 if no matching device was found;
 * -ENODEV if the device is not registered.
 *
 * When called for a USB interface, @dev->parent->sem must be held.
 */
int device_attach(struct device *dev)
{
	int ret = 0;

	down(&dev->sem);
	if (dev->driver) {
		ret = device_bind_driver(dev);
		if (ret == 0)
			ret = 1;
		else {
			dev->driver = NULL;
			ret = 0;
		}
	} else {
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
	}
	up(&dev->sem);
	return ret;
}
Exemple #6
0
/**
 * device_attach - try to attach device to a driver.
 * @dev: device.
 *
 * Walk the list of drivers that the bus has and call
 * driver_probe_device() for each pair. If a compatible
 * pair is found, break out and return.
 *
 * Returns 1 if the device was bound to a driver;
 * 0 if no matching device was found;
 * -ENODEV if the device is not registered.
 *
 * When called for a USB interface, @dev->parent->sem must be held.
 */
int device_attach(struct device *dev)  /* 将设备绑定到它的驱动程序上*/
{
	int ret = 0;

	down(&dev->sem);
	if (dev->driver) {   /* 如果dev->driver不为空,表明当前设备dev已经和它的驱动程序进行了绑定*/ 
		ret = device_bind_driver(dev);/* 则调用该函数在sysfs文件树中建立与其驱动程序之间的互联关系 */
		if (ret == 0)
			ret = 1;
		else {
			dev->driver = NULL;  /* 否则设置设备的驱动为空 */
			ret = 0;
		}
	} else { /* 否则dev->driver = NULL,则表明当前设备对象dev还没有和它的驱动程序绑定,此时需要遍
	                 历dev所在总线dev->bus上挂载的所有驱动程序对象 */
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);  /* 遍历挂在总线上的所有驱动对象drv,调用__device_attach进行绑定*/
	}
	up(&dev->sem);
	return ret;
}
Exemple #7
0
/**
 * device_attach - try to attach device to a driver.
 * @dev: device.
 *
 * Walk the list of drivers that the bus has and call
 * driver_probe_device() for each pair. If a compatible
 * pair is found, break out and return.
 *
 * Returns 1 if the device was bound to a driver;
 * 0 if no matching driver was found;
 * -ENODEV if the device is not registered.
 *
 * When called for a USB interface, @dev->parent->mutex must be held.
 */
int device_attach(struct device *dev)
{
	int ret = 0;

	mutex_lock(&dev->mutex);
	if (dev->driver) {
		ret = device_bind_driver(dev);
		if (ret == 0)
			ret = 1;
		else {
			dev->driver = NULL;
			ret = 0;
		}
	} else {
		pm_runtime_get_noresume(dev);
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
		pm_runtime_put_sync(dev);
	}
	mutex_unlock(&dev->mutex);
	return ret;
}
Exemple #8
0
static int ide_drivers_show(struct seq_file *s, void *p)
{
	bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver);
	return 0;
}