Lines Matching refs:device
43 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
55 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
56 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
57 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
75 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
81 for_each_child_of_node(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
84 err = host1x_subdev_add(device, np); in host1x_device_parse_dt()
93 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
104 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
105 mutex_lock(&device->clients_lock); in host1x_subdev_register()
106 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
107 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
108 client->parent = &device->dev; in host1x_subdev_register()
110 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
111 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
113 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
114 err = device_add(&device->dev); in host1x_subdev_register()
116 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
118 device->registered = true; in host1x_subdev_register()
122 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
131 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
132 if (device->registered) { in __host1x_subdev_unregister()
133 device->registered = false; in __host1x_subdev_unregister()
134 device_del(&device->dev); in __host1x_subdev_unregister()
142 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
145 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
155 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
158 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
161 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
162 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
163 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
166 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
171 mutex_lock(&device->clients_lock); in host1x_device_init()
173 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
177 dev_err(&device->dev, in host1x_device_init()
180 mutex_unlock(&device->clients_lock); in host1x_device_init()
186 mutex_unlock(&device->clients_lock); in host1x_device_init()
192 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
197 mutex_lock(&device->clients_lock); in host1x_device_exit()
199 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
203 dev_err(&device->dev, in host1x_device_exit()
206 mutex_unlock(&device->clients_lock); in host1x_device_exit()
212 mutex_unlock(&device->clients_lock); in host1x_device_exit()
221 struct host1x_device *device; in host1x_add_client() local
226 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
227 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
229 host1x_subdev_register(device, subdev, client); in host1x_add_client()
243 struct host1x_device *device, *dt; in host1x_del_client() local
248 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
249 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
251 host1x_subdev_unregister(device, subdev); in host1x_del_client()
262 static int host1x_device_match(struct device *dev, struct device_driver *drv) in host1x_device_match()
267 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
270 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
273 return driver->probe(device); in host1x_device_probe()
278 static int host1x_device_remove(struct device *dev) in host1x_device_remove()
281 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
284 return driver->remove(device); in host1x_device_remove()
289 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
292 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
295 driver->shutdown(device); in host1x_device_shutdown()
316 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
321 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
324 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
336 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
345 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
348 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
352 mutex_lock(&device->clients_lock); in __host1x_device_del()
354 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
357 mutex_unlock(&device->clients_lock); in __host1x_device_del()
361 list_del_init(&device->list); in __host1x_device_del()
364 static void host1x_device_release(struct device *dev) in host1x_device_release()
366 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
368 __host1x_device_del(device); in host1x_device_release()
369 kfree(device); in host1x_device_release()
377 struct host1x_device *device; in host1x_device_add() local
380 device = kzalloc(sizeof(*device), GFP_KERNEL); in host1x_device_add()
381 if (!device) in host1x_device_add()
384 device_initialize(&device->dev); in host1x_device_add()
386 mutex_init(&device->subdevs_lock); in host1x_device_add()
387 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
388 INIT_LIST_HEAD(&device->active); in host1x_device_add()
389 mutex_init(&device->clients_lock); in host1x_device_add()
390 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
391 INIT_LIST_HEAD(&device->list); in host1x_device_add()
392 device->driver = driver; in host1x_device_add()
394 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
395 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
396 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
397 device->dev.release = host1x_device_release; in host1x_device_add()
398 device->dev.bus = &host1x_bus_type; in host1x_device_add()
399 device->dev.parent = host1x->dev; in host1x_device_add()
401 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
403 kfree(device); in host1x_device_add()
407 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
412 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
414 host1x_subdev_register(device, subdev, client); in host1x_device_add()
432 struct host1x_device *device) in host1x_device_del() argument
434 if (device->registered) { in host1x_device_del()
435 device->registered = false; in host1x_device_del()
436 device_del(&device->dev); in host1x_device_del()
439 put_device(&device->dev); in host1x_device_del()
445 struct host1x_device *device; in host1x_attach_driver() local
450 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
451 if (device->driver == driver) { in host1x_attach_driver()
467 struct host1x_device *device, *tmp; in host1x_detach_driver() local
471 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
472 if (device->driver == driver) in host1x_detach_driver()
473 host1x_device_del(host1x, device); in host1x_detach_driver()