Lines Matching full:device
33 * host1x_subdev_add() - add a new subdevice with an associated device node
34 * @device: host1x device to add the subdevice to
35 * @np: device node
37 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
52 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
53 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
54 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
60 err = host1x_subdev_add(device, driver, child); in host1x_subdev_add()
84 * host1x_device_parse_dt() - scan device tree and add matching subdevices
85 * @device: host1x logical device
88 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
94 for_each_child_of_node(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
97 err = host1x_subdev_add(device, driver, np); in host1x_device_parse_dt()
108 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
117 * client with its parent device. in host1x_subdev_register()
119 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
120 mutex_lock(&device->clients_lock); in host1x_subdev_register()
121 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
122 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
123 client->host = &device->dev; in host1x_subdev_register()
125 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
126 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
128 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
129 err = device_add(&device->dev); in host1x_subdev_register()
131 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
133 device->registered = true; in host1x_subdev_register()
137 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
146 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
147 if (device->registered) { in __host1x_subdev_unregister()
148 device->registered = false; in __host1x_subdev_unregister()
149 device_del(&device->dev); in __host1x_subdev_unregister()
157 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
160 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
163 * when the device is about to be deleted. in __host1x_subdev_unregister()
167 * also when the composite device is about to be removed. in __host1x_subdev_unregister()
170 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
173 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
176 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
177 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
178 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
182 * host1x_device_init() - initialize a host1x logical device
183 * @device: host1x logical device
185 * The driver for the host1x logical device can call this during execution of
191 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
196 mutex_lock(&device->clients_lock); in host1x_device_init()
198 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
202 dev_err(&device->dev, in host1x_device_init()
210 mutex_unlock(&device->clients_lock); in host1x_device_init()
215 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
219 mutex_unlock(&device->clients_lock); in host1x_device_init()
225 * host1x_device_exit() - uninitialize host1x logical device
226 * @device: host1x logical device
228 * When the driver for a host1x logical device is unloaded, it can call this
233 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
238 mutex_lock(&device->clients_lock); in host1x_device_exit()
240 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
244 dev_err(&device->dev, in host1x_device_exit()
247 mutex_unlock(&device->clients_lock); in host1x_device_exit()
253 mutex_unlock(&device->clients_lock); in host1x_device_exit()
262 struct host1x_device *device; in host1x_add_client() local
267 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
268 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
270 host1x_subdev_register(device, subdev, client); in host1x_add_client()
284 struct host1x_device *device, *dt; in host1x_del_client() local
289 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
290 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
292 host1x_subdev_unregister(device, subdev); in host1x_del_client()
303 static int host1x_device_match(struct device *dev, struct device_driver *drv) in host1x_device_match()
308 static int host1x_device_uevent(struct device *dev, in host1x_device_uevent()
338 static int host1x_dma_configure(struct device *dev) in host1x_dma_configure()
360 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
365 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
368 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
380 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
389 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
392 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
396 mutex_lock(&device->clients_lock); in __host1x_device_del()
398 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
401 mutex_unlock(&device->clients_lock); in __host1x_device_del()
404 /* finally remove the device */ in __host1x_device_del()
405 list_del_init(&device->list); in __host1x_device_del()
408 static void host1x_device_release(struct device *dev) in host1x_device_release()
410 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
412 __host1x_device_del(device); in host1x_device_release()
413 kfree(device); in host1x_device_release()
421 struct host1x_device *device; in host1x_device_add() local
424 device = kzalloc(sizeof(*device), GFP_KERNEL); in host1x_device_add()
425 if (!device) in host1x_device_add()
428 device_initialize(&device->dev); in host1x_device_add()
430 mutex_init(&device->subdevs_lock); in host1x_device_add()
431 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
432 INIT_LIST_HEAD(&device->active); in host1x_device_add()
433 mutex_init(&device->clients_lock); in host1x_device_add()
434 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
435 INIT_LIST_HEAD(&device->list); in host1x_device_add()
436 device->driver = driver; in host1x_device_add()
438 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
439 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
440 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
441 device->dev.release = host1x_device_release; in host1x_device_add()
442 device->dev.bus = &host1x_bus_type; in host1x_device_add()
443 device->dev.parent = host1x->dev; in host1x_device_add()
445 of_dma_configure(&device->dev, host1x->dev->of_node, true); in host1x_device_add()
447 device->dev.dma_parms = &device->dma_parms; in host1x_device_add()
448 dma_set_max_seg_size(&device->dev, UINT_MAX); in host1x_device_add()
450 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
452 kfree(device); in host1x_device_add()
456 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
461 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
463 host1x_subdev_register(device, subdev, client); in host1x_device_add()
475 * Removes a device by first unregistering any subdevices and then removing
481 struct host1x_device *device) in host1x_device_del() argument
483 if (device->registered) { in host1x_device_del()
484 device->registered = false; in host1x_device_del()
485 device_del(&device->dev); in host1x_device_del()
488 put_device(&device->dev); in host1x_device_del()
494 struct host1x_device *device; in host1x_attach_driver() local
499 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
500 if (device->driver == driver) { in host1x_attach_driver()
508 dev_err(host1x->dev, "failed to allocate device: %d\n", err); in host1x_attach_driver()
516 struct host1x_device *device, *tmp; in host1x_detach_driver() local
520 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
521 if (device->driver == driver) in host1x_detach_driver()
522 host1x_device_del(host1x, device); in host1x_detach_driver()
530 struct host1x_device *device; in host1x_devices_show() local
534 list_for_each_entry(device, &host1x->devices, list) { in host1x_devices_show()
537 seq_printf(s, "%s\n", dev_name(&device->dev)); in host1x_devices_show()
539 mutex_lock(&device->subdevs_lock); in host1x_devices_show()
541 list_for_each_entry(subdev, &device->active, list) in host1x_devices_show()
545 list_for_each_entry(subdev, &device->subdevs, list) in host1x_devices_show()
548 mutex_unlock(&device->subdevs_lock); in host1x_devices_show()
611 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
614 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
617 return driver->probe(device); in host1x_device_probe()
622 static int host1x_device_remove(struct device *dev) in host1x_device_remove()
625 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
628 return driver->remove(device); in host1x_device_remove()
633 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
636 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
639 driver->shutdown(device); in host1x_device_shutdown()
649 * registration of the driver actually triggers tho logical device creation.
650 * A logical device will be created for each host1x instance.
714 * device and call host1x_device_init(), which will in turn call each client's
751 * device has already been initialized, it will be torn down.