*参照元 [#dd4098e2] #backlinks *説明 [#cd7d4a9b] -パス: [[linux-2.6.33/drivers/base/dd.c]] -FIXME: これは何? --説明 **引数 [#acb3f0cc] -struct device *dev -- --[[linux-2.6.33/device]] **返り値 [#jf7e042a] -int --デバイスを登録できたか否かを返す。詳細はコメントを参照。 --0: 登録すべきデバイスがなかった。 --1: デバイスを登録した。 --(-ENODEV): (恐らく何らかのエラーで)デバイスが登録されなかった。 **参考 [#s325f8d4] *実装 [#o5f0faa7] /** * 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->sem must be held. */ int device_attach(struct device *dev) { int ret = 0; down(&dev->sem); - --[[linux-2.6.33/down()]] if (dev->driver) { ret = device_bind_driver(dev); if (ret == 0) ret = 1; else { dev->driver = NULL; ret = 0; } - --[[linux-2.6.33/device_bind_driver()]] } else { pm_runtime_get_noresume(dev); - --[[linux-2.6.33/pm_runtime_get_noresume()]] ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); - --[[linux-2.6.33/bus_for_each_drv()]] --[[linux-2.6.33/__device_attach()]] pm_runtime_put_sync(dev); } - --[[linux-2.6.33/pm_runtime_get_noresume()]] --[[linux-2.6.33/bus_for_each_drv()]] --[[linux-2.6.33/pm_runtime_put_sync()]] up(&dev->sem); - --[[linux-2.6.33/up()]] return ret; } EXPORT_SYMBOL_GPL(device_attach); - --[[linux-2.6.33/EXPORT_SYMBOL_GPL()]] *コメント [#q04a2e3e]