Lines Matching refs:dev
62 struct device *dev; in deferred_probe_work_func() local
79 typeof(*dev->p), deferred_probe); in deferred_probe_work_func()
80 dev = private->device; in deferred_probe_work_func()
83 get_device(dev); in deferred_probe_work_func()
98 device_pm_move_last(dev); in deferred_probe_work_func()
101 dev_dbg(dev, "Retrying from deferred list\n"); in deferred_probe_work_func()
102 bus_probe_device(dev); in deferred_probe_work_func()
106 put_device(dev); in deferred_probe_work_func()
112 static void driver_deferred_probe_add(struct device *dev) in driver_deferred_probe_add() argument
115 if (list_empty(&dev->p->deferred_probe)) { in driver_deferred_probe_add()
116 dev_dbg(dev, "Added to deferred list\n"); in driver_deferred_probe_add()
117 list_add_tail(&dev->p->deferred_probe, &deferred_probe_pending_list); in driver_deferred_probe_add()
122 void driver_deferred_probe_del(struct device *dev) in driver_deferred_probe_del() argument
125 if (!list_empty(&dev->p->deferred_probe)) { in driver_deferred_probe_del()
126 dev_dbg(dev, "Removed from deferred list\n"); in driver_deferred_probe_del()
127 list_del_init(&dev->p->deferred_probe); in driver_deferred_probe_del()
195 static void driver_bound(struct device *dev) in driver_bound() argument
197 if (klist_node_attached(&dev->p->knode_driver)) { in driver_bound()
199 __func__, kobject_name(&dev->kobj)); in driver_bound()
203 pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->driver->name, in driver_bound()
204 __func__, dev_name(dev)); in driver_bound()
206 klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); in driver_bound()
212 driver_deferred_probe_del(dev); in driver_bound()
215 if (dev->bus) in driver_bound()
216 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in driver_bound()
217 BUS_NOTIFY_BOUND_DRIVER, dev); in driver_bound()
220 static int driver_sysfs_add(struct device *dev) in driver_sysfs_add() argument
224 if (dev->bus) in driver_sysfs_add()
225 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in driver_sysfs_add()
226 BUS_NOTIFY_BIND_DRIVER, dev); in driver_sysfs_add()
228 ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj, in driver_sysfs_add()
229 kobject_name(&dev->kobj)); in driver_sysfs_add()
231 ret = sysfs_create_link(&dev->kobj, &dev->driver->p->kobj, in driver_sysfs_add()
234 sysfs_remove_link(&dev->driver->p->kobj, in driver_sysfs_add()
235 kobject_name(&dev->kobj)); in driver_sysfs_add()
240 static void driver_sysfs_remove(struct device *dev) in driver_sysfs_remove() argument
242 struct device_driver *drv = dev->driver; in driver_sysfs_remove()
245 sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj)); in driver_sysfs_remove()
246 sysfs_remove_link(&dev->kobj, "driver"); in driver_sysfs_remove()
264 int device_bind_driver(struct device *dev) in device_bind_driver() argument
268 ret = driver_sysfs_add(dev); in device_bind_driver()
270 driver_bound(dev); in device_bind_driver()
278 static int really_probe(struct device *dev, struct device_driver *drv) in really_probe() argument
285 drv->bus->name, __func__, drv->name, dev_name(dev)); in really_probe()
286 WARN_ON(!list_empty(&dev->devres_head)); in really_probe()
288 dev->driver = drv; in really_probe()
291 ret = pinctrl_bind_pins(dev); in really_probe()
295 if (driver_sysfs_add(dev)) { in really_probe()
297 __func__, dev_name(dev)); in really_probe()
301 if (dev->pm_domain && dev->pm_domain->activate) { in really_probe()
302 ret = dev->pm_domain->activate(dev); in really_probe()
313 devices_kset_move_last(dev); in really_probe()
315 if (dev->bus->probe) { in really_probe()
316 ret = dev->bus->probe(dev); in really_probe()
320 ret = drv->probe(dev); in really_probe()
325 pinctrl_init_done(dev); in really_probe()
327 if (dev->pm_domain && dev->pm_domain->sync) in really_probe()
328 dev->pm_domain->sync(dev); in really_probe()
330 driver_bound(dev); in really_probe()
333 drv->bus->name, __func__, dev_name(dev), drv->name); in really_probe()
337 devres_release_all(dev); in really_probe()
338 driver_sysfs_remove(dev); in really_probe()
339 dev->driver = NULL; in really_probe()
340 dev_set_drvdata(dev, NULL); in really_probe()
341 if (dev->pm_domain && dev->pm_domain->dismiss) in really_probe()
342 dev->pm_domain->dismiss(dev); in really_probe()
347 dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name); in really_probe()
348 driver_deferred_probe_add(dev); in really_probe()
356 drv->name, dev_name(dev), ret); in really_probe()
362 drv->name, dev_name(dev), ret); in really_probe()
415 int driver_probe_device(struct device_driver *drv, struct device *dev) in driver_probe_device() argument
419 if (!device_is_registered(dev)) in driver_probe_device()
423 drv->bus->name, __func__, dev_name(dev), drv->name); in driver_probe_device()
425 if (dev->parent) in driver_probe_device()
426 pm_runtime_get_sync(dev->parent); in driver_probe_device()
428 pm_runtime_barrier(dev); in driver_probe_device()
429 ret = really_probe(dev, drv); in driver_probe_device()
430 pm_request_idle(dev); in driver_probe_device()
432 if (dev->parent) in driver_probe_device()
433 pm_runtime_put(dev->parent); in driver_probe_device()
456 struct device *dev; member
491 struct device *dev = data->dev; in __device_attach_driver() local
500 if (dev->driver) in __device_attach_driver()
503 if (!driver_match_device(drv, dev)) in __device_attach_driver()
514 return driver_probe_device(drv, dev); in __device_attach_driver()
519 struct device *dev = _dev; in __device_attach_async_helper() local
521 .dev = dev, in __device_attach_async_helper()
526 device_lock(dev); in __device_attach_async_helper()
528 if (dev->parent) in __device_attach_async_helper()
529 pm_runtime_get_sync(dev->parent); in __device_attach_async_helper()
531 bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver); in __device_attach_async_helper()
532 dev_dbg(dev, "async probe completed\n"); in __device_attach_async_helper()
534 pm_request_idle(dev); in __device_attach_async_helper()
536 if (dev->parent) in __device_attach_async_helper()
537 pm_runtime_put(dev->parent); in __device_attach_async_helper()
539 device_unlock(dev); in __device_attach_async_helper()
541 put_device(dev); in __device_attach_async_helper()
544 static int __device_attach(struct device *dev, bool allow_async) in __device_attach() argument
548 device_lock(dev); in __device_attach()
549 if (dev->driver) { in __device_attach()
550 if (klist_node_attached(&dev->p->knode_driver)) { in __device_attach()
554 ret = device_bind_driver(dev); in __device_attach()
558 dev->driver = NULL; in __device_attach()
563 .dev = dev, in __device_attach()
568 if (dev->parent) in __device_attach()
569 pm_runtime_get_sync(dev->parent); in __device_attach()
571 ret = bus_for_each_drv(dev->bus, NULL, &data, in __device_attach()
581 dev_dbg(dev, "scheduling asynchronous probe\n"); in __device_attach()
582 get_device(dev); in __device_attach()
583 async_schedule(__device_attach_async_helper, dev); in __device_attach()
585 pm_request_idle(dev); in __device_attach()
588 if (dev->parent) in __device_attach()
589 pm_runtime_put(dev->parent); in __device_attach()
592 device_unlock(dev); in __device_attach()
610 int device_attach(struct device *dev) in device_attach() argument
612 return __device_attach(dev, false); in device_attach()
616 void device_initial_probe(struct device *dev) in device_initial_probe() argument
618 __device_attach(dev, true); in device_initial_probe()
621 static int __driver_attach(struct device *dev, void *data) in __driver_attach() argument
635 if (!driver_match_device(drv, dev)) in __driver_attach()
638 if (dev->parent) /* Needed for USB */ in __driver_attach()
639 device_lock(dev->parent); in __driver_attach()
640 device_lock(dev); in __driver_attach()
641 if (!dev->driver) in __driver_attach()
642 driver_probe_device(drv, dev); in __driver_attach()
643 device_unlock(dev); in __driver_attach()
644 if (dev->parent) in __driver_attach()
645 device_unlock(dev->parent); in __driver_attach()
669 static void __device_release_driver(struct device *dev) in __device_release_driver() argument
673 drv = dev->driver; in __device_release_driver()
678 pm_runtime_get_sync(dev); in __device_release_driver()
680 driver_sysfs_remove(dev); in __device_release_driver()
682 if (dev->bus) in __device_release_driver()
683 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in __device_release_driver()
685 dev); in __device_release_driver()
687 pm_runtime_put_sync(dev); in __device_release_driver()
689 if (dev->bus && dev->bus->remove) in __device_release_driver()
690 dev->bus->remove(dev); in __device_release_driver()
692 drv->remove(dev); in __device_release_driver()
693 devres_release_all(dev); in __device_release_driver()
694 dev->driver = NULL; in __device_release_driver()
695 dev_set_drvdata(dev, NULL); in __device_release_driver()
696 if (dev->pm_domain && dev->pm_domain->dismiss) in __device_release_driver()
697 dev->pm_domain->dismiss(dev); in __device_release_driver()
699 klist_remove(&dev->p->knode_driver); in __device_release_driver()
700 if (dev->bus) in __device_release_driver()
701 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in __device_release_driver()
703 dev); in __device_release_driver()
715 void device_release_driver(struct device *dev) in device_release_driver() argument
722 device_lock(dev); in device_release_driver()
723 __device_release_driver(dev); in device_release_driver()
724 device_unlock(dev); in device_release_driver()
735 struct device *dev; in driver_detach() local
746 dev = dev_prv->device; in driver_detach()
747 get_device(dev); in driver_detach()
750 if (dev->parent) /* Needed for USB */ in driver_detach()
751 device_lock(dev->parent); in driver_detach()
752 device_lock(dev); in driver_detach()
753 if (dev->driver == drv) in driver_detach()
754 __device_release_driver(dev); in driver_detach()
755 device_unlock(dev); in driver_detach()
756 if (dev->parent) in driver_detach()
757 device_unlock(dev->parent); in driver_detach()
758 put_device(dev); in driver_detach()