aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/uhid.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 5dee8bd60745..db4e119cb088 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -44,10 +44,11 @@ struct uhid_device {
44 __u8 tail; 44 __u8 tail;
45 struct uhid_event *outq[UHID_BUFSIZE]; 45 struct uhid_event *outq[UHID_BUFSIZE];
46 46
47 /* blocking GET_REPORT support; state changes protected by qlock */
47 struct mutex report_lock; 48 struct mutex report_lock;
48 wait_queue_head_t report_wait; 49 wait_queue_head_t report_wait;
49 atomic_t report_done; 50 atomic_t report_done;
50 atomic_t report_id; 51 u32 report_id;
51 struct uhid_event report_buf; 52 struct uhid_event report_buf;
52}; 53};
53 54
@@ -163,7 +164,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
163 164
164 spin_lock_irqsave(&uhid->qlock, flags); 165 spin_lock_irqsave(&uhid->qlock, flags);
165 ev->type = UHID_FEATURE; 166 ev->type = UHID_FEATURE;
166 ev->u.feature.id = atomic_inc_return(&uhid->report_id); 167 ev->u.feature.id = ++uhid->report_id;
167 ev->u.feature.rnum = rnum; 168 ev->u.feature.rnum = rnum;
168 ev->u.feature.rtype = report_type; 169 ev->u.feature.rtype = report_type;
169 170
@@ -497,7 +498,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
497 spin_lock_irqsave(&uhid->qlock, flags); 498 spin_lock_irqsave(&uhid->qlock, flags);
498 499
499 /* id for old report; drop it silently */ 500 /* id for old report; drop it silently */
500 if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id) 501 if (uhid->report_id != ev->u.feature_answer.id)
501 goto unlock; 502 goto unlock;
502 if (atomic_read(&uhid->report_done)) 503 if (atomic_read(&uhid->report_done))
503 goto unlock; 504 goto unlock;