aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-12-24 01:16:41 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-12-24 01:16:41 -0500
commit17eb9d62828c3688f41f31ac00d7fee6da9675bf (patch)
tree03da91192242b6467d4f2d9d0b26f11f4da55c0c /drivers/platform/x86
parent76e7461a21dfe13565b2a323b53c8cc963541126 (diff)
parentf34548cb735b7a80bbbb0bdd09ad4c2173ba92d5 (diff)
Merge branches 'sh/g3-prep' and 'sh/stable-updates'
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c30
-rw-r--r--drivers/platform/x86/sony-laptop.c56
2 files changed, 44 insertions, 42 deletions
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index bcd4ba8be7db..b66029bd75d0 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -164,7 +164,7 @@ struct fujitsu_hotkey_t {
164 struct input_dev *input; 164 struct input_dev *input;
165 char phys[32]; 165 char phys[32];
166 struct platform_device *pf_device; 166 struct platform_device *pf_device;
167 struct kfifo *fifo; 167 struct kfifo fifo;
168 spinlock_t fifo_lock; 168 spinlock_t fifo_lock;
169 int rfkill_supported; 169 int rfkill_supported;
170 int rfkill_state; 170 int rfkill_state;
@@ -824,12 +824,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
824 824
825 /* kfifo */ 825 /* kfifo */
826 spin_lock_init(&fujitsu_hotkey->fifo_lock); 826 spin_lock_init(&fujitsu_hotkey->fifo_lock);
827 fujitsu_hotkey->fifo = 827 error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int),
828 kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL, 828 GFP_KERNEL);
829 &fujitsu_hotkey->fifo_lock); 829 if (error) {
830 if (IS_ERR(fujitsu_hotkey->fifo)) {
831 printk(KERN_ERR "kfifo_alloc failed\n"); 830 printk(KERN_ERR "kfifo_alloc failed\n");
832 error = PTR_ERR(fujitsu_hotkey->fifo);
833 goto err_stop; 831 goto err_stop;
834 } 832 }
835 833
@@ -934,7 +932,7 @@ err_unregister_input_dev:
934err_free_input_dev: 932err_free_input_dev:
935 input_free_device(input); 933 input_free_device(input);
936err_free_fifo: 934err_free_fifo:
937 kfifo_free(fujitsu_hotkey->fifo); 935 kfifo_free(&fujitsu_hotkey->fifo);
938err_stop: 936err_stop:
939 return result; 937 return result;
940} 938}
@@ -956,7 +954,7 @@ static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
956 954
957 input_free_device(input); 955 input_free_device(input);
958 956
959 kfifo_free(fujitsu_hotkey->fifo); 957 kfifo_free(&fujitsu_hotkey->fifo);
960 958
961 fujitsu_hotkey->acpi_handle = NULL; 959 fujitsu_hotkey->acpi_handle = NULL;
962 960
@@ -1008,9 +1006,10 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
1008 vdbg_printk(FUJLAPTOP_DBG_TRACE, 1006 vdbg_printk(FUJLAPTOP_DBG_TRACE,
1009 "Push keycode into ringbuffer [%d]\n", 1007 "Push keycode into ringbuffer [%d]\n",
1010 keycode); 1008 keycode);
1011 status = kfifo_put(fujitsu_hotkey->fifo, 1009 status = kfifo_in_locked(&fujitsu_hotkey->fifo,
1012 (unsigned char *)&keycode, 1010 (unsigned char *)&keycode,
1013 sizeof(keycode)); 1011 sizeof(keycode),
1012 &fujitsu_hotkey->fifo_lock);
1014 if (status != sizeof(keycode)) { 1013 if (status != sizeof(keycode)) {
1015 vdbg_printk(FUJLAPTOP_DBG_WARN, 1014 vdbg_printk(FUJLAPTOP_DBG_WARN,
1016 "Could not push keycode [0x%x]\n", 1015 "Could not push keycode [0x%x]\n",
@@ -1021,11 +1020,12 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
1021 } 1020 }
1022 } else if (keycode == 0) { 1021 } else if (keycode == 0) {
1023 while ((status = 1022 while ((status =
1024 kfifo_get 1023 kfifo_out_locked(
1025 (fujitsu_hotkey->fifo, (unsigned char *) 1024 &fujitsu_hotkey->fifo,
1026 &keycode_r, 1025 (unsigned char *) &keycode_r,
1027 sizeof 1026 sizeof(keycode_r),
1028 (keycode_r))) == sizeof(keycode_r)) { 1027 &fujitsu_hotkey->fifo_lock))
1028 == sizeof(keycode_r)) {
1029 input_report_key(input, keycode_r, 0); 1029 input_report_key(input, keycode_r, 0);
1030 input_sync(input); 1030 input_sync(input);
1031 vdbg_printk(FUJLAPTOP_DBG_TRACE, 1031 vdbg_printk(FUJLAPTOP_DBG_TRACE,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 7a2cc8a5c975..2896ca4cd9ab 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -142,7 +142,7 @@ struct sony_laptop_input_s {
142 atomic_t users; 142 atomic_t users;
143 struct input_dev *jog_dev; 143 struct input_dev *jog_dev;
144 struct input_dev *key_dev; 144 struct input_dev *key_dev;
145 struct kfifo *fifo; 145 struct kfifo fifo;
146 spinlock_t fifo_lock; 146 spinlock_t fifo_lock;
147 struct workqueue_struct *wq; 147 struct workqueue_struct *wq;
148}; 148};
@@ -300,8 +300,9 @@ static void do_sony_laptop_release_key(struct work_struct *work)
300{ 300{
301 struct sony_laptop_keypress kp; 301 struct sony_laptop_keypress kp;
302 302
303 while (kfifo_get(sony_laptop_input.fifo, (unsigned char *)&kp, 303 while (kfifo_out_locked(&sony_laptop_input.fifo, (unsigned char *)&kp,
304 sizeof(kp)) == sizeof(kp)) { 304 sizeof(kp), &sony_laptop_input.fifo_lock)
305 == sizeof(kp)) {
305 msleep(10); 306 msleep(10);
306 input_report_key(kp.dev, kp.key, 0); 307 input_report_key(kp.dev, kp.key, 0);
307 input_sync(kp.dev); 308 input_sync(kp.dev);
@@ -362,8 +363,9 @@ static void sony_laptop_report_input_event(u8 event)
362 /* we emit the scancode so we can always remap the key */ 363 /* we emit the scancode so we can always remap the key */
363 input_event(kp.dev, EV_MSC, MSC_SCAN, event); 364 input_event(kp.dev, EV_MSC, MSC_SCAN, event);
364 input_sync(kp.dev); 365 input_sync(kp.dev);
365 kfifo_put(sony_laptop_input.fifo, 366 kfifo_in_locked(&sony_laptop_input.fifo,
366 (unsigned char *)&kp, sizeof(kp)); 367 (unsigned char *)&kp, sizeof(kp),
368 &sony_laptop_input.fifo_lock);
367 369
368 if (!work_pending(&sony_laptop_release_key_work)) 370 if (!work_pending(&sony_laptop_release_key_work))
369 queue_work(sony_laptop_input.wq, 371 queue_work(sony_laptop_input.wq,
@@ -385,12 +387,10 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
385 387
386 /* kfifo */ 388 /* kfifo */
387 spin_lock_init(&sony_laptop_input.fifo_lock); 389 spin_lock_init(&sony_laptop_input.fifo_lock);
388 sony_laptop_input.fifo = 390 error =
389 kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, 391 kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
390 &sony_laptop_input.fifo_lock); 392 if (error) {
391 if (IS_ERR(sony_laptop_input.fifo)) {
392 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); 393 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
393 error = PTR_ERR(sony_laptop_input.fifo);
394 goto err_dec_users; 394 goto err_dec_users;
395 } 395 }
396 396
@@ -474,7 +474,7 @@ err_destroy_wq:
474 destroy_workqueue(sony_laptop_input.wq); 474 destroy_workqueue(sony_laptop_input.wq);
475 475
476err_free_kfifo: 476err_free_kfifo:
477 kfifo_free(sony_laptop_input.fifo); 477 kfifo_free(&sony_laptop_input.fifo);
478 478
479err_dec_users: 479err_dec_users:
480 atomic_dec(&sony_laptop_input.users); 480 atomic_dec(&sony_laptop_input.users);
@@ -500,7 +500,7 @@ static void sony_laptop_remove_input(void)
500 } 500 }
501 501
502 destroy_workqueue(sony_laptop_input.wq); 502 destroy_workqueue(sony_laptop_input.wq);
503 kfifo_free(sony_laptop_input.fifo); 503 kfifo_free(&sony_laptop_input.fifo);
504} 504}
505 505
506/*********** Platform Device ***********/ 506/*********** Platform Device ***********/
@@ -2079,7 +2079,7 @@ static struct attribute_group spic_attribute_group = {
2079 2079
2080struct sonypi_compat_s { 2080struct sonypi_compat_s {
2081 struct fasync_struct *fifo_async; 2081 struct fasync_struct *fifo_async;
2082 struct kfifo *fifo; 2082 struct kfifo fifo;
2083 spinlock_t fifo_lock; 2083 spinlock_t fifo_lock;
2084 wait_queue_head_t fifo_proc_list; 2084 wait_queue_head_t fifo_proc_list;
2085 atomic_t open_count; 2085 atomic_t open_count;
@@ -2104,12 +2104,12 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
2104 /* Flush input queue on first open */ 2104 /* Flush input queue on first open */
2105 unsigned long flags; 2105 unsigned long flags;
2106 2106
2107 spin_lock_irqsave(sonypi_compat.fifo->lock, flags); 2107 spin_lock_irqsave(&sonypi_compat.fifo_lock, flags);
2108 2108
2109 if (atomic_inc_return(&sonypi_compat.open_count) == 1) 2109 if (atomic_inc_return(&sonypi_compat.open_count) == 1)
2110 __kfifo_reset(sonypi_compat.fifo); 2110 kfifo_reset(&sonypi_compat.fifo);
2111 2111
2112 spin_unlock_irqrestore(sonypi_compat.fifo->lock, flags); 2112 spin_unlock_irqrestore(&sonypi_compat.fifo_lock, flags);
2113 2113
2114 return 0; 2114 return 0;
2115} 2115}
@@ -2120,17 +2120,18 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
2120 ssize_t ret; 2120 ssize_t ret;
2121 unsigned char c; 2121 unsigned char c;
2122 2122
2123 if ((kfifo_len(sonypi_compat.fifo) == 0) && 2123 if ((kfifo_len(&sonypi_compat.fifo) == 0) &&
2124 (file->f_flags & O_NONBLOCK)) 2124 (file->f_flags & O_NONBLOCK))
2125 return -EAGAIN; 2125 return -EAGAIN;
2126 2126
2127 ret = wait_event_interruptible(sonypi_compat.fifo_proc_list, 2127 ret = wait_event_interruptible(sonypi_compat.fifo_proc_list,
2128 kfifo_len(sonypi_compat.fifo) != 0); 2128 kfifo_len(&sonypi_compat.fifo) != 0);
2129 if (ret) 2129 if (ret)
2130 return ret; 2130 return ret;
2131 2131
2132 while (ret < count && 2132 while (ret < count &&
2133 (kfifo_get(sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) { 2133 (kfifo_out_locked(&sonypi_compat.fifo, &c, sizeof(c),
2134 &sonypi_compat.fifo_lock) == sizeof(c))) {
2134 if (put_user(c, buf++)) 2135 if (put_user(c, buf++))
2135 return -EFAULT; 2136 return -EFAULT;
2136 ret++; 2137 ret++;
@@ -2147,7 +2148,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
2147static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait) 2148static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
2148{ 2149{
2149 poll_wait(file, &sonypi_compat.fifo_proc_list, wait); 2150 poll_wait(file, &sonypi_compat.fifo_proc_list, wait);
2150 if (kfifo_len(sonypi_compat.fifo)) 2151 if (kfifo_len(&sonypi_compat.fifo))
2151 return POLLIN | POLLRDNORM; 2152 return POLLIN | POLLRDNORM;
2152 return 0; 2153 return 0;
2153} 2154}
@@ -2309,7 +2310,8 @@ static struct miscdevice sonypi_misc_device = {
2309 2310
2310static void sonypi_compat_report_event(u8 event) 2311static void sonypi_compat_report_event(u8 event)
2311{ 2312{
2312 kfifo_put(sonypi_compat.fifo, (unsigned char *)&event, sizeof(event)); 2313 kfifo_in_locked(&sonypi_compat.fifo, (unsigned char *)&event,
2314 sizeof(event), &sonypi_compat.fifo_lock);
2313 kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN); 2315 kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
2314 wake_up_interruptible(&sonypi_compat.fifo_proc_list); 2316 wake_up_interruptible(&sonypi_compat.fifo_proc_list);
2315} 2317}
@@ -2319,11 +2321,11 @@ static int sonypi_compat_init(void)
2319 int error; 2321 int error;
2320 2322
2321 spin_lock_init(&sonypi_compat.fifo_lock); 2323 spin_lock_init(&sonypi_compat.fifo_lock);
2322 sonypi_compat.fifo = kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL, 2324 error =
2323 &sonypi_compat.fifo_lock); 2325 kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
2324 if (IS_ERR(sonypi_compat.fifo)) { 2326 if (error) {
2325 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); 2327 printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
2326 return PTR_ERR(sonypi_compat.fifo); 2328 return error;
2327 } 2329 }
2328 2330
2329 init_waitqueue_head(&sonypi_compat.fifo_proc_list); 2331 init_waitqueue_head(&sonypi_compat.fifo_proc_list);
@@ -2342,14 +2344,14 @@ static int sonypi_compat_init(void)
2342 return 0; 2344 return 0;
2343 2345
2344err_free_kfifo: 2346err_free_kfifo:
2345 kfifo_free(sonypi_compat.fifo); 2347 kfifo_free(&sonypi_compat.fifo);
2346 return error; 2348 return error;
2347} 2349}
2348 2350
2349static void sonypi_compat_exit(void) 2351static void sonypi_compat_exit(void)
2350{ 2352{
2351 misc_deregister(&sonypi_misc_device); 2353 misc_deregister(&sonypi_misc_device);
2352 kfifo_free(sonypi_compat.fifo); 2354 kfifo_free(&sonypi_compat.fifo);
2353} 2355}
2354#else 2356#else
2355static int sonypi_compat_init(void) { return 0; } 2357static int sonypi_compat_init(void) { return 0; }