Merge branch 'timers/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / misc / sony-laptop.c
index 899e3f7..60775be 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/types.h>
 #include <linux/backlight.h>
 #include <linux/platform_device.h>
@@ -315,7 +316,7 @@ static void sony_laptop_report_input_event(u8 event)
                break;
 
        default:
-               if (event > ARRAY_SIZE(sony_laptop_input_index)) {
+               if (event >= ARRAY_SIZE(sony_laptop_input_index)) {
                        dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
                        break;
                }
@@ -961,7 +962,7 @@ static int sony_nc_resume(struct acpi_device *device)
                ret = acpi_callsetfunc(sony_nc_acpi_handle, *item->acpiset,
                                       item->value, NULL);
                if (ret < 0) {
-                       printk("%s: %d\n", __FUNCTION__, ret);
+                       printk("%s: %d\n", __func__, ret);
                        break;
                }
        }
@@ -1453,7 +1454,7 @@ static struct sonypi_eventtypes type4_events[] = {
                udelay(1);                                              \
        if (!n)                                                         \
                dprintk("command failed at %s : %s (line %d)\n",        \
-                               __FILE__, __FUNCTION__, __LINE__);      \
+                               __FILE__, __func__, __LINE__);  \
 }
 
 static u8 sony_pic_call1(u8 dev)
@@ -1927,8 +1928,10 @@ static int sonypi_misc_release(struct inode *inode, struct file *file)
 static int sonypi_misc_open(struct inode *inode, struct file *file)
 {
        /* Flush input queue on first open */
+       lock_kernel();
        if (atomic_inc_return(&sonypi_compat.open_count) == 1)
                kfifo_reset(sonypi_compat.fifo);
+       unlock_kernel();
        return 0;
 }