3 * Copyright 1999-2000 Digi International (www.digi.com)
4 * James Puzzo <jamesp at digi dot com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 * Handle the file operations required for the /proc/dgrp/ports/...
31 * devices. Basically gathers tty status for the node and returns it.
39 #include <linux/module.h>
40 #include <linux/proc_fs.h>
41 #include <linux/tty.h>
42 #include <linux/sched.h>
43 #include <linux/seq_file.h>
45 #include "dgrp_common.h"
47 /* File operation declarations */
48 static int dgrp_ports_open(struct inode *, struct file *);
50 const struct file_operations dgrp_ports_ops = {
52 .open = dgrp_ports_open,
55 .release = seq_release
58 static void *dgrp_ports_seq_start(struct seq_file *seq, loff_t *pos)
61 seq_puts(seq, "#num tty_open pr_open tot_wait MSTAT IFLAG OFLAG CFLAG BPS DIGIFLAGS\n");
66 static void *dgrp_ports_seq_next(struct seq_file *seq, void *v, loff_t *pos)
68 struct nd_struct *nd = seq->private;
70 if (*pos >= nd->nd_chan_count)
78 static void dgrp_ports_seq_stop(struct seq_file *seq, void *v)
82 static int dgrp_ports_seq_show(struct seq_file *seq, void *v)
87 struct un_struct *tun, *pun;
94 if (*pos >= nd->nd_chan_count)
97 ch = &nd->nd_chan[*pos];
102 * If port is not open and no one is waiting to
103 * open it, the modem signal values can't be
104 * trusted, and will be zeroed.
106 totcnt = tun->un_open_count +
108 ch->ch_wait_count[0] +
109 ch->ch_wait_count[1] +
110 ch->ch_wait_count[2];
112 seq_printf(seq, "%02d %02d %02d %02d 0x%04X 0x%04X 0x%04X 0x%04X %-6d 0x%04X\n",
116 ch->ch_wait_count[0] +
117 ch->ch_wait_count[1] +
118 ch->ch_wait_count[2],
119 (totcnt ? ch->ch_s_mlast : 0),
123 (ch->ch_s_brate ? (1843200 / ch->ch_s_brate) : 0),
124 ch->ch_digi.digi_flags);
129 static const struct seq_operations ports_seq_ops = {
130 .start = dgrp_ports_seq_start,
131 .next = dgrp_ports_seq_next,
132 .stop = dgrp_ports_seq_stop,
133 .show = dgrp_ports_seq_show,
137 * dgrp_ports_open -- open the /proc/dgrp/ports/... device
138 * @inode: struct inode *
139 * @file: struct file *
141 * Open function to open the /proc/dgrp/ports device for a PortServer.
142 * This is the open function for struct file_operations
144 static int dgrp_ports_open(struct inode *inode, struct file *file)
146 struct seq_file *seq;
149 rtn = seq_open(file, &ports_seq_ops);
151 seq = file->private_data;
152 seq->private = PDE_DATA(inode);