Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec79d605 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman
Browse files

tty: replace BKL with a new tty_lock



As a preparation for replacing the big kernel lock
in the TTY layer, wrap all the callers in new
macros tty_lock, tty_lock_nested and tty_unlock.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3f582b8c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1072,7 +1072,7 @@ static int get_serial_info(struct async_struct * info,
	if (!retinfo)
		return -EFAULT;
	memset(&tmp, 0, sizeof(tmp));
	lock_kernel();
	tty_lock();
	tmp.type = state->type;
	tmp.line = state->line;
	tmp.port = state->port;
@@ -1083,7 +1083,7 @@ static int get_serial_info(struct async_struct * info,
	tmp.close_delay = state->close_delay;
	tmp.closing_wait = state->closing_wait;
	tmp.custom_divisor = state->custom_divisor;
	unlock_kernel();
	tty_unlock();
	if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
		return -EFAULT;
	return 0;
@@ -1100,14 +1100,14 @@ static int set_serial_info(struct async_struct * info,
	if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
		return -EFAULT;

	lock_kernel();
	tty_lock();
	state = info->state;
	old_state = *state;
  
	change_irq = new_serial.irq != state->irq;
	change_port = (new_serial.port != state->port);
	if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) {
	  unlock_kernel();
	  tty_unlock();
	  return -EINVAL;
	}
  
@@ -1127,7 +1127,7 @@ static int set_serial_info(struct async_struct * info,
	}

	if (new_serial.baud_base < 9600) {
		unlock_kernel();
		tty_unlock();
		return -EINVAL;
	}

@@ -1163,7 +1163,7 @@ check_and_exit:
		}
	} else
		retval = startup(info);
	unlock_kernel();
	tty_unlock();
	return retval;
}

@@ -1538,7 +1538,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)

	orig_jiffies = jiffies;

	lock_kernel();
	tty_lock_nested(); /* tty_wait_until_sent is called from lots of places */
	/*
	 * Set the check interval to be 1/5 of the estimated time to
	 * send a single character, and make it at least 1.  The check
@@ -1579,7 +1579,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
			break;
	}
	__set_current_state(TASK_RUNNING);
	unlock_kernel();
	tty_unlock();
#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
	printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
#endif
+3 −3
Original line number Diff line number Diff line
@@ -67,15 +67,15 @@ static void set_led(char state)

static int briq_panel_open(struct inode *ino, struct file *filep)
{
	lock_kernel();
	tty_lock();
	/* enforce single access, vfd_is_open is protected by BKL */
	if (vfd_is_open) {
		unlock_kernel();
		tty_unlock();
		return -EBUSY;
	}
	vfd_is_open = 1;

	unlock_kernel();
	tty_unlock();
	return 0;
}

+8 −8
Original line number Diff line number Diff line
@@ -598,18 +598,18 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
		return -EFAULT;
	}

	lock_kernel();
	tty_lock();

	for (;;) {
		if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
			unlock_kernel();
			tty_unlock();
			return -EIO;
		}

		n_hdlc = tty2n_hdlc (tty);
		if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
			 tty != n_hdlc->tty) {
			unlock_kernel();
			tty_unlock();
			return 0;
		}

@@ -619,13 +619,13 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
			
		/* no data */
		if (file->f_flags & O_NONBLOCK) {
			unlock_kernel();
			tty_unlock();
			return -EAGAIN;
		}
			
		interruptible_sleep_on (&tty->read_wait);
		if (signal_pending(current)) {
			unlock_kernel();
			tty_unlock();
			return -EINTR;
		}
	}
@@ -648,7 +648,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
		kfree(rbuf);
	else	
		n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
	unlock_kernel();
	tty_unlock();
	return ret;
	
}	/* end of n_hdlc_tty_read() */
@@ -691,7 +691,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
		count = maxframe;
	}
	
	lock_kernel();
	tty_lock();

	add_wait_queue(&tty->write_wait, &wait);
	set_current_state(TASK_INTERRUPTIBLE);
@@ -731,7 +731,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
		n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
		n_hdlc_send_frames(n_hdlc,tty);
	}
	unlock_kernel();
	tty_unlock();
	return error;
	
}	/* end of n_hdlc_tty_write() */
+4 −4
Original line number Diff line number Diff line
@@ -1067,7 +1067,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,

	TRACE_L("read()");

	lock_kernel();
	tty_lock();

	pClient = findClient(pInfo, task_pid(current));
	if (pClient) {
@@ -1109,7 +1109,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
	}
	ret = -EPERM;
unlock:
	unlock_kernel();
	tty_unlock();
	return ret;
}

@@ -1158,7 +1158,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
	pHeader->locks = 0;
	pHeader->owner = NULL;

	lock_kernel();
	tty_lock();

	pClient = findClient(pInfo, task_pid(current));
	if (pClient) {
@@ -1177,7 +1177,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
	add_tx_queue(pInfo, pHeader);
	trigger_transmit(pInfo);

	unlock_kernel();
	tty_unlock();

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -692,9 +692,9 @@ static int ptmx_open(struct inode *inode, struct file *filp)
{
	int ret;

	lock_kernel();
	tty_lock();
	ret = __ptmx_open(inode, filp);
	unlock_kernel();
	tty_unlock();
	return ret;
}

Loading