~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/hid/usbhid/hiddev.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
        list_del(&list->node);
243
243
        spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
244
244
 
 
245
        mutex_lock(&list->hiddev->existancelock);
245
246
        if (!--list->hiddev->open) {
246
247
                if (list->hiddev->exist) {
247
248
                        usbhid_close(list->hiddev->hid);
248
249
                        usbhid_put_power(list->hiddev->hid);
249
250
                } else {
 
251
                        mutex_unlock(&list->hiddev->existancelock);
250
252
                        kfree(list->hiddev);
 
253
                        kfree(list);
 
254
                        return 0;
251
255
                }
252
256
        }
253
257
 
 
258
        mutex_unlock(&list->hiddev->existancelock);
254
259
        kfree(list);
255
260
 
256
261
        return 0;
300
305
        list_add_tail(&list->node, &hiddev->list);
301
306
        spin_unlock_irq(&list->hiddev->list_lock);
302
307
 
 
308
        mutex_lock(&hiddev->existancelock);
303
309
        if (!list->hiddev->open++)
304
310
                if (list->hiddev->exist) {
305
311
                        struct hid_device *hid = hiddev->hid;
306
312
                        res = usbhid_get_power(hid);
307
313
                        if (res < 0) {
308
314
                                res = -EIO;
309
 
                                goto bail;
 
315
                                goto bail_unlock;
310
316
                        }
311
317
                        usbhid_open(hid);
312
318
                }
 
319
        mutex_unlock(&hiddev->existancelock);
313
320
        return 0;
 
321
bail_unlock:
 
322
        mutex_unlock(&hiddev->existancelock);
314
323
bail:
315
324
        file->private_data = NULL;
316
325
        kfree(list);
367
376
                                /* let O_NONBLOCK tasks run */
368
377
                                mutex_unlock(&list->thread_lock);
369
378
                                schedule();
370
 
                                if (mutex_lock_interruptible(&list->thread_lock))
 
379
                                if (mutex_lock_interruptible(&list->thread_lock)) {
 
380
                                        finish_wait(&list->hiddev->wait, &wait);
371
381
                                        return -EINTR;
 
382
                                }
372
383
                                set_current_state(TASK_INTERRUPTIBLE);
373
384
                        }
374
385
                        finish_wait(&list->hiddev->wait, &wait);
509
520
                                 (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
510
521
                                  uref->usage_index + uref_multi->num_values > field->report_count))
511
522
                                goto inval;
512
 
                        }
 
523
                }
513
524
 
514
525
                switch (cmd) {
515
526
                case HIDIOCGUSAGE:
801
812
                        break;
802
813
 
803
814
                if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) {
804
 
                        int len;
805
 
 
806
 
                        if (!hid->name) {
807
 
                                r = 0;
808
 
                                break;
809
 
                        }
810
 
 
811
 
                        len = strlen(hid->name) + 1;
 
815
                        int len = strlen(hid->name) + 1;
812
816
                        if (len > _IOC_SIZE(cmd))
813
817
                                 len = _IOC_SIZE(cmd);
814
818
                        r = copy_to_user(user_arg, hid->name, len) ?
817
821
                }
818
822
 
819
823
                if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) {
820
 
                        int len;
821
 
 
822
 
                        if (!hid->phys) {
823
 
                                r = 0;
824
 
                                break;
825
 
                        }
826
 
 
827
 
                        len = strlen(hid->phys) + 1;
 
824
                        int len = strlen(hid->phys) + 1;
828
825
                        if (len > _IOC_SIZE(cmd))
829
826
                                len = _IOC_SIZE(cmd);
830
827
                        r = copy_to_user(user_arg, hid->phys, len) ?
925
922
 
926
923
        mutex_lock(&hiddev->existancelock);
927
924
        hiddev->exist = 0;
928
 
        mutex_unlock(&hiddev->existancelock);
929
925
 
930
926
        usb_deregister_dev(usbhid->intf, &hiddev_class);
931
927
 
932
928
        if (hiddev->open) {
 
929
                mutex_unlock(&hiddev->existancelock);
933
930
                usbhid_close(hiddev->hid);
934
931
                wake_up_interruptible(&hiddev->wait);
935
932
        } else {
 
933
                mutex_unlock(&hiddev->existancelock);
936
934
                kfree(hiddev);
937
935
        }
938
936
}