Lines Matching refs:aux_dev
62 struct drm_dp_aux_dev *aux_dev = NULL; in drm_dp_aux_dev_get_by_minor() local
65 aux_dev = idr_find(&aux_idr, index); in drm_dp_aux_dev_get_by_minor()
66 if (aux_dev && !kref_get_unless_zero(&aux_dev->refcount)) in drm_dp_aux_dev_get_by_minor()
67 aux_dev = NULL; in drm_dp_aux_dev_get_by_minor()
70 return aux_dev; in drm_dp_aux_dev_get_by_minor()
75 struct drm_dp_aux_dev *aux_dev; in alloc_drm_dp_aux_dev() local
78 aux_dev = kzalloc(sizeof(*aux_dev), GFP_KERNEL); in alloc_drm_dp_aux_dev()
79 if (!aux_dev) in alloc_drm_dp_aux_dev()
81 aux_dev->aux = aux; in alloc_drm_dp_aux_dev()
82 atomic_set(&aux_dev->usecount, 1); in alloc_drm_dp_aux_dev()
83 kref_init(&aux_dev->refcount); in alloc_drm_dp_aux_dev()
86 index = idr_alloc(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, GFP_KERNEL); in alloc_drm_dp_aux_dev()
89 kfree(aux_dev); in alloc_drm_dp_aux_dev()
92 aux_dev->index = index; in alloc_drm_dp_aux_dev()
94 return aux_dev; in alloc_drm_dp_aux_dev()
99 struct drm_dp_aux_dev *aux_dev = in release_drm_dp_aux_dev() local
102 kfree(aux_dev); in release_drm_dp_aux_dev()
109 struct drm_dp_aux_dev *aux_dev = in name_show() local
112 if (!aux_dev) in name_show()
115 res = sprintf(buf, "%s\n", aux_dev->aux->name); in name_show()
116 kref_put(&aux_dev->refcount, release_drm_dp_aux_dev); in name_show()
131 struct drm_dp_aux_dev *aux_dev; in auxdev_open() local
133 aux_dev = drm_dp_aux_dev_get_by_minor(minor); in auxdev_open()
134 if (!aux_dev) in auxdev_open()
137 file->private_data = aux_dev; in auxdev_open()
148 struct drm_dp_aux_dev *aux_dev = iocb->ki_filp->private_data; in auxdev_read_iter() local
152 if (!atomic_inc_not_zero(&aux_dev->usecount)) in auxdev_read_iter()
166 res = drm_dp_dpcd_read(aux_dev->aux, pos, buf, todo); in auxdev_read_iter()
183 if (atomic_dec_and_test(&aux_dev->usecount)) in auxdev_read_iter()
184 wake_up_var(&aux_dev->usecount); in auxdev_read_iter()
191 struct drm_dp_aux_dev *aux_dev = iocb->ki_filp->private_data; in auxdev_write_iter() local
195 if (!atomic_inc_not_zero(&aux_dev->usecount)) in auxdev_write_iter()
214 res = drm_dp_dpcd_write(aux_dev->aux, pos, buf, todo); in auxdev_write_iter()
226 if (atomic_dec_and_test(&aux_dev->usecount)) in auxdev_write_iter()
227 wake_up_var(&aux_dev->usecount); in auxdev_write_iter()
234 struct drm_dp_aux_dev *aux_dev = file->private_data; in auxdev_release() local
236 kref_put(&aux_dev->refcount, release_drm_dp_aux_dev); in auxdev_release()
253 struct drm_dp_aux_dev *iter, *aux_dev = NULL; in drm_dp_aux_dev_get_by_aux() local
264 aux_dev = iter; in drm_dp_aux_dev_get_by_aux()
269 return aux_dev; in drm_dp_aux_dev_get_by_aux()
274 struct drm_dp_aux_dev *aux_dev; in drm_dp_aux_unregister_devnode() local
277 aux_dev = drm_dp_aux_dev_get_by_aux(aux); in drm_dp_aux_unregister_devnode()
278 if (!aux_dev) /* attach must have failed */ in drm_dp_aux_unregister_devnode()
288 idr_remove(&aux_idr, aux_dev->index); in drm_dp_aux_unregister_devnode()
291 atomic_dec(&aux_dev->usecount); in drm_dp_aux_unregister_devnode()
292 wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount)); in drm_dp_aux_unregister_devnode()
294 minor = aux_dev->index; in drm_dp_aux_unregister_devnode()
295 if (aux_dev->dev) in drm_dp_aux_unregister_devnode()
300 kref_put(&aux_dev->refcount, release_drm_dp_aux_dev); in drm_dp_aux_unregister_devnode()
305 struct drm_dp_aux_dev *aux_dev; in drm_dp_aux_register_devnode() local
308 aux_dev = alloc_drm_dp_aux_dev(aux); in drm_dp_aux_register_devnode()
309 if (IS_ERR(aux_dev)) in drm_dp_aux_register_devnode()
310 return PTR_ERR(aux_dev); in drm_dp_aux_register_devnode()
312 aux_dev->dev = device_create(drm_dp_aux_dev_class, aux->dev, in drm_dp_aux_register_devnode()
313 MKDEV(drm_dev_major, aux_dev->index), NULL, in drm_dp_aux_register_devnode()
314 "drm_dp_aux%d", aux_dev->index); in drm_dp_aux_register_devnode()
315 if (IS_ERR(aux_dev->dev)) { in drm_dp_aux_register_devnode()
316 res = PTR_ERR(aux_dev->dev); in drm_dp_aux_register_devnode()
317 aux_dev->dev = NULL; in drm_dp_aux_register_devnode()
322 aux->name, aux_dev->index); in drm_dp_aux_register_devnode()