diff options
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r-- | drivers/hid/hidraw.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 8918dd12bb69..6a6dd5cd7833 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -308,18 +308,25 @@ static int hidraw_fasync(int fd, struct file *file, int on) | |||
308 | static void drop_ref(struct hidraw *hidraw, int exists_bit) | 308 | static void drop_ref(struct hidraw *hidraw, int exists_bit) |
309 | { | 309 | { |
310 | if (exists_bit) { | 310 | if (exists_bit) { |
311 | hid_hw_close(hidraw->hid); | ||
312 | hidraw->exist = 0; | 311 | hidraw->exist = 0; |
313 | if (hidraw->open) | 312 | if (hidraw->open) { |
313 | hid_hw_close(hidraw->hid); | ||
314 | wake_up_interruptible(&hidraw->wait); | 314 | wake_up_interruptible(&hidraw->wait); |
315 | } | ||
315 | } else { | 316 | } else { |
316 | --hidraw->open; | 317 | --hidraw->open; |
317 | } | 318 | } |
318 | 319 | if (!hidraw->open) { | |
319 | if (!hidraw->open && !hidraw->exist) { | 320 | if (!hidraw->exist) { |
320 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | 321 | device_destroy(hidraw_class, |
321 | hidraw_table[hidraw->minor] = NULL; | 322 | MKDEV(hidraw_major, hidraw->minor)); |
322 | kfree(hidraw); | 323 | hidraw_table[hidraw->minor] = NULL; |
324 | kfree(hidraw); | ||
325 | } else { | ||
326 | /* close device for last reader */ | ||
327 | hid_hw_power(hidraw->hid, PM_HINT_NORMAL); | ||
328 | hid_hw_close(hidraw->hid); | ||
329 | } | ||
323 | } | 330 | } |
324 | } | 331 | } |
325 | 332 | ||