Lines Matching full:device

15  * Module roccat is a char device used to report special events of roccat
18 * not stored in device. The information in these events depends on hid device
48 struct device *dev;
65 struct roccat_device *device; member
80 struct roccat_device *device = reader->device; in roccat_read() local
85 mutex_lock(&device->cbuf_lock); in roccat_read()
88 if (reader->cbuf_start == device->cbuf_end) { in roccat_read()
89 add_wait_queue(&device->wait, &wait); in roccat_read()
93 while (reader->cbuf_start == device->cbuf_end) { in roccat_read()
102 if (!device->exist) { in roccat_read()
107 mutex_unlock(&device->cbuf_lock); in roccat_read()
109 mutex_lock(&device->cbuf_lock); in roccat_read()
114 remove_wait_queue(&device->wait, &wait); in roccat_read()
121 report = &device->cbuf[reader->cbuf_start]; in roccat_read()
126 len = device->report_size > count ? count : device->report_size; in roccat_read()
136 mutex_unlock(&device->cbuf_lock); in roccat_read()
143 poll_wait(file, &reader->device->wait, wait); in roccat_poll()
144 if (reader->cbuf_start != reader->device->cbuf_end) in roccat_poll()
146 if (!reader->device->exist) in roccat_poll()
155 struct roccat_device *device; in roccat_open() local
164 device = devices[minor]; in roccat_open()
166 if (!device) { in roccat_open()
167 pr_emerg("roccat device with minor %d doesn't exist\n", minor); in roccat_open()
172 mutex_lock(&device->readers_lock); in roccat_open()
174 if (!device->open++) { in roccat_open()
175 /* power on device on adding first reader */ in roccat_open()
176 error = hid_hw_power(device->hid, PM_HINT_FULLON); in roccat_open()
178 --device->open; in roccat_open()
182 error = hid_hw_open(device->hid); in roccat_open()
184 hid_hw_power(device->hid, PM_HINT_NORMAL); in roccat_open()
185 --device->open; in roccat_open()
190 reader->device = device; in roccat_open()
192 reader->cbuf_start = device->cbuf_end; in roccat_open()
194 list_add_tail(&reader->node, &device->readers); in roccat_open()
198 mutex_unlock(&device->readers_lock); in roccat_open()
210 struct roccat_device *device; in roccat_release() local
214 device = devices[minor]; in roccat_release()
215 if (!device) { in roccat_release()
217 pr_emerg("roccat device with minor %d doesn't exist\n", minor); in roccat_release()
221 mutex_lock(&device->readers_lock); in roccat_release()
223 mutex_unlock(&device->readers_lock); in roccat_release()
226 if (!--device->open) { in roccat_release()
228 if (device->exist) { in roccat_release()
229 hid_hw_power(device->hid, PM_HINT_NORMAL); in roccat_release()
230 hid_hw_close(device->hid); in roccat_release()
232 kfree(device); in roccat_release()
243 * @minor: minor device number returned by roccat_connect()
253 struct roccat_device *device; in roccat_report_event() local
258 device = devices[minor]; in roccat_report_event()
260 new_value = kmemdup(data, device->report_size, GFP_ATOMIC); in roccat_report_event()
264 report = &device->cbuf[device->cbuf_end]; in roccat_report_event()
270 device->cbuf_end = (device->cbuf_end + 1) % ROCCAT_CBUF_SIZE; in roccat_report_event()
272 list_for_each_entry(reader, &device->readers, node) { in roccat_report_event()
279 if (reader->cbuf_start == device->cbuf_end) in roccat_report_event()
283 wake_up_interruptible(&device->wait); in roccat_report_event()
289 * roccat_connect() - create a char device for special event output
290 * @class: the class thats used to create the device. Meant to hold device
292 * @hid: the hid device the char device should be connected to.
294 * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on
300 struct roccat_device *device; in roccat_connect() local
303 device = kzalloc(sizeof(struct roccat_device), GFP_KERNEL); in roccat_connect()
304 if (!device) in roccat_connect()
316 devices[minor] = device; in roccat_connect()
319 kfree(device); in roccat_connect()
323 device->dev = device_create(klass, &hid->dev, in roccat_connect()
327 if (IS_ERR(device->dev)) { in roccat_connect()
330 temp = PTR_ERR(device->dev); in roccat_connect()
331 kfree(device); in roccat_connect()
337 init_waitqueue_head(&device->wait); in roccat_connect()
338 INIT_LIST_HEAD(&device->readers); in roccat_connect()
339 mutex_init(&device->readers_lock); in roccat_connect()
340 mutex_init(&device->cbuf_lock); in roccat_connect()
341 device->minor = minor; in roccat_connect()
342 device->hid = hid; in roccat_connect()
343 device->exist = 1; in roccat_connect()
344 device->cbuf_end = 0; in roccat_connect()
345 device->report_size = report_size; in roccat_connect()
351 /* roccat_disconnect() - remove char device from hid device
352 * @minor: the minor device number returned by roccat_connect()
356 struct roccat_device *device; in roccat_disconnect() local
359 device = devices[minor]; in roccat_disconnect()
362 device->exist = 0; /* TODO exist maybe not needed */ in roccat_disconnect()
364 device_destroy(device->dev->class, MKDEV(roccat_major, minor)); in roccat_disconnect()
370 if (device->open) { in roccat_disconnect()
371 hid_hw_close(device->hid); in roccat_disconnect()
372 wake_up_interruptible(&device->wait); in roccat_disconnect()
374 kfree(device); in roccat_disconnect()
382 struct roccat_device *device; in roccat_ioctl() local
388 device = devices[minor]; in roccat_ioctl()
389 if (!device) { in roccat_ioctl()
396 if (put_user(device->report_size, (int __user *)arg)) in roccat_ioctl()
450 MODULE_DESCRIPTION("USB Roccat char device");