/* When called for a USB interface, @dev->parent->sem must be held.  */
int device_attach(struct device *dev)
/* 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 {
		pm_runtime_get_noresume(dev);
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
		pm_runtime_put_sync(dev);
	}
	up(&dev->sem);
	return ret;
}