Lines Matching full:device

12  * Module roccat is a char device used to report special events of roccat
15 * not stored in device. The information in these events depends on hid device
45 struct device *dev;
62 struct roccat_device *device; member
77 struct roccat_device *device = reader->device; in roccat_read() local
82 mutex_lock(&device->cbuf_lock); in roccat_read()
85 if (reader->cbuf_start == device->cbuf_end) { in roccat_read()
86 add_wait_queue(&device->wait, &wait); in roccat_read()
90 while (reader->cbuf_start == device->cbuf_end) { in roccat_read()
99 if (!device->exist) { in roccat_read()
104 mutex_unlock(&device->cbuf_lock); in roccat_read()
106 mutex_lock(&device->cbuf_lock); in roccat_read()
111 remove_wait_queue(&device->wait, &wait); in roccat_read()
118 report = &device->cbuf[reader->cbuf_start]; in roccat_read()
123 len = device->report_size > count ? count : device->report_size; in roccat_read()
133 mutex_unlock(&device->cbuf_lock); in roccat_read()
140 poll_wait(file, &reader->device->wait, wait); in roccat_poll()
141 if (reader->cbuf_start != reader->device->cbuf_end) in roccat_poll()
143 if (!reader->device->exist) in roccat_poll()
152 struct roccat_device *device; in roccat_open() local
161 device = devices[minor]; in roccat_open()
163 if (!device) { in roccat_open()
164 pr_emerg("roccat device with minor %d doesn't exist\n", minor); in roccat_open()
169 mutex_lock(&device->readers_lock); in roccat_open()
171 if (!device->open++) { in roccat_open()
172 /* power on device on adding first reader */ in roccat_open()
173 error = hid_hw_power(device->hid, PM_HINT_FULLON); in roccat_open()
175 --device->open; in roccat_open()
179 error = hid_hw_open(device->hid); in roccat_open()
181 hid_hw_power(device->hid, PM_HINT_NORMAL); in roccat_open()
182 --device->open; in roccat_open()
187 reader->device = device; in roccat_open()
189 reader->cbuf_start = device->cbuf_end; in roccat_open()
191 list_add_tail(&reader->node, &device->readers); in roccat_open()
195 mutex_unlock(&device->readers_lock); in roccat_open()
207 struct roccat_device *device; in roccat_release() local
211 device = devices[minor]; in roccat_release()
212 if (!device) { in roccat_release()
214 pr_emerg("roccat device with minor %d doesn't exist\n", minor); in roccat_release()
218 mutex_lock(&device->readers_lock); in roccat_release()
220 mutex_unlock(&device->readers_lock); in roccat_release()
223 if (!--device->open) { in roccat_release()
225 if (device->exist) { in roccat_release()
226 hid_hw_power(device->hid, PM_HINT_NORMAL); in roccat_release()
227 hid_hw_close(device->hid); in roccat_release()
229 kfree(device); in roccat_release()
240 * @minor: minor device number returned by roccat_connect()
249 struct roccat_device *device; in roccat_report_event() local
254 device = devices[minor]; in roccat_report_event()
256 new_value = kmemdup(data, device->report_size, GFP_ATOMIC); in roccat_report_event()
260 mutex_lock(&device->cbuf_lock); in roccat_report_event()
262 report = &device->cbuf[device->cbuf_end]; in roccat_report_event()
268 device->cbuf_end = (device->cbuf_end + 1) % ROCCAT_CBUF_SIZE; in roccat_report_event()
270 list_for_each_entry(reader, &device->readers, node) { in roccat_report_event()
277 if (reader->cbuf_start == device->cbuf_end) in roccat_report_event()
281 mutex_unlock(&device->cbuf_lock); 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.
295 * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on
301 struct roccat_device *device; in roccat_connect() local
304 device = kzalloc(sizeof(struct roccat_device), GFP_KERNEL); in roccat_connect()
305 if (!device) in roccat_connect()
317 devices[minor] = device; in roccat_connect()
320 kfree(device); in roccat_connect()
324 device->dev = device_create(klass, &hid->dev, in roccat_connect()
328 if (IS_ERR(device->dev)) { in roccat_connect()
331 temp = PTR_ERR(device->dev); in roccat_connect()
332 kfree(device); in roccat_connect()
338 init_waitqueue_head(&device->wait); in roccat_connect()
339 INIT_LIST_HEAD(&device->readers); in roccat_connect()
340 mutex_init(&device->readers_lock); in roccat_connect()
341 mutex_init(&device->cbuf_lock); in roccat_connect()
342 device->minor = minor; in roccat_connect()
343 device->hid = hid; in roccat_connect()
344 device->exist = 1; in roccat_connect()
345 device->cbuf_end = 0; in roccat_connect()
346 device->report_size = report_size; in roccat_connect()
352 /* roccat_disconnect() - remove char device from hid device
353 * @minor: the minor device number returned by roccat_connect()
357 struct roccat_device *device; in roccat_disconnect() local
360 device = devices[minor]; in roccat_disconnect()
363 device->exist = 0; /* TODO exist maybe not needed */ in roccat_disconnect()
365 device_destroy(device->dev->class, MKDEV(roccat_major, minor)); in roccat_disconnect()
371 if (device->open) { in roccat_disconnect()
372 hid_hw_close(device->hid); in roccat_disconnect()
373 wake_up_interruptible(&device->wait); in roccat_disconnect()
375 kfree(device); in roccat_disconnect()
383 struct roccat_device *device; in roccat_ioctl() local
389 device = devices[minor]; in roccat_ioctl()
390 if (!device) { in roccat_ioctl()
397 if (put_user(device->report_size, (int __user *)arg)) in roccat_ioctl()
460 MODULE_DESCRIPTION("USB Roccat char device");