Signed-off-by: Alan Cox <alan@redhat.com>
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c
index 4fe9206..1690cfb 100644
--- a/drivers/char/lcd.c
+++ b/drivers/char/lcd.c
@@ -21,15 +21,15 @@
#include <linux/netdevice.h>
#include <linux/sched.h>
#include <linux/delay.h>
+#include <linux/smp_lock.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
#include <asm/system.h>
#include "lcd.h"
-static int lcd_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static unsigned int lcd_present = 1;
@@ -54,11 +54,13 @@ int lcd_register_linkcheck_func(int iface_num, void *func, void *cookie)
}
#endif
-static int lcd_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct lcd_display button_display;
unsigned long address, a;
+ long ret = 0;
+
+ lock_kernel();
switch (cmd) {
case LCD_On:
@@ -135,7 +137,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
- return -EFAULT;
+ ret = -EFAULT;
break;
}
@@ -147,14 +149,13 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
- return -EFAULT;
-
- a = (display.cursor_address | kLCD_Addr);
-
- udelay(150);
- BusyCheck();
- LCDWriteInst(a);
-
+ ret = -EFAULT;
+ else {
+ a = (display.cursor_address | kLCD_Addr);
+ udelay(150);
+ BusyCheck();
+ LCDWriteInst(a);
+ }
break;
}
@@ -168,11 +169,12 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
- return -EFAULT;
- udelay(150);
- BusyCheck();
- LCDWriteInst(0x10);
-
+ ret = -EFAULT;
+ else {
+ udelay(150);
+ BusyCheck();
+ LCDWriteInst(0x10);
+ }
break;
}
@@ -182,15 +184,15 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
- return -EFAULT;
-
- udelay(150);
- BusyCheck();
- LCDWriteData(display.character);
- udelay(150);
- BusyCheck();
- LCDWriteInst(0x10);
-
+ ret = -EFAULT;
+ else {
+ udelay(150);
+ BusyCheck();
+ LCDWriteData(display.character);
+ udelay(150);
+ BusyCheck();
+ LCDWriteInst(0x10);
+ }
break;
}
@@ -220,8 +222,10 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&display, (struct lcd_display *) arg,
- sizeof(struct lcd_display)))
- return -EFAULT;
+ sizeof(struct lcd_display))) {
+ ret = -EFAULT;
+ break;
+ }
udelay(150);
BusyCheck();
@@ -287,7 +291,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_to_user
((struct lcd_display *) arg, &display,
sizeof(struct lcd_display)))
- return -EFAULT;
+ ret = -EFAULT;
break;
}
@@ -300,10 +304,11 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
- return -EFAULT;
-
- led_state = led_display.leds;
- LEDSet(led_state);
+ ret = -EFAULT;
+ else {
+ led_state = led_display.leds;
+ LEDSet(led_state);
+ }
break;
}
@@ -320,14 +325,15 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
- return -EFAULT;
-
- for (i = 0; i < (int) led_display.leds; i++) {
- bit = 2 * bit;
+ ret = -EFAULT;
+ else {
+ for (i = 0; i < (int) led_display.leds; i++) {
+ bit = 2 * bit;
+ }
+
+ led_state = led_state | bit;
+ LEDSet(led_state);
}
-
- led_state = led_state | bit;
- LEDSet(led_state);
break;
}
@@ -342,14 +348,15 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user
(&led_display, (struct lcd_display *) arg,
sizeof(struct lcd_display)))
- return -EFAULT;
-
- for (i = 0; i < (int) led_display.leds; i++) {
- bit = 2 * bit;
+ ret = -EFAULT;
+ else {
+ for (i = 0; i < (int) led_display.leds; i++) {
+ bit = 2 * bit;
+ }
+
+ led_state = led_state & ~bit;
+ LEDSet(led_state);
}
-
- led_state = led_state & ~bit;
- LEDSet(led_state);
break;
}
@@ -359,7 +366,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
- return -EFAULT;
+ ret = -EFAULT;
break;
}
@@ -369,7 +376,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
- return -EFAULT;
+ ret = -EFAULT;
break;
}
@@ -382,8 +389,10 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
*/
if (copy_from_user
(&button_display, (struct lcd_display *) arg,
- sizeof(button_display)))
- return -EFAULT;
+ sizeof(button_display))) {
+ ret = -EFAULT;
+ break;
+ }
iface_num = button_display.buttons;
#if defined(CONFIG_TULIP) && 0
if (iface_num >= 0 &&
@@ -399,17 +408,15 @@ static int lcd_ioctl(struct inode *inode, struct file *file,
if (__copy_to_user
((struct lcd_display *) arg, &button_display,
sizeof(struct lcd_display)))
- return -EFAULT;
+ ret = -EFAULT;
break;
}
default:
- return -EINVAL;
-
+ ret = -ENOTTY;
}
-
- return 0;
-
+ lock_kernel();
+ return ret;
}
static int lcd_open(struct inode *inode, struct file *file)
@@ -462,7 +469,7 @@ static ssize_t lcd_read(struct file *file, char *buf,
static const struct file_operations lcd_fops = {
.read = lcd_read,
- .ioctl = lcd_ioctl,
+ .unlocked_ioctl = lcd_ioctl,
.open = lcd_open,
};
--
| Ingo Molnar | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
| Greg Kroah-Hartman | [PATCH 014/196] kobject: remove incorrect comment in kobject_rename |
| Linus Torvalds | Linux 2.6.27-rc8 |
| Tony Lindgren | [PATCH 32/90] ARM: OMAP: Basic support for siemens sx1 |
git: | |
| Andy Parkins | svn:externals using git submodules |
| Peter Stahlir | Git as a filesystem |
| Jakub Narebski | Re: VCS comparison table |
| Linus Torvalds | Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Richard Stallman | Real men don't attack straw men |
| Alexey Suslikov | OT: OpenBSD on Asus eeePC |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Jozsef Kadlecsik | Re: TCP connection stalls under 2.6.24.7 |
| Jarek Poplawski | [PATCH take2][NET] ifb: set separate lockdep classes for queue locks |
| Stephen Hemminger | [RFC] TCP illinois max rtt aging |
