Skip to content

Commit

Permalink
tty: replace ->proc_fops with ->proc_show
Browse files Browse the repository at this point in the history
Just set up the show callback in the tty_operations, and use
proc_create_single_data to create the file without additional
boilerplace code.

Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Christoph Hellwig committed May 16, 2018
1 parent ec7d9c9 commit 8a8dcab
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 172 deletions.
15 changes: 1 addition & 14 deletions arch/ia64/hp/sim/simserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,19 +435,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
return 0;
}

static int rs_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, rs_proc_show, NULL);
}

static const struct file_operations rs_proc_fops = {
.owner = THIS_MODULE,
.open = rs_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct tty_operations hp_ops = {
.open = rs_open,
.close = rs_close,
Expand All @@ -462,7 +449,7 @@ static const struct tty_operations hp_ops = {
.unthrottle = rs_unthrottle,
.send_xchar = rs_send_xchar,
.hangup = rs_hangup,
.proc_fops = &rs_proc_fops,
.proc_show = rs_proc_show,
};

static const struct tty_port_operations hp_port_ops = {
Expand Down
15 changes: 1 addition & 14 deletions arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
return 0;
}

static int rs_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, rs_proc_show, NULL);
}

static const struct file_operations rs_proc_fops = {
.owner = THIS_MODULE,
.open = rs_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct tty_operations serial_ops = {
.open = rs_open,
.close = rs_close,
Expand All @@ -176,7 +163,7 @@ static const struct tty_operations serial_ops = {
.chars_in_buffer = rs_chars_in_buffer,
.hangup = rs_hangup,
.wait_until_sent = rs_wait_until_sent,
.proc_fops = &rs_proc_fops,
.proc_show = rs_proc_show,
};

int __init rs_init(void)
Expand Down
15 changes: 1 addition & 14 deletions drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2616,19 +2616,6 @@ static int mgslpc_proc_show(struct seq_file *m, void *v)
return 0;
}

static int mgslpc_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, mgslpc_proc_show, NULL);
}

static const struct file_operations mgslpc_proc_fops = {
.owner = THIS_MODULE,
.open = mgslpc_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static int rx_alloc_buffers(MGSLPC_INFO *info)
{
/* each buffer has header and data */
Expand Down Expand Up @@ -2815,7 +2802,7 @@ static const struct tty_operations mgslpc_ops = {
.tiocmget = tiocmget,
.tiocmset = tiocmset,
.get_icount = mgslpc_get_icount,
.proc_fops = &mgslpc_proc_fops,
.proc_show = mgslpc_proc_show,
};

static int __init synclink_cs_init(void)
Expand Down
15 changes: 1 addition & 14 deletions drivers/mmc/core/sdio_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,19 +1008,6 @@ static int sdio_uart_proc_show(struct seq_file *m, void *v)
return 0;
}

static int sdio_uart_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, sdio_uart_proc_show, NULL);
}

