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
36 * @np: device node
38 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
53 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
54 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
55 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
61 err = host1x_subdev_add(device, driver, child); in host1x_subdev_add()
85 * host1x_device_parse_dt() - scan device tree and add matching subdevices
86 * @device: host1x logical device
89 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
95 for_each_child_of_node(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
98 err = host1x_subdev_add(device, driver, np); in host1x_device_parse_dt()
109 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
118 * client with its parent device. in host1x_subdev_register()
120 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
121 mutex_lock(&device->clients_lock); in host1x_subdev_register()
122 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
123 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
124 client->host = &device->dev; in host1x_subdev_register()
126 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
127 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
129 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
130 err = device_add(&device->dev); in host1x_subdev_register()
132 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
134 device->registered = true; in host1x_subdev_register()
138 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
147 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
148 if (device->registered) { in __host1x_subdev_unregister()
149 device->registered = false; in __host1x_subdev_unregister()
150 device_del(&device->dev); in __host1x_subdev_unregister()
158 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
161 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
164 * when the device is about to be deleted. in __host1x_subdev_unregister()
168 * also when the composite device is about to be removed. in __host1x_subdev_unregister()
171 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
174 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
177 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
178 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
179 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
183 * host1x_device_init() - initialize a host1x logical device
184 * @device: host1x logical device
186 * The driver for the host1x logical device can call this during execution of
192 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
197 mutex_lock(&device->clients_lock); in host1x_device_init()
199 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
203 dev_err(&device->dev, "failed to early initialize %s: %d\n", in host1x_device_init()
210 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
214 dev_err(&device->dev, in host1x_device_init()
222 mutex_unlock(&device->clients_lock); in host1x_device_init()
227 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
232 client = list_entry(&device->clients, struct host1x_client, list); in host1x_device_init()
235 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
239 mutex_unlock(&device->clients_lock); in host1x_device_init()
245 * host1x_device_exit() - uninitialize host1x logical device
246 * @device: host1x logical device
248 * When the driver for a host1x logical device is unloaded, it can call this
253 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
258 mutex_lock(&device->clients_lock); in host1x_device_exit()
260 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
264 dev_err(&device->dev, in host1x_device_exit()
267 mutex_unlock(&device->clients_lock); in host1x_device_exit()
273 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
277 dev_err(&device->dev, "failed to late cleanup %s: %d\n", in host1x_device_exit()
279 mutex_unlock(&device->clients_lock); in host1x_device_exit()
285 mutex_unlock(&device->clients_lock); in host1x_device_exit()
294 struct host1x_device *device; in host1x_add_client() local
299 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
300 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
302 host1x_subdev_register(device, subdev, client); in host1x_add_client()
316 struct host1x_device *device, *dt; in host1x_del_client() local
321 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
322 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
324 host1x_subdev_unregister(device, subdev); in host1x_del_client()
335 static int host1x_device_match(struct device *dev, struct device_driver *drv) in host1x_device_match()
340 static int host1x_device_uevent(struct device *dev, in host1x_device_uevent()
370 static int host1x_dma_configure(struct device *dev) in host1x_dma_configure()
392 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
397 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
400 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
412 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
421 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
424 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
428 mutex_lock(&device->clients_lock); in __host1x_device_del()
430 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
433 mutex_unlock(&device->clients_lock); in __host1x_device_del()
436 /* finally remove the device */ in __host1x_device_del()
437 list_del_init(&device->list); in __host1x_device_del()
440 static void host1x_device_release(struct device *dev) in host1x_device_release()
442 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
444 __host1x_device_del(device); in host1x_device_release()
445 kfree(device); in host1x_device_release()
453 struct host1x_device *device; in host1x_device_add() local
456 device = kzalloc(sizeof(*device), GFP_KERNEL); in host1x_device_add()
457 if (!device) in host1x_device_add()
460 device_initialize(&device->dev); in host1x_device_add()
462 mutex_init(&device->subdevs_lock); in host1x_device_add()
463 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
464 INIT_LIST_HEAD(&device->active); in host1x_device_add()
465 mutex_init(&device->clients_lock); in host1x_device_add()
466 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
467 INIT_LIST_HEAD(&device->list); in host1x_device_add()
468 device->driver = driver; in host1x_device_add()
470 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
471 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
472 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
473 device->dev.release = host1x_device_release; in host1x_device_add()
474 device->dev.bus = &host1x_bus_type; in host1x_device_add()
475 device->dev.parent = host1x->dev; in host1x_device_add()
477 of_dma_configure(&device->dev, host1x->dev->of_node, true); in host1x_device_add()
479 device->dev.dma_parms = &device->dma_parms; in host1x_device_add()
480 dma_set_max_seg_size(&device->dev, UINT_MAX); in host1x_device_add()
482 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
484 kfree(device); in host1x_device_add()
488 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
493 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
495 host1x_subdev_register(device, subdev, client); in host1x_device_add()
507 * Removes a device by first unregistering any subdevices and then removing
513 struct host1x_device *device) in host1x_device_del() argument
515 if (device->registered) { in host1x_device_del()
516 device->registered = false; in host1x_device_del()
517 device_del(&device->dev); in host1x_device_del()
520 put_device(&device->dev); in host1x_device_del()
526 struct host1x_device *device; in host1x_attach_driver() local
531 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
532 if (device->driver == driver) { in host1x_attach_driver()
540 dev_err(host1x->dev, "failed to allocate device: %d\n", err); in host1x_attach_driver()
548 struct host1x_device *device, *tmp; in host1x_detach_driver() local
552 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
553 if (device->driver == driver) in host1x_detach_driver()
554 host1x_device_del(host1x, device); in host1x_detach_driver()
562 struct host1x_device *device; in host1x_devices_show() local
566 list_for_each_entry(device, &host1x->devices, list) { in host1x_devices_show()
569 seq_printf(s, "%s\n", dev_name(&device->dev)); in host1x_devices_show()
571 mutex_lock(&device->subdevs_lock); in host1x_devices_show()
573 list_for_each_entry(subdev, &device->active, list) in host1x_devices_show()
577 list_for_each_entry(subdev, &device->subdevs, list) in host1x_devices_show()
580 mutex_unlock(&device->subdevs_lock); in host1x_devices_show()
643 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
646 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
649 return driver->probe(device); in host1x_device_probe()
654 static int host1x_device_remove(struct device *dev) in host1x_device_remove()
657 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
660 return driver->remove(device); in host1x_device_remove()
665 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
668 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
671 driver->shutdown(device); in host1x_device_shutdown()
681 * registration of the driver actually triggers tho logical device creation.
682 * A logical device will be created for each host1x instance.
770 * device and call host1x_device_init(), which will in turn call each client's
803 * device has already been initialized, it will be torn down.