@@ -23,16 +23,18 @@ static char *serial_version = "$Revision: 1.25 $";
2323#include <linux/mm.h>
2424#include <linux/slab.h>
2525#include <linux/init.h>
26- #include <asm/uaccess.h>
2726#include <linux/kernel.h>
2827#include <linux/mutex.h>
2928#include <linux/bitops.h>
29+ #include <linux/seq_file.h>
30+ #include <linux/delay.h>
31+ #include <linux/module.h>
32+ #include <linux/uaccess.h>
33+ #include <linux/io.h>
3034
31- #include <asm/io.h>
3235#include <asm/irq.h>
3336#include <asm/dma.h>
3437#include <asm/system.h>
35- #include <linux/delay.h>
3638
3739#include <arch/svinto.h>
3840
@@ -456,7 +458,6 @@ static struct e100_serial rs_table[] = {
456458
457459#define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
458460
459- static struct ktermios * serial_termios [NR_PORTS ];
460461#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
461462static struct fast_timer fast_timers [NR_PORTS ];
462463#endif
@@ -4257,151 +4258,132 @@ rs_open(struct tty_struct *tty, struct file * filp)
42574258 return 0 ;
42584259}
42594260
4261+ #ifdef CONFIG_PROC_FS
42604262/*
42614263 * /proc fs routines....
42624264 */
42634265
4264- static int line_info ( char * buf , struct e100_serial * info )
4266+ static void seq_line_info ( struct seq_file * m , struct e100_serial * info )
42654267{
4266- char stat_buf [30 ];
4267- int ret ;
42684268 unsigned long tmp ;
42694269
4270- ret = sprintf ( buf , "%d: uart:E100 port:%lX irq:%d" ,
4271- info -> line , (unsigned long )info -> ioport , info -> irq );
4270+ seq_printf ( m , "%d: uart:E100 port:%lX irq:%d" ,
4271+ info -> line , (unsigned long )info -> ioport , info -> irq );
42724272
42734273 if (!info -> ioport || (info -> type == PORT_UNKNOWN )) {
4274- ret += sprintf ( buf + ret , "\n" );
4275- return ret ;
4274+ seq_printf ( m , "\n" );
4275+ return ;
42764276 }
42774277
4278- stat_buf [0 ] = 0 ;
4279- stat_buf [1 ] = 0 ;
4280- if (!E100_RTS_GET (info ))
4281- strcat (stat_buf , "|RTS" );
4282- if (!E100_CTS_GET (info ))
4283- strcat (stat_buf , "|CTS" );
4284- if (!E100_DTR_GET (info ))
4285- strcat (stat_buf , "|DTR" );
4286- if (!E100_DSR_GET (info ))
4287- strcat (stat_buf , "|DSR" );
4288- if (!E100_CD_GET (info ))
4289- strcat (stat_buf , "|CD" );
4290- if (!E100_RI_GET (info ))
4291- strcat (stat_buf , "|RI" );
4292-
4293- ret += sprintf (buf + ret , " baud:%d" , info -> baud );
4294-
4295- ret += sprintf (buf + ret , " tx:%lu rx:%lu" ,
4278+ seq_printf (m , " baud:%d" , info -> baud );
4279+ seq_printf (m , " tx:%lu rx:%lu" ,
42964280 (unsigned long )info -> icount .tx ,
42974281 (unsigned long )info -> icount .rx );
42984282 tmp = CIRC_CNT (info -> xmit .head , info -> xmit .tail , SERIAL_XMIT_SIZE );
4299- if (tmp ) {
4300- ret += sprintf (buf + ret , " tx_pend:%lu/%lu" ,
4301- (unsigned long )tmp ,
4302- (unsigned long )SERIAL_XMIT_SIZE );
4303- }
4283+ if (tmp )
4284+ seq_printf (m , " tx_pend:%lu/%lu" ,
4285+ (unsigned long )tmp ,
4286+ (unsigned long )SERIAL_XMIT_SIZE );
43044287
4305- ret += sprintf ( buf + ret , " rx_pend:%lu/%lu" ,
4306- (unsigned long )info -> recv_cnt ,
4307- (unsigned long )info -> max_recv_cnt );
4288+ seq_printf ( m , " rx_pend:%lu/%lu" ,
4289+ (unsigned long )info -> recv_cnt ,
4290+ (unsigned long )info -> max_recv_cnt );
43084291
43094292#if 1
43104293 if (info -> port .tty ) {
4311-
43124294 if (info -> port .tty -> stopped )
4313- ret += sprintf ( buf + ret , " stopped:%i" ,
4314- (int )info -> port .tty -> stopped );
4295+ seq_printf ( m , " stopped:%i" ,
4296+ (int )info -> port .tty -> stopped );
43154297 if (info -> port .tty -> hw_stopped )
4316- ret += sprintf ( buf + ret , " hw_stopped:%i" ,
4317- (int )info -> port .tty -> hw_stopped );
4298+ seq_printf ( m , " hw_stopped:%i" ,
4299+ (int )info -> port .tty -> hw_stopped );
43184300 }
43194301
43204302 {
43214303 unsigned char rstat = info -> ioport [REG_STATUS ];
4322- if (rstat & IO_MASK (R_SERIAL0_STATUS , xoff_detect ) )
4323- ret += sprintf ( buf + ret , " xoff_detect:1" );
4304+ if (rstat & IO_MASK (R_SERIAL0_STATUS , xoff_detect ))
4305+ seq_printf ( m , " xoff_detect:1" );
43244306 }
43254307
43264308#endif
43274309
4328-
4329-
4330-
43314310 if (info -> icount .frame )
4332- ret += sprintf (buf + ret , " fe:%lu" ,
4333- (unsigned long )info -> icount .frame );
4311+ seq_printf (m , " fe:%lu" , (unsigned long )info -> icount .frame );
43344312
43354313 if (info -> icount .parity )
4336- ret += sprintf (buf + ret , " pe:%lu" ,
4337- (unsigned long )info -> icount .parity );
4314+ seq_printf (m , " pe:%lu" , (unsigned long )info -> icount .parity );
43384315
43394316 if (info -> icount .brk )
4340- ret += sprintf (buf + ret , " brk:%lu" ,
4341- (unsigned long )info -> icount .brk );
4317+ seq_printf (m , " brk:%lu" , (unsigned long )info -> icount .brk );
43424318
43434319 if (info -> icount .overrun )
4344- ret += sprintf (buf + ret , " oe:%lu" ,
4345- (unsigned long )info -> icount .overrun );
4320+ seq_printf (m , " oe:%lu" , (unsigned long )info -> icount .overrun );
43464321
43474322 /*
43484323 * Last thing is the RS-232 status lines
43494324 */
4350- ret += sprintf (buf + ret , " %s\n" , stat_buf + 1 );
4351- return ret ;
4325+ if (!E100_RTS_GET (info ))
4326+ seq_puts (m , "|RTS" );
4327+ if (!E100_CTS_GET (info ))
4328+ seq_puts (m , "|CTS" );
4329+ if (!E100_DTR_GET (info ))
4330+ seq_puts (m , "|DTR" );
4331+ if (!E100_DSR_GET (info ))
4332+ seq_puts (m , "|DSR" );
4333+ if (!E100_CD_GET (info ))
4334+ seq_puts (m , "|CD" );
4335+ if (!E100_RI_GET (info ))
4336+ seq_puts (m , "|RI" );
4337+ seq_puts (m , "\n" );
43524338}
43534339
4354- int rs_read_proc ( char * page , char * * start , off_t off , int count ,
4355- int * eof , void * data )
4340+
4341+ static int crisv10_proc_show ( struct seq_file * m , void * v )
43564342{
4357- int i , len = 0 , l ;
4358- off_t begin = 0 ;
4343+ int i ;
43594344
4360- len += sprintf ( page , "serinfo:1.0 driver:%s\n" ,
4361- serial_version );
4362- for (i = 0 ; i < NR_PORTS && len < 4000 ; i ++ ) {
4345+ seq_printf ( m , "serinfo:1.0 driver:%s\n" , serial_version );
4346+
4347+ for (i = 0 ; i < NR_PORTS ; i ++ ) {
43634348 if (!rs_table [i ].enabled )
43644349 continue ;
4365- l = line_info (page + len , & rs_table [i ]);
4366- len += l ;
4367- if (len + begin > off + count )
4368- goto done ;
4369- if (len + begin < off ) {
4370- begin += len ;
4371- len = 0 ;
4372- }
4350+ seq_line_info (m , & rs_table [i ]);
43734351 }
43744352#ifdef DEBUG_LOG_INCLUDED
43754353 for (i = 0 ; i < debug_log_pos ; i ++ ) {
4376- len += sprintf (page + len , "%-4i %lu.%lu " , i , debug_log [i ].time , timer_data_to_ns (debug_log [i ].timer_data ));
4377- len += sprintf (page + len , debug_log [i ].string , debug_log [i ].value );
4378- if (len + begin > off + count )
4379- goto done ;
4380- if (len + begin < off ) {
4381- begin += len ;
4382- len = 0 ;
4383- }
4354+ seq_printf (m , "%-4i %lu.%lu " ,
4355+ i , debug_log [i ].time ,
4356+ timer_data_to_ns (debug_log [i ].timer_data ));
4357+ seq_printf (m , debug_log [i ].string , debug_log [i ].value );
43844358 }
4385- len += sprintf (page + len , "debug_log %i/%i %li bytes\n" ,
4386- i , DEBUG_LOG_SIZE , begin + len );
4359+ seq_printf (m , "debug_log %i/%i\n" , i , DEBUG_LOG_SIZE );
43874360 debug_log_pos = 0 ;
43884361#endif
4362+ return 0 ;
4363+ }
43894364
4390- * eof = 1 ;
4391- done :
4392- if (off >= len + begin )
4393- return 0 ;
4394- * start = page + (off - begin );
4395- return ((count < begin + len - off ) ? count : begin + len - off );
4365+ static int crisv10_proc_open (struct inode * inode , struct file * file )
4366+ {
4367+ return single_open (file , crisv10_proc_show , NULL );
43964368}
43974369
4370+ static const struct file_operations crisv10_proc_fops = {
4371+ .owner = THIS_MODULE ,
4372+ .open = crisv10_proc_open ,
4373+ .read = seq_read ,
4374+ .llseek = seq_lseek ,
4375+ .release = single_release ,
4376+ };
4377+ #endif
4378+
4379+
43984380/* Finally, routines used to initialize the serial driver. */
43994381
4400- static void
4401- show_serial_version (void )
4382+ static void show_serial_version (void )
44024383{
44034384 printk (KERN_INFO
4404- "ETRAX 100LX serial-driver %s, (c) 2000-2004 Axis Communications AB\r\n" ,
4385+ "ETRAX 100LX serial-driver %s, "
4386+ "(c) 2000-2004 Axis Communications AB\r\n" ,
44054387 & serial_version [11 ]); /* "$Revision: x.yy" */
44064388}
44074389
@@ -4425,13 +4407,14 @@ static const struct tty_operations rs_ops = {
44254407 .break_ctl = rs_break ,
44264408 .send_xchar = rs_send_xchar ,
44274409 .wait_until_sent = rs_wait_until_sent ,
4428- .read_proc = rs_read_proc ,
44294410 .tiocmget = rs_tiocmget ,
4430- .tiocmset = rs_tiocmset
4411+ .tiocmset = rs_tiocmset ,
4412+ #ifdef CONFIG_PROC_FS
4413+ .proc_fops = & crisv10_proc_fops ,
4414+ #endif
44314415};
44324416
4433- static int __init
4434- rs_init (void )
4417+ static int __init rs_init (void )
44354418{
44364419 int i ;
44374420 struct e100_serial * info ;
0 commit comments