static const struct file_operations sdio_uart_proc_fops = {
.owner = THIS_MODULE,
.open = sdio_uart_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct tty_port_operations sdio_uart_port_ops = {
.dtr_rts = uart_dtr_rts,
.carrier_raised = uart_carrier_raised,
Expand All @@ -1045,7 +1032,7 @@ static const struct tty_operations sdio_uart_ops = {
.tiocmset = sdio_uart_tiocmset,
.install = sdio_uart_install,
.cleanup = sdio_uart_cleanup,
.proc_fops = &sdio_uart_proc_fops,
.proc_show = sdio_uart_proc_show,
};

static struct tty_driver *sdio_uart_tty_driver;
Expand Down
15 changes: 1 addition & 14 deletions drivers/staging/fwserial/fwserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,11 +1506,6 @@ static int fwtty_debugfs_peers_show(struct seq_file *m, void *v)
return 0;
}

static int fwtty_proc_open(struct inode *inode, struct file *fp)
{
return single_open(fp, fwtty_proc_show, NULL);
}

static int fwtty_stats_open(struct inode *inode, struct file *fp)
{
return single_open(fp, fwtty_debugfs_stats_show, inode->i_private);
Expand All @@ -1537,14 +1532,6 @@ static const struct file_operations fwtty_peers_fops = {
.release = single_release,
};

static const struct file_operations fwtty_proc_fops = {
.owner = THIS_MODULE,
.open = fwtty_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static const struct tty_port_operations fwtty_port_ops = {
.dtr_rts = fwtty_port_dtr_rts,
.carrier_raised = fwtty_port_carrier_raised,
Expand All @@ -1570,7 +1557,7 @@ static const struct tty_operations fwtty_ops = {
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount = fwtty_get_icount,
.proc_fops = &fwtty_proc_fops,
.proc_show = fwtty_proc_show,
};

static const struct tty_operations fwloop_ops = {
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,19 +1566,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
return 0;
}

static int rs_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, rs_proc_show, NULL);
}

static const struct file_operations rs_proc_fops = {
.owner = THIS_MODULE,
.open = rs_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/*
* ---------------------------------------------------------------------
* rs_init() and friends
Expand Down Expand Up @@ -1620,7 +1607,7 @@ static const struct tty_operations serial_ops = {
.tiocmget = rs_tiocmget,
.tiocmset = rs_tiocmset,
.get_icount = rs_get_icount,
.proc_fops = &rs_proc_fops,
.proc_show = rs_proc_show,
};

static int amiga_carrier_raised(struct tty_port *port)
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/cyclades.c
Original file line number Diff line number Diff line change
Expand Up @@ -3972,19 +3972,6 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
return 0;
}

static int cyclades_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, cyclades_proc_show, NULL);
}

static const struct file_operations cyclades_proc_fops = {
.owner = THIS_MODULE,
.open = cyclades_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/* The serial driver boot-time initialization code!
Hardware I/O ports are mapped to character special devices on a
first found, first allocated manner. That is, this code searches
Expand Down Expand Up @@ -4024,7 +4011,7 @@ static const struct tty_operations cy_ops = {
.tiocmget = cy_tiocmget,
.tiocmset = cy_tiocmset,
.get_icount = cy_get_icount,
.proc_fops = &cyclades_proc_fops,
.proc_show = cyclades_proc_show,
};

static int __init cy_init(void)
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/serial/serial_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,19 +1829,6 @@ static int uart_proc_show(struct seq_file *m, void *v)
uart_line_info(m, drv, i);
return 0;
}

static int uart_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, uart_proc_show, PDE_DATA(inode));
}

static const struct file_operations uart_proc_fops = {
.owner = THIS_MODULE,
.open = uart_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif

#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
Expand Down Expand Up @@ -2415,7 +2402,7 @@ static const struct tty_operations uart_ops = {
.break_ctl = uart_break_ctl,
.wait_until_sent= uart_wait_until_sent,
#ifdef CONFIG_PROC_FS
.proc_fops = &uart_proc_fops,
.proc_show = uart_proc_show,
#endif
.tiocmget = uart_tiocmget,
.tiocmset = uart_tiocmset,
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/synclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -3534,19 +3534,6 @@ static int mgsl_proc_show(struct seq_file *m, void *v)
return 0;
}

static int mgsl_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, mgsl_proc_show, NULL);
}

static const struct file_operations mgsl_proc_fops = {
.owner = THIS_MODULE,
.open = mgsl_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/* mgsl_allocate_dma_buffers()
*
* Allocate and format DMA buffers (ISA adapter)
Expand Down Expand Up @@ -4298,7 +4285,7 @@ static const struct tty_operations mgsl_ops = {
.tiocmget = tiocmget,
.tiocmset = tiocmset,
.get_icount = msgl_get_icount,
.proc_fops = &mgsl_proc_fops,
.proc_show = mgsl_proc_show,
};

/*
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/synclink_gt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,19 +1316,6 @@ static int synclink_gt_proc_show(struct seq_file *m, void *v)
return 0;
}

static int synclink_gt_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, synclink_gt_proc_show, NULL);
}

static const struct file_operations synclink_gt_proc_fops = {
.owner = THIS_MODULE,
.open = synclink_gt_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/*
* return count of bytes in transmit buffer
*/
Expand Down Expand Up @@ -3721,7 +3708,7 @@ static const struct tty_operations ops = {
.tiocmget = tiocmget,
.tiocmset = tiocmset,
.get_icount = get_icount,
.proc_fops = &synclink_gt_proc_fops,
.proc_show = synclink_gt_proc_show,
};

static void slgt_cleanup(void)
Expand Down
15 changes: 1 addition & 14 deletions drivers/tty/synclinkmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,19 +1421,6 @@ static int synclinkmp_proc_show(struct seq_file *m, void *v)
return 0;
}

static int synclinkmp_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, synclinkmp_proc_show, NULL);
}

static const struct file_operations synclinkmp_proc_fops = {
.owner = THIS_MODULE,
.open = synclinkmp_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

/* Return the count of bytes in transmit buffer
*/
static int chars_in_buffer(struct tty_struct *tty)
Expand Down Expand Up @@ -3899,7 +3886,7 @@ static const struct tty_operations ops = {
.tiocmget = tiocmget,
.tiocmset = tiocmset,
.get_icount = get_icount,
.proc_fops = &synclinkmp_proc_fops,
.proc_show = synclinkmp_proc_show,
};


Expand Down
15 changes: 1 addition & 14 deletions drivers/usb/serial/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,6 @@ static int serial_proc_show(struct seq_file *m, void *v)
return 0;
}

static int serial_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, serial_proc_show, NULL);
}

static const struct file_operations serial_proc_fops = {
.owner = THIS_MODULE,
.open = serial_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static int serial_tiocmget(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
Expand Down Expand Up @@ -1192,7 +1179,7 @@ static const struct tty_operations serial_ops = {
.get_icount = serial_get_icount,
.cleanup = serial_cleanup,
.install = serial_install,
.proc_fops = &serial_proc_fops,
.proc_show = serial_proc_show,
};


Expand Down
6 changes: 3 additions & 3 deletions fs/proc/proc_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ void proc_tty_register_driver(struct tty_driver *driver)
struct proc_dir_entry *ent;

if (!driver->driver_name || driver->proc_entry ||
!driver->ops->proc_fops)
!driver->ops->proc_show)
return;

ent = proc_create_data(driver->driver_name, 0, proc_tty_driver,
driver->ops->proc_fops, driver);
ent = proc_create_single_data(driver->driver_name, 0, proc_tty_driver,
driver->ops->proc_show, driver);
driver->proc_entry = ent;
}

Expand Down
2 changes: 1 addition & 1 deletion include/linux/tty_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct tty_operations {
int (*poll_get_char)(struct tty_driver *driver, int line);
void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
#endif
const struct file_operations *proc_fops;
int (*proc_show)(struct seq_file *, void *);
} __randomize_layout;

struct tty_driver {
Expand Down

0 comments on commit 8a8dcab

Please sign in to comment.