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