diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-12-08 02:02:48 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-12-08 08:35:14 -0500 |
commit | 5bea7660bba973dc5e8e9d92b11fb1dd5b524ebf (patch) | |
tree | 511ae632c2d2c22d94956ed2d236bd8654d27ff0 /drivers/hid/hidraw.c | |
parent | 33d6eb570b1f3fe5ba93cef465c5be66535c2c9a (diff) |
HID: add hid_hw_open/close/power() handlers
Instead of exposing the guts of hid->ll_driver relationship to HID
sub-drivers provide these helpers to encapsulate the details.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r-- | drivers/hid/hidraw.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 8a4b32dca9f7..5aefe73cf795 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -193,15 +193,13 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
193 | 193 | ||
194 | dev = hidraw_table[minor]; | 194 | dev = hidraw_table[minor]; |
195 | if (!dev->open++) { | 195 | if (!dev->open++) { |
196 | if (dev->hid->ll_driver->power) { | 196 | err = hid_hw_power(dev->hid, PM_HINT_FULLON); |
197 | err = dev->hid->ll_driver->power(dev->hid, PM_HINT_FULLON); | 197 | if (err < 0) |
198 | if (err < 0) | 198 | goto out_unlock; |
199 | goto out_unlock; | 199 | |
200 | } | 200 | err = hid_hw_open(dev->hid); |
201 | err = dev->hid->ll_driver->open(dev->hid); | ||
202 | if (err < 0) { | 201 | if (err < 0) { |
203 | if (dev->hid->ll_driver->power) | 202 | hid_hw_power(dev->hid, PM_HINT_NORMAL); |
204 | dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL); | ||
205 | dev->open--; | 203 | dev->open--; |
206 | } | 204 | } |
207 | } | 205 | } |
@@ -230,9 +228,8 @@ static int hidraw_release(struct inode * inode, struct file * file) | |||
230 | dev = hidraw_table[minor]; | 228 | dev = hidraw_table[minor]; |
231 | if (!--dev->open) { | 229 | if (!--dev->open) { |
232 | if (list->hidraw->exist) { | 230 | if (list->hidraw->exist) { |
233 | if (dev->hid->ll_driver->power) | 231 | hid_hw_power(dev->hid, PM_HINT_NORMAL); |
234 | dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL); | 232 | hid_hw_close(dev->hid); |
235 | dev->hid->ll_driver->close(dev->hid); | ||
236 | } else { | 233 | } else { |
237 | kfree(list->hidraw); | 234 | kfree(list->hidraw); |
238 | } | 235 | } |
@@ -434,7 +431,7 @@ void hidraw_disconnect(struct hid_device *hid) | |||
434 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | 431 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); |
435 | 432 | ||
436 | if (hidraw->open) { | 433 | if (hidraw->open) { |
437 | hid->ll_driver->close(hid); | 434 | hid_hw_close(hid); |
438 | wake_up_interruptible(&hidraw->wait); | 435 | wake_up_interruptible(&hidraw->wait); |
439 | } else { | 436 | } else { |
440 | kfree(hidraw); | 437 | kfree(hidraw); |