Quellcode durchsuchen

esp: lock_kernel push down

Push the BKL down into a few internal bits of code in this driver.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Alan Cox vor 17 Jahren
Ursprung
Commit
5a4bc8c1bd
1 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. 16 6
      drivers/char/esp.c

+ 16 - 6
drivers/char/esp.c

@@ -1355,6 +1355,7 @@ static int get_serial_info(struct esp_struct * info,
 {
 {
 	struct serial_struct tmp;
 	struct serial_struct tmp;
   
   
+	lock_kernel();
 	memset(&tmp, 0, sizeof(tmp));
 	memset(&tmp, 0, sizeof(tmp));
 	tmp.type = PORT_16550A;
 	tmp.type = PORT_16550A;
 	tmp.line = info->line;
 	tmp.line = info->line;
@@ -1367,6 +1368,7 @@ static int get_serial_info(struct esp_struct * info,
 	tmp.closing_wait = info->closing_wait;
 	tmp.closing_wait = info->closing_wait;
 	tmp.custom_divisor = info->custom_divisor;
 	tmp.custom_divisor = info->custom_divisor;
 	tmp.hub6 = 0;
 	tmp.hub6 = 0;
+	unlock_kernel();
 	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
 	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
 		return -EFAULT;
 		return -EFAULT;
 	return 0;
 	return 0;
@@ -1381,6 +1383,7 @@ static int get_esp_config(struct esp_struct * info,
 		return -EFAULT;
 		return -EFAULT;
 
 
 	memset(&tmp, 0, sizeof(tmp));
 	memset(&tmp, 0, sizeof(tmp));
+	lock_kernel();
 	tmp.rx_timeout = info->config.rx_timeout;
 	tmp.rx_timeout = info->config.rx_timeout;
 	tmp.rx_trigger = info->config.rx_trigger;
 	tmp.rx_trigger = info->config.rx_trigger;
 	tmp.tx_trigger = info->config.tx_trigger;
 	tmp.tx_trigger = info->config.tx_trigger;
@@ -1388,6 +1391,7 @@ static int get_esp_config(struct esp_struct * info,
 	tmp.flow_on = info->config.flow_on;
 	tmp.flow_on = info->config.flow_on;
 	tmp.pio_threshold = info->config.pio_threshold;
 	tmp.pio_threshold = info->config.pio_threshold;
 	tmp.dma_channel = (info->stat_flags & ESP_STAT_NEVER_DMA ? 0 : dma);
 	tmp.dma_channel = (info->stat_flags & ESP_STAT_NEVER_DMA ? 0 : dma);
+	unlock_kernel();
 
 
 	return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
 	return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
 }
 }
@@ -1766,6 +1770,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
 	struct serial_icounter_struct __user *p_cuser;	/* user space */
 	struct serial_icounter_struct __user *p_cuser;	/* user space */
 	void __user *argp = (void __user *)arg;
 	void __user *argp = (void __user *)arg;
 	unsigned long flags;
 	unsigned long flags;
+	int ret;
 
 
 	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 	if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
 		return -ENODEV;
 		return -ENODEV;
@@ -1783,7 +1788,10 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
 		case TIOCGSERIAL:
 		case TIOCGSERIAL:
 			return get_serial_info(info, argp);
 			return get_serial_info(info, argp);
 		case TIOCSSERIAL:
 		case TIOCSSERIAL:
-			return set_serial_info(info, argp);
+			lock_kernel();
+			ret = set_serial_info(info, argp);
+			unlock_kernel();
+			return ret;
 		case TIOCSERCONFIG:
 		case TIOCSERCONFIG:
 			/* do not reconfigure after initial configuration */
 			/* do not reconfigure after initial configuration */
 			return 0;
 			return 0;
@@ -1855,11 +1863,13 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
 				return -EFAULT;
 				return -EFAULT;
 
 
 			return 0;
 			return 0;
-	case TIOCGHAYESESP:
-		return get_esp_config(info, argp);
-	case TIOCSHAYESESP:
-		return set_esp_config(info, argp);
-
+		case TIOCGHAYESESP:
+			return get_esp_config(info, argp);
+		case TIOCSHAYESESP:
+			lock_kernel();
+			ret = set_esp_config(info, argp);
+			unlock_kernel();
+			return ret;
 		default:
 		default:
 			return -ENOIOCTLCMD;
 			return -ENOIOCTLCMD;
 		}
 		}