aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-12-08 02:02:48 -0500
committerJiri Kosina <jkosina@suse.cz>2010-12-08 08:35:14 -0500
commit5bea7660bba973dc5e8e9d92b11fb1dd5b524ebf (patch)
tree511ae632c2d2c22d94956ed2d236bd8654d27ff0 /drivers
parent33d6eb570b1f3fe5ba93cef465c5be66535c2c9a (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')
-rw-r--r--drivers/hid/hid-input.c4
-rw-r--r--drivers/hid/hid-picolcd.c6
-rw-r--r--drivers/hid/hid-roccat.c26
-rw-r--r--drivers/hid/hidraw.c21
4 files changed, 24 insertions, 33 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 834ef47b76d6..b718f7144ce1 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -772,14 +772,14 @@ static int hidinput_open(struct input_dev *dev)
772{ 772{
773 struct hid_device *hid = input_get_drvdata(dev); 773 struct hid_device *hid = input_get_drvdata(dev);
774 774
775 return hid->ll_driver->open(hid); 775 return hid_hw_open(hid);
776} 776}
777 777
778static void hidinput_close(struct input_dev *dev) 778static void hidinput_close(struct input_dev *dev)
779{ 779{
780 struct hid_device *hid = input_get_drvdata(dev); 780 struct hid_device *hid = input_get_drvdata(dev);
781 781
782 hid->ll_driver->close(hid); 782 hid_hw_close(hid);
783} 783}
784 784
785/* 785/*
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index bc2e07740628..38565fee7bf1 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -2635,7 +2635,7 @@ static int picolcd_probe(struct hid_device *hdev,
2635 goto err_cleanup_data; 2635 goto err_cleanup_data;
2636 } 2636 }
2637 2637
2638 error = hdev->ll_driver->open(hdev); 2638 error = hid_hw_open(hdev);
2639 if (error) { 2639 if (error) {
2640 dev_err(&hdev->dev, "failed to open input interrupt pipe for key and IR events\n"); 2640 dev_err(&hdev->dev, "failed to open input interrupt pipe for key and IR events\n");
2641 goto err_cleanup_hid_hw; 2641 goto err_cleanup_hid_hw;
@@ -2668,7 +2668,7 @@ err_cleanup_sysfs2:
2668err_cleanup_sysfs1: 2668err_cleanup_sysfs1:
2669 device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); 2669 device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
2670err_cleanup_hid_ll: 2670err_cleanup_hid_ll:
2671 hdev->ll_driver->close(hdev); 2671 hid_hw_close(hdev);
2672err_cleanup_hid_hw: 2672err_cleanup_hid_hw:
2673 hid_hw_stop(hdev); 2673 hid_hw_stop(hdev);
2674err_cleanup_data: 2674err_cleanup_data:
@@ -2699,7 +2699,7 @@ static void picolcd_remove(struct hid_device *hdev)
2699 picolcd_exit_devfs(data); 2699 picolcd_exit_devfs(data);
2700 device_remove_file(&hdev->dev, &dev_attr_operation_mode); 2700 device_remove_file(&hdev->dev, &dev_attr_operation_mode);
2701 device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); 2701 device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
2702 hdev->ll_driver->close(hdev); 2702 hid_hw_close(hdev);
2703 hid_hw_stop(hdev); 2703 hid_hw_stop(hdev);
2704 hid_set_drvdata(hdev, NULL); 2704 hid_set_drvdata(hdev, NULL);
2705 2705
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index 5a6879e235ac..a9d9b29ff47f 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -173,19 +173,15 @@ static int roccat_open(struct inode *inode, struct file *file)
173 173
174 if (!device->open++) { 174 if (!device->open++) {
175 /* power on device on adding first reader */ 175 /* power on device on adding first reader */
176 if (device->hid->ll_driver->power) { 176 error = hid_hw_power(device->hid, PM_HINT_FULLON);
177 error = device->hid->ll_driver->power(device->hid, 177 if (error < 0) {
178 PM_HINT_FULLON); 178 --device->open;
179 if (error < 0) { 179 goto exit_err;
180 --device->open;
181 goto exit_err;
182 }
183 } 180 }
184 error = device->hid->ll_driver->open(device->hid); 181
182 error = hid_hw_open(device->hid);
185 if (error < 0) { 183 if (error < 0) {
186 if (device->hid->ll_driver->power) 184 hid_hw_power(device->hid, PM_HINT_NORMAL);
187 device->hid->ll_driver->power(device->hid,
188 PM_HINT_NORMAL);
189 --device->open; 185 --device->open;
190 goto exit_err; 186 goto exit_err;
191 } 187 }
@@ -231,10 +227,8 @@ static int roccat_release(struct inode *inode, struct file *file)
231 if (!--device->open) { 227 if (!--device->open) {
232 /* removing last reader */ 228 /* removing last reader */
233 if (device->exist) { 229 if (device->exist) {
234 if (device->hid->ll_driver->power) 230 hid_hw_power(device->hid, PM_HINT_NORMAL);
235 device->hid->ll_driver->power(device->hid, 231 hid_hw_close(device->hid);
236 PM_HINT_NORMAL);
237 device->hid->ll_driver->close(device->hid);
238 } else { 232 } else {
239 kfree(device); 233 kfree(device);
240 } 234 }
@@ -370,7 +364,7 @@ void roccat_disconnect(int minor)
370 device_destroy(roccat_class, MKDEV(roccat_major, minor)); 364 device_destroy(roccat_class, MKDEV(roccat_major, minor));
371 365
372 if (device->open) { 366 if (device->open) {
373 device->hid->ll_driver->close(device->hid); 367 hid_hw_close(device->hid);
374 wake_up_interruptible(&device->wait); 368 wake_up_interruptible(&device->wait);
375 } else { 369 } else {
376 kfree(device); 370 kfree(device);
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);