• Home
  • Raw
  • Download

Lines Matching full:device

42  * host1x_subdev_add() - add a new subdevice with an associated device node
43 * @device: host1x device to add the subdevice to
44 * @np: device node
46 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
61 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
62 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
63 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
69 err = host1x_subdev_add(device, driver, child); in host1x_subdev_add()
93 * host1x_device_parse_dt() - scan device tree and add matching subdevices
94 * @device: host1x logical device
97 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
103 for_each_child_of_node(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
106 err = host1x_subdev_add(device, driver, np); in host1x_device_parse_dt()
117 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
126 * client with its parent device. in host1x_subdev_register()
128 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
129 mutex_lock(&device->clients_lock); in host1x_subdev_register()
130 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
131 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
132 client->parent = &device->dev; in host1x_subdev_register()
134 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
135 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
137 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
138 err = device_add(&device->dev); in host1x_subdev_register()
140 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
142 device->registered = true; in host1x_subdev_register()
146 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
155 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
156 if (device->registered) { in __host1x_subdev_unregister()
157 device->registered = false; in __host1x_subdev_unregister()
158 device_del(&device->dev); in __host1x_subdev_unregister()
166 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
169 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
172 * when the device is about to be deleted. in __host1x_subdev_unregister()
176 * also when the composite device is about to be removed. in __host1x_subdev_unregister()
179 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
182 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
185 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
186 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
187 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
191 * host1x_device_init() - initialize a host1x logical device
192 * @device: host1x logical device
194 * The driver for the host1x logical device can call this during execution of
200 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
205 mutex_lock(&device->clients_lock); in host1x_device_init()
207 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
211 dev_err(&device->dev, in host1x_device_init()
219 mutex_unlock(&device->clients_lock); in host1x_device_init()
224 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
228 mutex_unlock(&device->clients_lock); in host1x_device_init()
234 * host1x_device_exit() - uninitialize host1x logical device
235 * @device: host1x logical device
237 * When the driver for a host1x logical device is unloaded, it can call this
242 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
247 mutex_lock(&device->clients_lock); in host1x_device_exit()
249 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
253 dev_err(&device->dev, in host1x_device_exit()
256 mutex_unlock(&device->clients_lock); in host1x_device_exit()
262 mutex_unlock(&device->clients_lock); in host1x_device_exit()
271 struct host1x_device *device; in host1x_add_client() local
276 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
277 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
279 host1x_subdev_register(device, subdev, client); in host1x_add_client()
293 struct host1x_device *device, *dt; in host1x_del_client() local
298 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
299 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
301 host1x_subdev_unregister(device, subdev); in host1x_del_client()
312 static int host1x_device_match(struct device *dev, struct device_driver *drv) in host1x_device_match()
317 static int host1x_dma_configure(struct device *dev) in host1x_dma_configure()
338 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
343 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
346 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
358 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
367 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
370 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
374 mutex_lock(&device->clients_lock); in __host1x_device_del()
376 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
379 mutex_unlock(&device->clients_lock); in __host1x_device_del()
382 /* finally remove the device */ in __host1x_device_del()
383 list_del_init(&device->list); in __host1x_device_del()
386 static void host1x_device_release(struct device *dev) in host1x_device_release()
388 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
390 __host1x_device_del(device); in host1x_device_release()
391 kfree(device); in host1x_device_release()
399 struct host1x_device *device; in host1x_device_add() local
402 device = kzalloc(sizeof(*device), GFP_KERNEL); in host1x_device_add()
403 if (!device) in host1x_device_add()
406 device_initialize(&device->dev); in host1x_device_add()
408 mutex_init(&device->subdevs_lock); in host1x_device_add()
409 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
410 INIT_LIST_HEAD(&device->active); in host1x_device_add()
411 mutex_init(&device->clients_lock); in host1x_device_add()
412 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
413 INIT_LIST_HEAD(&device->list); in host1x_device_add()
414 device->driver = driver; in host1x_device_add()
416 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
417 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
418 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
419 device->dev.release = host1x_device_release; in host1x_device_add()
420 device->dev.of_node = host1x->dev->of_node; in host1x_device_add()
421 device->dev.bus = &host1x_bus_type; in host1x_device_add()
422 device->dev.parent = host1x->dev; in host1x_device_add()
424 of_dma_configure(&device->dev, host1x->dev->of_node, true); in host1x_device_add()
426 device->dev.dma_parms = &device->dma_parms; in host1x_device_add()
427 dma_set_max_seg_size(&device->dev, SZ_4M); in host1x_device_add()
429 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
431 kfree(device); in host1x_device_add()
435 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
440 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
442 host1x_subdev_register(device, subdev, client); in host1x_device_add()
454 * Removes a device by first unregistering any subdevices and then removing
460 struct host1x_device *device) in host1x_device_del() argument
462 if (device->registered) { in host1x_device_del()
463 device->registered = false; in host1x_device_del()
464 device_del(&device->dev); in host1x_device_del()
467 put_device(&device->dev); in host1x_device_del()
473 struct host1x_device *device; in host1x_attach_driver() local
478 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
479 if (device->driver == driver) { in host1x_attach_driver()
487 dev_err(host1x->dev, "failed to allocate device: %d\n", err); in host1x_attach_driver()
495 struct host1x_device *device, *tmp; in host1x_detach_driver() local
499 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
500 if (device->driver == driver) in host1x_detach_driver()
501 host1x_device_del(host1x, device); in host1x_detach_driver()
557 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
560 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
563 return driver->probe(device); in host1x_device_probe()
568 static int host1x_device_remove(struct device *dev) in host1x_device_remove()
571 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
574 return driver->remove(device); in host1x_device_remove()
579 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
582 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
585 driver->shutdown(device); in host1x_device_shutdown()
595 * registration of the driver actually triggers tho logical device creation.
596 * A logical device will be created for each host1x instance.
660 * device and call host1x_device_init(), which will in turn call each client's
693 * device has already been initialized, it will be torn down.