diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-12-14 18:44:36 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-12-14 18:44:36 +0100 |
| commit | 9305526d84391e7f3752119c9c9bbfa9433745a2 (patch) | |
| tree | 4bd5fdc9142fb87c203d9fc1b388c1d9b572faed /usr/src/dkms_source_tree/hidraw.c | |
| parent | 164aff3db49c55476492de9d9aa7fb9637868b98 (diff) | |
upgrade to natty (2.6.37-9)
Diffstat (limited to 'usr/src/dkms_source_tree/hidraw.c')
| -rw-r--r-- | usr/src/dkms_source_tree/hidraw.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/usr/src/dkms_source_tree/hidraw.c b/usr/src/dkms_source_tree/hidraw.c index 3ccd478..e1f0748 100644 --- a/usr/src/dkms_source_tree/hidraw.c +++ b/usr/src/dkms_source_tree/hidraw.c | |||
| @@ -32,7 +32,6 @@ | |||
| 32 | #include <linux/hid.h> | 32 | #include <linux/hid.h> |
| 33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
| 34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
| 35 | #include <linux/smp_lock.h> | ||
| 36 | 35 | ||
| 37 | #include <linux/hidraw.h> | 36 | #include <linux/hidraw.h> |
| 38 | 37 | ||
| @@ -46,7 +45,6 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, | |||
| 46 | { | 45 | { |
| 47 | struct hidraw_list *list = file->private_data; | 46 | struct hidraw_list *list = file->private_data; |
| 48 | int ret = 0, len; | 47 | int ret = 0, len; |
| 49 | char *report; | ||
| 50 | DECLARE_WAITQUEUE(wait, current); | 48 | DECLARE_WAITQUEUE(wait, current); |
| 51 | 49 | ||
| 52 | mutex_lock(&list->read_mutex); | 50 | mutex_lock(&list->read_mutex); |
| @@ -84,7 +82,6 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, | |||
| 84 | if (ret) | 82 | if (ret) |
| 85 | goto out; | 83 | goto out; |
| 86 | 84 | ||
| 87 | report = list->buffer[list->tail].value; | ||
| 88 | len = list->buffer[list->tail].len > count ? | 85 | len = list->buffer[list->tail].len > count ? |
| 89 | count : list->buffer[list->tail].len; | 86 | count : list->buffer[list->tail].len; |
| 90 | 87 | ||
| @@ -111,6 +108,12 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t | |||
| 111 | int ret = 0; | 108 | int ret = 0; |
| 112 | 109 | ||
| 113 | mutex_lock(&minors_lock); | 110 | mutex_lock(&minors_lock); |
| 111 | |||
| 112 | if (!hidraw_table[minor]) { | ||
| 113 | ret = -ENODEV; | ||
| 114 | goto out; | ||
| 115 | } | ||
| 116 | |||
| 114 | dev = hidraw_table[minor]->hid; | 117 | dev = hidraw_table[minor]->hid; |
| 115 | 118 | ||
| 116 | if (!dev->hid_output_raw_report) { | 119 | if (!dev->hid_output_raw_report) { |
| @@ -214,9 +217,13 @@ static int hidraw_release(struct inode * inode, struct file * file) | |||
| 214 | unsigned int minor = iminor(inode); | 217 | unsigned int minor = iminor(inode); |
| 215 | struct hidraw *dev; | 218 | struct hidraw *dev; |
| 216 | struct hidraw_list *list = file->private_data; | 219 | struct hidraw_list *list = file->private_data; |
| 220 | int ret; | ||
| 217 | 221 | ||
| 218 | if (!hidraw_table[minor]) | 222 | mutex_lock(&minors_lock); |
| 219 | return -ENODEV; | 223 | if (!hidraw_table[minor]) { |
| 224 | ret = -ENODEV; | ||
| 225 | goto unlock; | ||
| 226 | } | ||
| 220 | 227 | ||
| 221 | list_del(&list->node); | 228 | list_del(&list->node); |
| 222 | dev = hidraw_table[minor]; | 229 | dev = hidraw_table[minor]; |
| @@ -229,10 +236,12 @@ static int hidraw_release(struct inode * inode, struct file * file) | |||
| 229 | kfree(list->hidraw); | 236 | kfree(list->hidraw); |
| 230 | } | 237 | } |
| 231 | } | 238 | } |
| 232 | |||
| 233 | kfree(list); | 239 | kfree(list); |
| 240 | ret = 0; | ||
| 241 | unlock: | ||
| 242 | mutex_unlock(&minors_lock); | ||
| 234 | 243 | ||
| 235 | return 0; | 244 | return ret; |
| 236 | } | 245 | } |
| 237 | 246 | ||
| 238 | static long hidraw_ioctl(struct file *file, unsigned int cmd, | 247 | static long hidraw_ioctl(struct file *file, unsigned int cmd, |
| @@ -246,6 +255,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
| 246 | 255 | ||
| 247 | mutex_lock(&minors_lock); | 256 | mutex_lock(&minors_lock); |
| 248 | dev = hidraw_table[minor]; | 257 | dev = hidraw_table[minor]; |
| 258 | if (!dev) { | ||
| 259 | ret = -ENODEV; | ||
| 260 | goto out; | ||
| 261 | } | ||
| 249 | 262 | ||
| 250 | switch (cmd) { | 263 | switch (cmd) { |
| 251 | case HIDIOCGRDESCSIZE: | 264 | case HIDIOCGRDESCSIZE: |
| @@ -319,6 +332,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
| 319 | 332 | ||
| 320 | ret = -ENOTTY; | 333 | ret = -ENOTTY; |
| 321 | } | 334 | } |
| 335 | out: | ||
| 322 | mutex_unlock(&minors_lock); | 336 | mutex_unlock(&minors_lock); |
| 323 | return ret; | 337 | return ret; |
| 324 | } | 338 | } |
| @@ -331,6 +345,7 @@ static const struct file_operations hidraw_ops = { | |||
| 331 | .open = hidraw_open, | 345 | .open = hidraw_open, |
| 332 | .release = hidraw_release, | 346 | .release = hidraw_release, |
| 333 | .unlocked_ioctl = hidraw_ioctl, | 347 | .unlocked_ioctl = hidraw_ioctl, |
| 348 | .llseek = noop_llseek, | ||
| 334 | }; | 349 | }; |
| 335 | 350 | ||
| 336 | void hidraw_report_event(struct hid_device *hid, u8 *data, int len) | 351 | void hidraw_report_event(struct hid_device *hid, u8 *data, int len) |
