Lines Matching refs:dev
25 int device_chld_unbind(struct udevice *dev, struct driver *drv) in device_chld_unbind() argument
30 assert(dev); in device_chld_unbind()
32 device_foreach_child_safe(pos, n, dev) { in device_chld_unbind()
47 int device_chld_remove(struct udevice *dev, struct driver *drv, in device_chld_remove() argument
53 assert(dev); in device_chld_remove()
55 device_foreach_child_safe(pos, n, dev) { in device_chld_remove()
71 int device_unbind(struct udevice *dev) in device_unbind() argument
76 if (!dev) in device_unbind()
79 if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) in device_unbind()
82 if (!(dev_get_flags(dev) & DM_FLAG_BOUND)) in device_unbind()
85 drv = dev->driver; in device_unbind()
89 ret = drv->unbind(dev); in device_unbind()
94 ret = device_chld_unbind(dev, NULL); in device_unbind()
98 ret = uclass_pre_unbind_device(dev); in device_unbind()
101 if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { in device_unbind()
102 free(dev_get_plat(dev)); in device_unbind()
103 dev_set_plat(dev, NULL); in device_unbind()
105 if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { in device_unbind()
106 free(dev_get_uclass_plat(dev)); in device_unbind()
107 dev_set_uclass_plat(dev, NULL); in device_unbind()
109 if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) { in device_unbind()
110 free(dev_get_parent_plat(dev)); in device_unbind()
111 dev_set_parent_plat(dev, NULL); in device_unbind()
113 ret = uclass_unbind_device(dev); in device_unbind()
117 if (dev->parent) in device_unbind()
118 list_del(&dev->sibling_node); in device_unbind()
120 devres_release_all(dev); in device_unbind()
122 if (dev_get_flags(dev) & DM_FLAG_NAME_ALLOCED) in device_unbind()
123 free((char *)dev->name); in device_unbind()
124 free(dev); in device_unbind()
133 void device_free(struct udevice *dev) in device_free() argument
137 if (dev->driver->priv_auto) { in device_free()
138 free(dev_get_priv(dev)); in device_free()
139 dev_set_priv(dev, NULL); in device_free()
141 size = dev->uclass->uc_drv->per_device_auto; in device_free()
143 free(dev_get_uclass_priv(dev)); in device_free()
144 dev_set_uclass_priv(dev, NULL); in device_free()
146 if (dev->parent) { in device_free()
147 size = dev->parent->driver->per_child_auto; in device_free()
149 size = dev->parent->uclass->uc_drv->per_child_auto; in device_free()
151 free(dev_get_parent_priv(dev)); in device_free()
152 dev_set_parent_priv(dev, NULL); in device_free()
155 dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID); in device_free()
157 devres_release_probe(dev); in device_free()
199 int device_remove(struct udevice *dev, uint flags) in device_remove() argument
204 if (!dev) in device_remove()
207 if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) in device_remove()
210 ret = device_notify(dev, EVT_DM_PRE_REMOVE); in device_remove()
218 ret = device_chld_remove(dev, NULL, flags); in device_remove()
226 drv = dev->driver; in device_remove()
231 dev->name, flags, drv->flags, ret); in device_remove()
235 ret = uclass_pre_remove_device(dev); in device_remove()
240 ret = drv->remove(dev); in device_remove()
245 if (dev->parent && dev->parent->driver->child_post_remove) { in device_remove()
246 ret = dev->parent->driver->child_post_remove(dev); in device_remove()
249 __func__, dev->name); in device_remove()
256 dev != gd->cur_serial_dev) in device_remove()
257 dev_power_domain_off(dev); in device_remove()
259 device_free(dev); in device_remove()
261 dev_bic_flags(dev, DM_FLAG_ACTIVATED); in device_remove()
263 ret = device_notify(dev, EVT_DM_POST_REMOVE); in device_remove()
272 __func__, dev->name); in device_remove()