aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hidraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r--drivers/hid/hidraw.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index e1f07483691f..468e87b53ed2 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -19,6 +19,8 @@
19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/fs.h> 24#include <linux/fs.h>
23#include <linux/module.h> 25#include <linux/module.h>
24#include <linux/errno.h> 26#include <linux/errno.h>
@@ -122,15 +124,15 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
122 } 124 }
123 125
124 if (count > HID_MAX_BUFFER_SIZE) { 126 if (count > HID_MAX_BUFFER_SIZE) {
125 printk(KERN_WARNING "hidraw: pid %d passed too large report\n", 127 hid_warn(dev, "pid %d passed too large report\n",
126 task_pid_nr(current)); 128 task_pid_nr(current));
127 ret = -EINVAL; 129 ret = -EINVAL;
128 goto out; 130 goto out;
129 } 131 }
130 132
131 if (count < 2) { 133 if (count < 2) {
132 printk(KERN_WARNING "hidraw: pid %d passed too short report\n", 134 hid_warn(dev, "pid %d passed too short report\n",
133 task_pid_nr(current)); 135 task_pid_nr(current));
134 ret = -EINVAL; 136 ret = -EINVAL;
135 goto out; 137 goto out;
136 } 138 }
@@ -192,15 +194,13 @@ static int hidraw_open(struct inode *inode, struct file *file)
192 194
193 dev = hidraw_table[minor]; 195 dev = hidraw_table[minor];
194 if (!dev->open++) { 196 if (!dev->open++) {
195 if (dev->hid->ll_driver->power) { 197 err = hid_hw_power(dev->hid, PM_HINT_FULLON);
196 err = dev->hid->ll_driver->power(dev->hid, PM_HINT_FULLON); 198 if (err < 0)
197 if (err < 0) 199 goto out_unlock;
198 goto out_unlock; 200
199 } 201 err = hid_hw_open(dev->hid);
200 err = dev->hid->ll_driver->open(dev->hid);
201 if (err < 0) { 202 if (err < 0) {
202 if (dev->hid->ll_driver->power) 203 hid_hw_power(dev->hid, PM_HINT_NORMAL);
203 dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL);
204 dev->open--; 204 dev->open--;
205 } 205 }
206 } 206 }
@@ -229,9 +229,8 @@ static int hidraw_release(struct inode * inode, struct file * file)
229 dev = hidraw_table[minor]; 229 dev = hidraw_table[minor];
230 if (!--dev->open) { 230 if (!--dev->open) {
231 if (list->hidraw->exist) { 231 if (list->hidraw->exist) {
232 if (dev->hid->ll_driver->power) 232 hid_hw_power(dev->hid, PM_HINT_NORMAL);
233 dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL); 233 hid_hw_close(dev->hid);
234 dev->hid->ll_driver->close(dev->hid);
235 } else { 234 } else {
236 kfree(list->hidraw); 235 kfree(list->hidraw);
237 } 236 }
@@ -345,6 +344,9 @@ static const struct file_operations hidraw_ops = {
345 .open = hidraw_open, 344 .open = hidraw_open,
346 .release = hidraw_release, 345 .release = hidraw_release,
347 .unlocked_ioctl = hidraw_ioctl, 346 .unlocked_ioctl = hidraw_ioctl,
347#ifdef CONFIG_COMPAT
348 .compat_ioctl = hidraw_ioctl,
349#endif
348 .llseek = noop_llseek, 350 .llseek = noop_llseek,
349}; 351};
350 352
@@ -433,7 +435,7 @@ void hidraw_disconnect(struct hid_device *hid)
433 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); 435 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
434 436
435 if (hidraw->open) { 437 if (hidraw->open) {
436 hid->ll_driver->close(hid); 438 hid_hw_close(hid);
437 wake_up_interruptible(&hidraw->wait); 439 wake_up_interruptible(&hidraw->wait);
438 } else { 440 } else {
439 kfree(hidraw); 441 kfree(hidraw);
@@ -452,7 +454,7 @@ int __init hidraw_init(void)
452 hidraw_major = MAJOR(dev_id); 454 hidraw_major = MAJOR(dev_id);
453 455
454 if (result < 0) { 456 if (result < 0) {
455 printk(KERN_WARNING "hidraw: can't get major number\n"); 457 pr_warn("can't get major number\n");
456 result = 0; 458 result = 0;
457 goto out; 459 goto out;
458 } 460 }