Commit 2b4107a8 authored by Alexander Viro's avatar Alexander Viro Committed by Christoph Hellwig

[PATCH] tty cleanups (11/12)

	tty->device switched to dev_t
	There are very few uses of tty->device left by now; most of
them actually want dev_t (process accounting, proc/<pid>/stat, several
ioctls, slip.c logics, etc.) and the rest will go away shortly.
parent 50dceaae
...@@ -2847,7 +2847,7 @@ static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr) ...@@ -2847,7 +2847,7 @@ static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr)
real_tty = (struct tty_struct *)file->private_data; real_tty = (struct tty_struct *)file->private_data;
if (!real_tty) if (!real_tty)
return -EINVAL; return -EINVAL;
return put_user(kdev_t_to_nr(real_tty->device), ptr); return put_user(real_tty->device, ptr);
} }
......
...@@ -88,7 +88,7 @@ static void pty_close(struct tty_struct * tty, struct file * filp) ...@@ -88,7 +88,7 @@ static void pty_close(struct tty_struct * tty, struct file * filp)
set_bit(TTY_OTHER_CLOSED, &tty->flags); set_bit(TTY_OTHER_CLOSED, &tty->flags);
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
{ {
unsigned int major = major(tty->device) - UNIX98_PTY_MASTER_MAJOR; unsigned int major = MAJOR(tty->device) - UNIX98_PTY_MASTER_MAJOR;
if ( major < UNIX98_NR_MAJORS ) { if ( major < UNIX98_NR_MAJORS ) {
devpts_pty_kill( tty->index + tty->driver->name_base ); devpts_pty_kill( tty->index + tty->driver->name_base );
} }
......
...@@ -838,7 +838,7 @@ static int init_dev(struct tty_driver *driver, int idx, ...@@ -838,7 +838,7 @@ static int init_dev(struct tty_driver *driver, int idx,
if(!tty) if(!tty)
goto fail_no_mem; goto fail_no_mem;
initialize_tty_struct(tty); initialize_tty_struct(tty);
tty->device = mk_kdev(driver->major, driver->minor_start + idx); tty->device = MKDEV(driver->major, driver->minor_start) + idx;
tty->driver = driver; tty->driver = driver;
tty->index = idx; tty->index = idx;
tty_line_name(driver, idx, tty->name); tty_line_name(driver, idx, tty->name);
...@@ -866,8 +866,8 @@ static int init_dev(struct tty_driver *driver, int idx, ...@@ -866,8 +866,8 @@ static int init_dev(struct tty_driver *driver, int idx,
if (!o_tty) if (!o_tty)
goto free_mem_out; goto free_mem_out;
initialize_tty_struct(o_tty); initialize_tty_struct(o_tty);
o_tty->device = mk_kdev(driver->other->major, o_tty->device = MKDEV(driver->other->major,
driver->other->minor_start + idx); driver->other->minor_start) + idx;
o_tty->driver = driver->other; o_tty->driver = driver->other;
o_tty->index = idx; o_tty->index = idx;
tty_line_name(driver->other, idx, o_tty->name); tty_line_name(driver->other, idx, o_tty->name);
...@@ -1321,7 +1321,7 @@ static int tty_open(struct inode * inode, struct file * filp) ...@@ -1321,7 +1321,7 @@ static int tty_open(struct inode * inode, struct file * filp)
if (IS_TTY_DEV(device)) { if (IS_TTY_DEV(device)) {
if (!current->tty) if (!current->tty)
return -ENXIO; return -ENXIO;
device = current->tty->device; device = to_kdev_t(current->tty->device);
filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
/* noctty = 1; */ /* noctty = 1; */
} }
......
...@@ -722,7 +722,7 @@ static void sl_sync(void) ...@@ -722,7 +722,7 @@ static void sl_sync(void)
/* Find a free SLIP channel, and link in this `tty' line. */ /* Find a free SLIP channel, and link in this `tty' line. */
static struct slip * static struct slip *
sl_alloc(kdev_t line) sl_alloc(dev_t line)
{ {
struct slip *sl; struct slip *sl;
slip_ctrl_t *slp = NULL; slip_ctrl_t *slp = NULL;
...@@ -739,7 +739,7 @@ sl_alloc(kdev_t line) ...@@ -739,7 +739,7 @@ sl_alloc(kdev_t line)
break; break;
if (slp->ctrl.leased) { if (slp->ctrl.leased) {
if (!kdev_same(slp->ctrl.line, line)) if (slp->ctrl.line != line)
continue; continue;
if (slp->ctrl.tty) if (slp->ctrl.tty)
return NULL; return NULL;
...@@ -753,7 +753,7 @@ sl_alloc(kdev_t line) ...@@ -753,7 +753,7 @@ sl_alloc(kdev_t line)
continue; continue;
if (current->pid == slp->ctrl.pid) { if (current->pid == slp->ctrl.pid) {
if (kdev_same(slp->ctrl.line, line) && score < 3) { if (slp->ctrl.line == line && score < 3) {
sel = i; sel = i;
score = 3; score = 3;
continue; continue;
...@@ -764,7 +764,7 @@ sl_alloc(kdev_t line) ...@@ -764,7 +764,7 @@ sl_alloc(kdev_t line)
} }
continue; continue;
} }
if (kdev_same(slp->ctrl.line, line) && score < 1) { if (slp->ctrl.line == line && score < 1) {
sel = i; sel = i;
score = 1; score = 1;
continue; continue;
...@@ -941,7 +941,7 @@ slip_close(struct tty_struct *tty) ...@@ -941,7 +941,7 @@ slip_close(struct tty_struct *tty)
tty->disc_data = 0; tty->disc_data = 0;
sl->tty = NULL; sl->tty = NULL;
if (!sl->leased) if (!sl->leased)
sl->line = NODEV; sl->line = 0;
/* VSV = very important to remove timers */ /* VSV = very important to remove timers */
#ifdef CONFIG_SLIP_SMART #ifdef CONFIG_SLIP_SMART
......
...@@ -100,7 +100,7 @@ struct slip { ...@@ -100,7 +100,7 @@ struct slip {
unsigned char mode; /* SLIP mode */ unsigned char mode; /* SLIP mode */
unsigned char leased; unsigned char leased;
kdev_t line; dev_t line;
pid_t pid; pid_t pid;
#define SL_MODE_SLIP 0 #define SL_MODE_SLIP 0
#define SL_MODE_CSLIP 1 #define SL_MODE_CSLIP 1
......
...@@ -303,7 +303,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer) ...@@ -303,7 +303,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
atomic_inc(&mm->mm_users); atomic_inc(&mm->mm_users);
if (task->tty) { if (task->tty) {
tty_pgrp = task->tty->pgrp; tty_pgrp = task->tty->pgrp;
tty_nr = kdev_t_to_nr(task->tty->device); tty_nr = task->tty->device;
} }
task_unlock(task); task_unlock(task);
if (mm) { if (mm) {
......
...@@ -266,7 +266,7 @@ struct tty_struct { ...@@ -266,7 +266,7 @@ struct tty_struct {
char name[64]; char name[64];
int pgrp; int pgrp;
int session; int session;
kdev_t device; dev_t device;
unsigned long flags; unsigned long flags;
int count; int count;
struct winsize winsize; struct winsize winsize;
......
...@@ -335,7 +335,7 @@ static void do_acct_process(long exitcode, struct file *file) ...@@ -335,7 +335,7 @@ static void do_acct_process(long exitcode, struct file *file)
ac.ac_stime = encode_comp_t(current->stime); ac.ac_stime = encode_comp_t(current->stime);
ac.ac_uid = current->uid; ac.ac_uid = current->uid;
ac.ac_gid = current->gid; ac.ac_gid = current->gid;
ac.ac_tty = (current->tty) ? kdev_t_to_nr(current->tty->device) : 0; ac.ac_tty = current->tty ? current->tty->device : 0;
ac.ac_flag = 0; ac.ac_flag = 0;
if (current->flags & PF_FORKNOEXEC) if (current->flags & PF_FORKNOEXEC)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment