Lines Matching full:device

34  * host1x_subdev_add() - add a new subdevice with an associated device node
35 * @device: host1x device to add the subdevice to
37 * @np: device node
39 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
54 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
55 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
56 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
62 err = host1x_subdev_add(device, driver, child); in host1x_subdev_add()
86 * host1x_device_parse_dt() - scan device tree and add matching subdevices
87 * @device: host1x logical device
90 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
96 for_each_child_of_node(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
99 err = host1x_subdev_add(device, driver, np); in host1x_device_parse_dt()
110 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
119 * client with its parent device. in host1x_subdev_register()
121 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
122 mutex_lock(&device->clients_lock); in host1x_subdev_register()
123 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
124 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
125 client->host = &device->dev; in host1x_subdev_register()
127 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
128 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
130 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
131 err = device_add(&device->dev); in host1x_subdev_register()
133 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
135 device->registered = true; in host1x_subdev_register()
139 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
148 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
149 if (device->registered) { in __host1x_subdev_unregister()
150 device->registered = false; in __host1x_subdev_unregister()
151 device_del(&device->dev); in __host1x_subdev_unregister()
159 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
162 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
165 * when the device is about to be deleted. in __host1x_subdev_unregister()
169 * also when the composite device is about to be removed. in __host1x_subdev_unregister()
172 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
175 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
178 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
179 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
180 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
184 * host1x_device_init() - initialize a host1x logical device
185 * @device: host1x logical device
187 * The driver for the host1x logical device can call this during execution of
193 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
198 mutex_lock(&device->clients_lock); in host1x_device_init()
200 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
204 dev_err(&device->dev, "failed to early initialize %s: %d\n", in host1x_device_init()
211 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
215 dev_err(&device->dev, in host1x_device_init()
223 mutex_unlock(&device->clients_lock); in host1x_device_init()
228 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
233 client = list_entry(&device->clients, struct host1x_client, list); in host1x_device_init()
236 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
240 mutex_unlock(&device->clients_lock); in host1x_device_init()
246 * host1x_device_exit() - uninitialize host1x logical device
247 * @device: host1x logical device
249 * When the driver for a host1x logical device is unloaded, it can call this
254 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
259 mutex_lock(&device->clients_lock); in host1x_device_exit()
261 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
265 dev_err(&device->dev, in host1x_device_exit()
268 mutex_unlock(&device->clients_lock); in host1x_device_exit()
274 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
278 dev_err(&device->dev, "failed to late cleanup %s: %d\n", in host1x_device_exit()
280 mutex_unlock(&device->clients_lock); in host1x_device_exit()
286 mutex_unlock(&device->clients_lock); in host1x_device_exit()
295 struct host1x_device *device; in host1x_add_client() local
300 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
301 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
303 host1x_subdev_register(device, subdev, client); in host1x_add_client()
317 struct host1x_device *device, *dt; in host1x_del_client() local
322 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
323 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
325 host1x_subdev_unregister(device, subdev); in host1x_del_client()
336 static int host1x_device_match(struct device *dev, const struct device_driver *drv) in host1x_device_match()
346 static int host1x_device_uevent(const struct device *dev, in host1x_device_uevent()
370 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
375 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
378 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
390 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
399 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
402 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
406 mutex_lock(&device->clients_lock); in __host1x_device_del()
408 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
411 mutex_unlock(&device->clients_lock); in __host1x_device_del()
414 /* finally remove the device */ in __host1x_device_del()
415 list_del_init(&device->list); in __host1x_device_del()
418 static void host1x_device_release(struct device *dev) in host1x_device_release()
420 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
422 __host1x_device_del(device); in host1x_device_release()
423 kfree(device); in host1x_device_release()
431 struct host1x_device *device; in host1x_device_add() local
434 device = kzalloc(sizeof(*device), GFP_KERNEL); in host1x_device_add()
435 if (!device) in host1x_device_add()
438 device_initialize(&device->dev); in host1x_device_add()
440 mutex_init(&device->subdevs_lock); in host1x_device_add()
441 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
442 INIT_LIST_HEAD(&device->active); in host1x_device_add()
443 mutex_init(&device->clients_lock); in host1x_device_add()
444 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
445 INIT_LIST_HEAD(&device->list); in host1x_device_add()
446 device->driver = driver; in host1x_device_add()
448 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
449 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
450 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
451 device->dev.release = host1x_device_release; in host1x_device_add()
452 device->dev.bus = &host1x_bus_type; in host1x_device_add()
453 device->dev.parent = host1x->dev; in host1x_device_add()
455 device->dev.dma_parms = &device->dma_parms; in host1x_device_add()
456 dma_set_max_seg_size(&device->dev, UINT_MAX); in host1x_device_add()
458 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
460 kfree(device); in host1x_device_add()
464 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
469 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
471 host1x_subdev_register(device, subdev, client); in host1x_device_add()
483 * Removes a device by first unregistering any subdevices and then removing
489 struct host1x_device *device) in host1x_device_del() argument
491 if (device->registered) { in host1x_device_del()
492 device->registered = false; in host1x_device_del()
493 device_del(&device->dev); in host1x_device_del()
496 put_device(&device->dev); in host1x_device_del()
502 struct host1x_device *device; in host1x_attach_driver() local
507 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
508 if (device->driver == driver) { in host1x_attach_driver()
516 dev_err(host1x->dev, "failed to allocate device: %d\n", err); in host1x_attach_driver()
524 struct host1x_device *device, *tmp; in host1x_detach_driver() local
528 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
529 if (device->driver == driver) in host1x_detach_driver()
530 host1x_device_del(host1x, device); in host1x_detach_driver()
538 struct host1x_device *device; in host1x_devices_show() local
542 list_for_each_entry(device, &host1x->devices, list) { in host1x_devices_show()
545 seq_printf(s, "%s\n", dev_name(&device->dev)); in host1x_devices_show()
547 mutex_lock(&device->subdevs_lock); in host1x_devices_show()
549 list_for_each_entry(subdev, &device->active, list) in host1x_devices_show()
553 list_for_each_entry(subdev, &device->subdevs, list) in host1x_devices_show()
556 mutex_unlock(&device->subdevs_lock); in host1x_devices_show()
619 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
622 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
625 return driver->probe(device); in host1x_device_probe()
630 static int host1x_device_remove(struct device *dev) in host1x_device_remove()
633 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
636 return driver->remove(device); in host1x_device_remove()
641 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
644 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
647 driver->shutdown(device); in host1x_device_shutdown()
657 * registration of the driver actually triggers tho logical device creation.
658 * A logical device will be created for each host1x instance.
746 * device and call host1x_device_init(), which will in turn call each client's
779 * device has already been initialized, it will be torn down.
884 struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo, in host1x_bo_pin()