Lines Matching refs:dev

72 	struct device *dev;  in deferred_probe_work_func()  local
89 typeof(*dev->p), deferred_probe); in deferred_probe_work_func()
90 dev = private->device; in deferred_probe_work_func()
93 get_device(dev); in deferred_probe_work_func()
107 device_pm_move_to_tail(dev); in deferred_probe_work_func()
109 dev_dbg(dev, "Retrying from deferred list\n"); in deferred_probe_work_func()
110 bus_probe_device(dev); in deferred_probe_work_func()
113 put_device(dev); in deferred_probe_work_func()
119 static void driver_deferred_probe_add(struct device *dev) in driver_deferred_probe_add() argument
122 if (list_empty(&dev->p->deferred_probe)) { in driver_deferred_probe_add()
123 dev_dbg(dev, "Added to deferred list\n"); in driver_deferred_probe_add()
124 list_add_tail(&dev->p->deferred_probe, &deferred_probe_pending_list); in driver_deferred_probe_add()
129 void driver_deferred_probe_del(struct device *dev) in driver_deferred_probe_del() argument
132 if (!list_empty(&dev->p->deferred_probe)) { in driver_deferred_probe_del()
133 dev_dbg(dev, "Removed from deferred list\n"); in driver_deferred_probe_del()
134 list_del_init(&dev->p->deferred_probe); in driver_deferred_probe_del()
242 int driver_deferred_probe_check_state(struct device *dev) in driver_deferred_probe_check_state() argument
246 dev_WARN(dev, "deferred probe timeout, ignoring dependency"); in driver_deferred_probe_check_state()
249 dev_warn(dev, "ignoring dependency for device, assuming no driver"); in driver_deferred_probe_check_state()
316 bool device_is_bound(struct device *dev) in device_is_bound() argument
318 return dev->p && klist_node_attached(&dev->p->knode_driver); in device_is_bound()
321 static void driver_bound(struct device *dev) in driver_bound() argument
323 if (device_is_bound(dev)) { in driver_bound()
325 __func__, kobject_name(&dev->kobj)); in driver_bound()
329 pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->driver->name, in driver_bound()
330 __func__, dev_name(dev)); in driver_bound()
332 klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); in driver_bound()
333 device_links_driver_bound(dev); in driver_bound()
335 device_pm_check_callbacks(dev); in driver_bound()
341 driver_deferred_probe_del(dev); in driver_bound()
344 if (dev->bus) in driver_bound()
345 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in driver_bound()
346 BUS_NOTIFY_BOUND_DRIVER, dev); in driver_bound()
348 kobject_uevent(&dev->kobj, KOBJ_BIND); in driver_bound()
351 static ssize_t coredump_store(struct device *dev, struct device_attribute *attr, in coredump_store() argument
354 device_lock(dev); in coredump_store()
355 dev->driver->coredump(dev); in coredump_store()
356 device_unlock(dev); in coredump_store()
362 static int driver_sysfs_add(struct device *dev) in driver_sysfs_add() argument
366 if (dev->bus) in driver_sysfs_add()
367 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in driver_sysfs_add()
368 BUS_NOTIFY_BIND_DRIVER, dev); in driver_sysfs_add()
370 ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj, in driver_sysfs_add()
371 kobject_name(&dev->kobj)); in driver_sysfs_add()
375 ret = sysfs_create_link(&dev->kobj, &dev->driver->p->kobj, in driver_sysfs_add()
380 if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump || in driver_sysfs_add()
381 !device_create_file(dev, &dev_attr_coredump)) in driver_sysfs_add()
384 sysfs_remove_link(&dev->kobj, "driver"); in driver_sysfs_add()
387 sysfs_remove_link(&dev->driver->p->kobj, in driver_sysfs_add()
388 kobject_name(&dev->kobj)); in driver_sysfs_add()
394 static void driver_sysfs_remove(struct device *dev) in driver_sysfs_remove() argument
396 struct device_driver *drv = dev->driver; in driver_sysfs_remove()
400 device_remove_file(dev, &dev_attr_coredump); in driver_sysfs_remove()
401 sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj)); in driver_sysfs_remove()
402 sysfs_remove_link(&dev->kobj, "driver"); in driver_sysfs_remove()
420 int device_bind_driver(struct device *dev) in device_bind_driver() argument
424 ret = driver_sysfs_add(dev); in device_bind_driver()
426 driver_bound(dev); in device_bind_driver()
427 else if (dev->bus) in device_bind_driver()
428 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in device_bind_driver()
429 BUS_NOTIFY_DRIVER_NOT_BOUND, dev); in device_bind_driver()
437 static void driver_deferred_probe_add_trigger(struct device *dev, in driver_deferred_probe_add_trigger() argument
440 driver_deferred_probe_add(dev); in driver_deferred_probe_add_trigger()
446 static int really_probe(struct device *dev, struct device_driver *drv) in really_probe() argument
459 dev_dbg(dev, "Driver %s force probe deferral\n", drv->name); in really_probe()
460 driver_deferred_probe_add(dev); in really_probe()
464 ret = device_links_check_suppliers(dev); in really_probe()
466 driver_deferred_probe_add_trigger(dev, local_trigger_count); in really_probe()
472 drv->bus->name, __func__, drv->name, dev_name(dev)); in really_probe()
473 WARN_ON(!list_empty(&dev->devres_head)); in really_probe()
476 dev->driver = drv; in really_probe()
479 ret = pinctrl_bind_pins(dev); in really_probe()
483 ret = dma_configure(dev); in really_probe()
487 if (driver_sysfs_add(dev)) { in really_probe()
489 __func__, dev_name(dev)); in really_probe()
493 if (dev->pm_domain && dev->pm_domain->activate) { in really_probe()
494 ret = dev->pm_domain->activate(dev); in really_probe()
499 if (dev->bus->probe) { in really_probe()
500 ret = dev->bus->probe(dev); in really_probe()
504 ret = drv->probe(dev); in really_probe()
512 if (dev->bus->remove) in really_probe()
513 dev->bus->remove(dev); in really_probe()
515 drv->remove(dev); in really_probe()
517 devres_release_all(dev); in really_probe()
518 driver_sysfs_remove(dev); in really_probe()
519 dev->driver = NULL; in really_probe()
520 dev_set_drvdata(dev, NULL); in really_probe()
521 if (dev->pm_domain && dev->pm_domain->dismiss) in really_probe()
522 dev->pm_domain->dismiss(dev); in really_probe()
523 pm_runtime_reinit(dev); in really_probe()
528 pinctrl_init_done(dev); in really_probe()
530 if (dev->pm_domain && dev->pm_domain->sync) in really_probe()
531 dev->pm_domain->sync(dev); in really_probe()
533 driver_bound(dev); in really_probe()
536 drv->bus->name, __func__, dev_name(dev), drv->name); in really_probe()
540 dma_deconfigure(dev); in really_probe()
542 if (dev->bus) in really_probe()
543 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in really_probe()
544 BUS_NOTIFY_DRIVER_NOT_BOUND, dev); in really_probe()
546 device_links_no_driver(dev); in really_probe()
547 devres_release_all(dev); in really_probe()
548 driver_sysfs_remove(dev); in really_probe()
549 dev->driver = NULL; in really_probe()
550 dev_set_drvdata(dev, NULL); in really_probe()
551 if (dev->pm_domain && dev->pm_domain->dismiss) in really_probe()
552 dev->pm_domain->dismiss(dev); in really_probe()
553 pm_runtime_reinit(dev); in really_probe()
554 dev_pm_set_driver_flags(dev, 0); in really_probe()
559 dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name); in really_probe()
560 driver_deferred_probe_add_trigger(dev, local_trigger_count); in really_probe()
565 drv->name, dev_name(dev), ret); in really_probe()
571 drv->name, dev_name(dev), ret); in really_probe()
587 static int really_probe_debug(struct device *dev, struct device_driver *drv) in really_probe_debug() argument
593 ret = really_probe(dev, drv); in really_probe_debug()
597 dev_name(dev), ret, (s64) ktime_to_us(delta)); in really_probe_debug()
644 int driver_probe_device(struct device_driver *drv, struct device *dev) in driver_probe_device() argument
648 if (!device_is_registered(dev)) in driver_probe_device()
652 drv->bus->name, __func__, dev_name(dev), drv->name); in driver_probe_device()
654 pm_runtime_get_suppliers(dev); in driver_probe_device()
655 if (dev->parent) in driver_probe_device()
656 pm_runtime_get_sync(dev->parent); in driver_probe_device()
658 pm_runtime_barrier(dev); in driver_probe_device()
660 ret = really_probe_debug(dev, drv); in driver_probe_device()
662 ret = really_probe(dev, drv); in driver_probe_device()
663 pm_request_idle(dev); in driver_probe_device()
665 if (dev->parent) in driver_probe_device()
666 pm_runtime_put(dev->parent); in driver_probe_device()
668 pm_runtime_put_suppliers(dev); in driver_probe_device()
690 struct device *dev; member
725 struct device *dev = data->dev; in __device_attach_driver() local
735 if (dev->driver) in __device_attach_driver()
738 ret = driver_match_device(drv, dev); in __device_attach_driver()
743 dev_dbg(dev, "Device match requests probe deferral\n"); in __device_attach_driver()
744 driver_deferred_probe_add(dev); in __device_attach_driver()
746 dev_dbg(dev, "Bus failed to match device: %d", ret); in __device_attach_driver()
758 return driver_probe_device(drv, dev); in __device_attach_driver()
763 struct device *dev = _dev; in __device_attach_async_helper() local
765 .dev = dev, in __device_attach_async_helper()
770 device_lock(dev); in __device_attach_async_helper()
772 if (dev->parent) in __device_attach_async_helper()
773 pm_runtime_get_sync(dev->parent); in __device_attach_async_helper()
775 bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver); in __device_attach_async_helper()
776 dev_dbg(dev, "async probe completed\n"); in __device_attach_async_helper()
778 pm_request_idle(dev); in __device_attach_async_helper()
780 if (dev->parent) in __device_attach_async_helper()
781 pm_runtime_put(dev->parent); in __device_attach_async_helper()
783 device_unlock(dev); in __device_attach_async_helper()
785 put_device(dev); in __device_attach_async_helper()
788 static int __device_attach(struct device *dev, bool allow_async) in __device_attach() argument
792 device_lock(dev); in __device_attach()
793 if (dev->driver) { in __device_attach()
794 if (device_is_bound(dev)) { in __device_attach()
798 ret = device_bind_driver(dev); in __device_attach()
802 dev->driver = NULL; in __device_attach()
807 .dev = dev, in __device_attach()
812 if (dev->parent) in __device_attach()
813 pm_runtime_get_sync(dev->parent); in __device_attach()
815 ret = bus_for_each_drv(dev->bus, NULL, &data, in __device_attach()
825 dev_dbg(dev, "scheduling asynchronous probe\n"); in __device_attach()
826 get_device(dev); in __device_attach()
827 async_schedule(__device_attach_async_helper, dev); in __device_attach()
829 pm_request_idle(dev); in __device_attach()
832 if (dev->parent) in __device_attach()
833 pm_runtime_put(dev->parent); in __device_attach()
836 device_unlock(dev); in __device_attach()
854 int device_attach(struct device *dev) in device_attach() argument
856 return __device_attach(dev, false); in device_attach()
860 void device_initial_probe(struct device *dev) in device_initial_probe() argument
862 __device_attach(dev, true); in device_initial_probe()
865 static int __driver_attach(struct device *dev, void *data) in __driver_attach() argument
880 ret = driver_match_device(drv, dev); in __driver_attach()
885 dev_dbg(dev, "Device match requests probe deferral\n"); in __driver_attach()
886 driver_deferred_probe_add(dev); in __driver_attach()
888 dev_dbg(dev, "Bus failed to match device: %d", ret); in __driver_attach()
892 if (dev->parent && dev->bus->need_parent_lock) in __driver_attach()
893 device_lock(dev->parent); in __driver_attach()
894 device_lock(dev); in __driver_attach()
895 if (!dev->driver) in __driver_attach()
896 driver_probe_device(drv, dev); in __driver_attach()
897 device_unlock(dev); in __driver_attach()
898 if (dev->parent && dev->bus->need_parent_lock) in __driver_attach()
899 device_unlock(dev->parent); in __driver_attach()
923 static void __device_release_driver(struct device *dev, struct device *parent) in __device_release_driver() argument
927 drv = dev->driver; in __device_release_driver()
932 while (device_links_busy(dev)) { in __device_release_driver()
933 device_unlock(dev); in __device_release_driver()
937 device_links_unbind_consumers(dev); in __device_release_driver()
941 device_lock(dev); in __device_release_driver()
947 if (dev->driver != drv) in __device_release_driver()
951 pm_runtime_get_sync(dev); in __device_release_driver()
952 pm_runtime_clean_up_links(dev); in __device_release_driver()
954 driver_sysfs_remove(dev); in __device_release_driver()
956 if (dev->bus) in __device_release_driver()
957 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in __device_release_driver()
959 dev); in __device_release_driver()
961 pm_runtime_put_sync(dev); in __device_release_driver()
963 if (dev->bus && dev->bus->remove) in __device_release_driver()
964 dev->bus->remove(dev); in __device_release_driver()
966 drv->remove(dev); in __device_release_driver()
968 device_links_driver_cleanup(dev); in __device_release_driver()
969 dma_deconfigure(dev); in __device_release_driver()
971 devres_release_all(dev); in __device_release_driver()
972 dev->driver = NULL; in __device_release_driver()
973 dev_set_drvdata(dev, NULL); in __device_release_driver()
974 if (dev->pm_domain && dev->pm_domain->dismiss) in __device_release_driver()
975 dev->pm_domain->dismiss(dev); in __device_release_driver()
976 pm_runtime_reinit(dev); in __device_release_driver()
977 dev_pm_set_driver_flags(dev, 0); in __device_release_driver()
979 klist_remove(&dev->p->knode_driver); in __device_release_driver()
980 device_pm_check_callbacks(dev); in __device_release_driver()
981 if (dev->bus) in __device_release_driver()
982 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, in __device_release_driver()
984 dev); in __device_release_driver()
986 kobject_uevent(&dev->kobj, KOBJ_UNBIND); in __device_release_driver()
990 void device_release_driver_internal(struct device *dev, in device_release_driver_internal() argument
994 if (parent && dev->bus->need_parent_lock) in device_release_driver_internal()
997 device_lock(dev); in device_release_driver_internal()
998 if (!drv || drv == dev->driver) in device_release_driver_internal()
999 __device_release_driver(dev, parent); in device_release_driver_internal()
1001 device_unlock(dev); in device_release_driver_internal()
1002 if (parent && dev->bus->need_parent_lock) in device_release_driver_internal()
1017 void device_release_driver(struct device *dev) in device_release_driver() argument
1024 device_release_driver_internal(dev, NULL, NULL); in device_release_driver()
1035 struct device *dev; in driver_detach() local
1046 dev = dev_prv->device; in driver_detach()
1047 get_device(dev); in driver_detach()
1049 device_release_driver_internal(dev, drv, dev->parent); in driver_detach()
1050 put_device(dev); in driver_detach()