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 static const struct file_operations ports_ops
= {
52 .open
= dgrp_ports_open
,
55 .release
= seq_release
58 static struct inode_operations ports_inode_ops
= {
59 .permission
= dgrp_inode_permission
63 void dgrp_register_ports_hook(struct proc_dir_entry
*de
)
65 struct nd_struct
*node
= de
->data
;
67 de
->proc_iops
= &ports_inode_ops
;
68 de
->proc_fops
= &ports_ops
;
69 node
->nd_ports_de
= de
;
72 static void *dgrp_ports_seq_start(struct seq_file
*seq
, loff_t
*pos
)
75 seq_puts(seq
, "#num tty_open pr_open tot_wait MSTAT IFLAG OFLAG CFLAG BPS DIGIFLAGS\n");
80 static void *dgrp_ports_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
82 struct nd_struct
*nd
= seq
->private;
84 if (*pos
>= nd
->nd_chan_count
)
92 static void dgrp_ports_seq_stop(struct seq_file
*seq
, void *v
)
96 static int dgrp_ports_seq_show(struct seq_file
*seq
, void *v
)
100 struct ch_struct
*ch
;
101 struct un_struct
*tun
, *pun
;
108 if (*pos
>= nd
->nd_chan_count
)
111 ch
= &nd
->nd_chan
[*pos
];
116 * If port is not open and no one is waiting to
117 * open it, the modem signal values can't be
118 * trusted, and will be zeroed.
120 totcnt
= tun
->un_open_count
+
122 ch
->ch_wait_count
[0] +
123 ch
->ch_wait_count
[1] +
124 ch
->ch_wait_count
[2];
126 seq_printf(seq
, "%02d %02d %02d %02d 0x%04X 0x%04X 0x%04X 0x%04X %-6d 0x%04X\n",
130 ch
->ch_wait_count
[0] +
131 ch
->ch_wait_count
[1] +
132 ch
->ch_wait_count
[2],
133 (totcnt
? ch
->ch_s_mlast
: 0),
137 (ch
->ch_s_brate
? (1843200 / ch
->ch_s_brate
) : 0),
138 ch
->ch_digi
.digi_flags
);
143 static const struct seq_operations ports_seq_ops
= {
144 .start
= dgrp_ports_seq_start
,
145 .next
= dgrp_ports_seq_next
,
146 .stop
= dgrp_ports_seq_stop
,
147 .show
= dgrp_ports_seq_show
,
151 * dgrp_ports_open -- open the /proc/dgrp/ports/... device
152 * @inode: struct inode *
153 * @file: struct file *
155 * Open function to open the /proc/dgrp/ports device for a PortServer.
156 * This is the open function for struct file_operations
158 static int dgrp_ports_open(struct inode
*inode
, struct file
*file
)
160 struct seq_file
*seq
;
163 rtn
= seq_open(file
, &ports_seq_ops
);
165 seq
= file
->private_data
;
166 seq
->private = PDE(inode
)->data
;