From 2b4107a8038d2313e7a0eda367f15356581aba08 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Wed, 23 Apr 2003 04:19:46 -0700 Subject: [PATCH] [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//stat, several ioctls, slip.c logics, etc.) and the rest will go away shortly. --- arch/x86_64/ia32/ia32_ioctl.c | 2 +- drivers/char/pty.c | 2 +- drivers/char/tty_io.c | 8 ++++---- drivers/net/slip.c | 10 +++++----- drivers/net/slip.h | 2 +- fs/proc/array.c | 2 +- include/linux/tty.h | 2 +- kernel/acct.c | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c index 3e786a7794595..812f02c45edc0 100644 --- a/arch/x86_64/ia32/ia32_ioctl.c +++ b/arch/x86_64/ia32/ia32_ioctl.c @@ -2847,7 +2847,7 @@ static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr) real_tty = (struct tty_struct *)file->private_data; if (!real_tty) return -EINVAL; - return put_user(kdev_t_to_nr(real_tty->device), ptr); + return put_user(real_tty->device, ptr); } diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 1459910ae5ce2..e58858146d698 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -88,7 +88,7 @@ static void pty_close(struct tty_struct * tty, struct file * filp) set_bit(TTY_OTHER_CLOSED, &tty->flags); #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 ) { devpts_pty_kill( tty->index + tty->driver->name_base ); } diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 06184a0df09f0..8298988afaf50 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -838,7 +838,7 @@ static int init_dev(struct tty_driver *driver, int idx, if(!tty) goto fail_no_mem; 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->index = idx; tty_line_name(driver, idx, tty->name); @@ -866,8 +866,8 @@ static int init_dev(struct tty_driver *driver, int idx, if (!o_tty) goto free_mem_out; initialize_tty_struct(o_tty); - o_tty->device = mk_kdev(driver->other->major, - driver->other->minor_start + idx); + o_tty->device = MKDEV(driver->other->major, + driver->other->minor_start) + idx; o_tty->driver = driver->other; o_tty->index = idx; tty_line_name(driver->other, idx, o_tty->name); @@ -1321,7 +1321,7 @@ retry_open: if (IS_TTY_DEV(device)) { if (!current->tty) return -ENXIO; - device = current->tty->device; + device = to_kdev_t(current->tty->device); filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ /* noctty = 1; */ } diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 5a437dca6e775..4a5564b33304a 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -722,7 +722,7 @@ static void sl_sync(void) /* Find a free SLIP channel, and link in this `tty' line. */ static struct slip * -sl_alloc(kdev_t line) +sl_alloc(dev_t line) { struct slip *sl; slip_ctrl_t *slp = NULL; @@ -739,7 +739,7 @@ sl_alloc(kdev_t line) break; if (slp->ctrl.leased) { - if (!kdev_same(slp->ctrl.line, line)) + if (slp->ctrl.line != line) continue; if (slp->ctrl.tty) return NULL; @@ -753,7 +753,7 @@ sl_alloc(kdev_t line) continue; if (current->pid == slp->ctrl.pid) { - if (kdev_same(slp->ctrl.line, line) && score < 3) { + if (slp->ctrl.line == line && score < 3) { sel = i; score = 3; continue; @@ -764,7 +764,7 @@ sl_alloc(kdev_t line) } continue; } - if (kdev_same(slp->ctrl.line, line) && score < 1) { + if (slp->ctrl.line == line && score < 1) { sel = i; score = 1; continue; @@ -941,7 +941,7 @@ slip_close(struct tty_struct *tty) tty->disc_data = 0; sl->tty = NULL; if (!sl->leased) - sl->line = NODEV; + sl->line = 0; /* VSV = very important to remove timers */ #ifdef CONFIG_SLIP_SMART diff --git a/drivers/net/slip.h b/drivers/net/slip.h index bbd82fda55c83..524297033053e 100644 --- a/drivers/net/slip.h +++ b/drivers/net/slip.h @@ -100,7 +100,7 @@ struct slip { unsigned char mode; /* SLIP mode */ unsigned char leased; - kdev_t line; + dev_t line; pid_t pid; #define SL_MODE_SLIP 0 #define SL_MODE_CSLIP 1 diff --git a/fs/proc/array.c b/fs/proc/array.c index 186864bb78989..643ccd392f23c 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -303,7 +303,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer) atomic_inc(&mm->mm_users); if (task->tty) { tty_pgrp = task->tty->pgrp; - tty_nr = kdev_t_to_nr(task->tty->device); + tty_nr = task->tty->device; } task_unlock(task); if (mm) { diff --git a/include/linux/tty.h b/include/linux/tty.h index eaa682168a7a6..d7948e7ad0ebd 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -266,7 +266,7 @@ struct tty_struct { char name[64]; int pgrp; int session; - kdev_t device; + dev_t device; unsigned long flags; int count; struct winsize winsize; diff --git a/kernel/acct.c b/kernel/acct.c index 47736b0fb8e5c..2de6d736f7d89 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -335,7 +335,7 @@ static void do_acct_process(long exitcode, struct file *file) ac.ac_stime = encode_comp_t(current->stime); ac.ac_uid = current->uid; 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; if (current->flags & PF_FORKNOEXEC) -- 2.53.0