43
43
#include <linux/ratelimit.h>
44
44
45
45
#include <asm/io.h>
46
- #include <linux/uaccess.h>
47
-
48
- #define MOXA 0x400
49
- #define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */
50
- #define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */
51
- #define MOXA_GETDATACOUNT (MOXA + 23)
52
- #define MOXA_GET_IOQUEUE (MOXA + 27)
53
- #define MOXA_FLUSH_QUEUE (MOXA + 28)
54
- #define MOXA_GETMSTATUS (MOXA + 65)
55
46
56
47
/*
57
48
* System Configuration
@@ -397,19 +388,6 @@ static struct moxa_board_conf {
397
388
void __iomem * intTable ;
398
389
} moxa_boards [MAX_BOARDS ];
399
390
400
- struct mxser_mstatus {
401
- tcflag_t cflag ;
402
- int cts ;
403
- int dsr ;
404
- int ri ;
405
- int dcd ;
406
- };
407
-
408
- struct moxaq_str {
409
- int inq ;
410
- int outq ;
411
- };
412
-
413
391
struct moxa_port {
414
392
struct tty_port port ;
415
393
struct moxa_board_conf * board ;
@@ -424,12 +402,6 @@ struct moxa_port {
424
402
u8 lowChkFlag ;
425
403
};
426
404
427
- struct mon_str {
428
- int tick ;
429
- int rxcnt [MAX_PORTS ];
430
- int txcnt [MAX_PORTS ];
431
- };
432
-
433
405
/* statusflags */
434
406
#define TXSTOPPED 1
435
407
#define LOWWAIT 2
@@ -439,14 +411,11 @@ struct mon_str {
439
411
#define WAKEUP_CHARS 256
440
412
441
413
static int ttymajor = MOXAMAJOR ;
442
- static struct mon_str moxaLog ;
443
414
static unsigned int moxaFuncTout = HZ / 2 ;
444
415
static unsigned int moxaLowWaterChk ;
445
416
static DEFINE_MUTEX (moxa_openlock );
446
417
static DEFINE_SPINLOCK (moxa_lock );
447
418
448
- static struct tty_port moxa_service_port ;
449
-
450
419
MODULE_AUTHOR ("William Chen" );
451
420
MODULE_DESCRIPTION ("MOXA Intellio Family Multiport Board Device Driver" );
452
421
MODULE_LICENSE ("GPL" );
@@ -557,104 +526,6 @@ static void moxa_low_water_check(void __iomem *ofsAddr)
557
526
* TTY operations
558
527
*/
559
528
560
- static int moxa_ioctl (struct tty_struct * tty ,
561
- unsigned int cmd , unsigned long arg )
562
- {
563
- struct moxa_port * ch = tty -> driver_data ;
564
- void __user * argp = (void __user * )arg ;
565
- int status , ret = 0 ;
566
-
567
- if (tty -> index == MAX_PORTS ) {
568
- if (cmd != MOXA_GETDATACOUNT && cmd != MOXA_GET_IOQUEUE &&
569
- cmd != MOXA_GETMSTATUS )
570
- return - EINVAL ;
571
- } else if (!ch )
572
- return - ENODEV ;
573
-
574
- switch (cmd ) {
575
- case MOXA_GETDATACOUNT :
576
- moxaLog .tick = jiffies ;
577
- if (copy_to_user (argp , & moxaLog , sizeof (moxaLog )))
578
- ret = - EFAULT ;
579
- break ;
580
- case MOXA_FLUSH_QUEUE :
581
- MoxaPortFlushData (ch , arg );
582
- break ;
583
- case MOXA_GET_IOQUEUE : {
584
- struct moxaq_str __user * argm = argp ;
585
- struct moxaq_str tmp ;
586
- struct moxa_port * p ;
587
- unsigned int i , j ;
588
-
589
- for (i = 0 ; i < MAX_BOARDS ; i ++ ) {
590
- p = moxa_boards [i ].ports ;
591
- for (j = 0 ; j < MAX_PORTS_PER_BOARD ; j ++ , p ++ , argm ++ ) {
592
- memset (& tmp , 0 , sizeof (tmp ));
593
- spin_lock_bh (& moxa_lock );
594
- if (moxa_boards [i ].ready ) {
595
- tmp .inq = MoxaPortRxQueue (p );
596
- tmp .outq = MoxaPortTxQueue (p );
597
- }
598
- spin_unlock_bh (& moxa_lock );
599
- if (copy_to_user (argm , & tmp , sizeof (tmp )))
600
- return - EFAULT ;
601
- }
602
- }
603
- break ;
604
- } case MOXA_GET_OQUEUE :
605
- status = MoxaPortTxQueue (ch );
606
- ret = put_user (status , (unsigned long __user * )argp );
607
- break ;
608
- case MOXA_GET_IQUEUE :
609
- status = MoxaPortRxQueue (ch );
610
- ret = put_user (status , (unsigned long __user * )argp );
611
- break ;
612
- case MOXA_GETMSTATUS : {
613
- struct mxser_mstatus __user * argm = argp ;
614
- struct mxser_mstatus tmp ;
615
- struct moxa_port * p ;
616
- unsigned int i , j ;
617
-
618
- for (i = 0 ; i < MAX_BOARDS ; i ++ ) {
619
- p = moxa_boards [i ].ports ;
620
- for (j = 0 ; j < MAX_PORTS_PER_BOARD ; j ++ , p ++ , argm ++ ) {
621
- struct tty_struct * ttyp ;
622
- memset (& tmp , 0 , sizeof (tmp ));
623
- spin_lock_bh (& moxa_lock );
624
- if (!moxa_boards [i ].ready ) {
625
- spin_unlock_bh (& moxa_lock );
626
- goto copy ;
627
- }
628
-
629
- status = MoxaPortLineStatus (p );
630
- spin_unlock_bh (& moxa_lock );
631
-
632
- if (status & 1 )
633
- tmp .cts = 1 ;
634
- if (status & 2 )
635
- tmp .dsr = 1 ;
636
- if (status & 4 )
637
- tmp .dcd = 1 ;
638
-
639
- ttyp = tty_port_tty_get (& p -> port );
640
- if (!ttyp )
641
- tmp .cflag = p -> cflag ;
642
- else
643
- tmp .cflag = ttyp -> termios .c_cflag ;
644
- tty_kref_put (ttyp );
645
- copy :
646
- if (copy_to_user (argm , & tmp , sizeof (tmp )))
647
- return - EFAULT ;
648
- }
649
- }
650
- break ;
651
- }
652
- default :
653
- ret = - ENOIOCTLCMD ;
654
- }
655
- return ret ;
656
- }
657
-
658
529
static int moxa_break_ctl (struct tty_struct * tty , int state )
659
530
{
660
531
struct moxa_port * port = tty -> driver_data ;
@@ -671,7 +542,6 @@ static const struct tty_operations moxa_ops = {
671
542
.write_room = moxa_write_room ,
672
543
.flush_buffer = moxa_flush_buffer ,
673
544
.chars_in_buffer = moxa_chars_in_buffer ,
674
- .ioctl = moxa_ioctl ,
675
545
.set_termios = moxa_set_termios ,
676
546
.stop = moxa_stop ,
677
547
.start = moxa_start ,
@@ -1283,9 +1153,7 @@ static int __init moxa_init(void)
1283
1153
{
1284
1154
int retval = 0 ;
1285
1155
1286
- tty_port_init (& moxa_service_port );
1287
-
1288
- moxaDriver = tty_alloc_driver (MAX_PORTS + 1 ,
1156
+ moxaDriver = tty_alloc_driver (MAX_PORTS ,
1289
1157
TTY_DRIVER_REAL_RAW |
1290
1158
TTY_DRIVER_DYNAMIC_DEV );
1291
1159
if (IS_ERR (moxaDriver ))
@@ -1301,8 +1169,6 @@ static int __init moxa_init(void)
1301
1169
moxaDriver -> init_termios .c_ispeed = 9600 ;
1302
1170
moxaDriver -> init_termios .c_ospeed = 9600 ;
1303
1171
tty_set_operations (moxaDriver , & moxa_ops );
1304
- /* Having one more port only for ioctls is ugly */
1305
- tty_port_link_device (& moxa_service_port , moxaDriver , MAX_PORTS );
1306
1172
1307
1173
if (tty_register_driver (moxaDriver )) {
1308
1174
printk (KERN_ERR "can't register MOXA Smartio tty driver!\n" );
@@ -1362,9 +1228,6 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
1362
1228
int port ;
1363
1229
1364
1230
port = tty -> index ;
1365
- if (port == MAX_PORTS ) {
1366
- return capable (CAP_SYS_ADMIN ) ? 0 : - EPERM ;
1367
- }
1368
1231
if (mutex_lock_interruptible (& moxa_openlock ))
1369
1232
return - ERESTARTSYS ;
1370
1233
brd = & moxa_boards [port / MAX_PORTS_PER_BOARD ];
@@ -2087,7 +1950,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer,
2087
1950
c = (head > tail ) ? (head - tail - 1 ) : (head - tail + tx_mask );
2088
1951
if (c > len )
2089
1952
c = len ;
2090
- moxaLog .txcnt [port -> port .tty -> index ] += c ;
2091
1953
total = c ;
2092
1954
if (spage == epage ) {
2093
1955
bufhead = readw (ofsAddr + Ofs_txb );
@@ -2129,7 +1991,6 @@ static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer,
2129
1991
2130
1992
static int MoxaPortReadData (struct moxa_port * port )
2131
1993
{
2132
- struct tty_struct * tty = port -> port .tty ;
2133
1994
void __iomem * baseAddr , * ofsAddr , * ofs ;
2134
1995
u8 * dst ;
2135
1996
unsigned int count , len , total ;
@@ -2148,7 +2009,6 @@ static int MoxaPortReadData(struct moxa_port *port)
2148
2009
return 0 ;
2149
2010
2150
2011
total = count ;
2151
- moxaLog .rxcnt [tty -> index ] += total ;
2152
2012
if (spage == epage ) {
2153
2013
bufhead = readw (ofsAddr + Ofs_rxb );
2154
2014
writew (spage , baseAddr + Control_reg );
@@ -2236,8 +2096,6 @@ static int moxa_get_serial_info(struct tty_struct *tty,
2236
2096
{
2237
2097
struct moxa_port * info = tty -> driver_data ;
2238
2098
2239
- if (tty -> index == MAX_PORTS )
2240
- return - EINVAL ;
2241
2099
if (!info )
2242
2100
return - ENODEV ;
2243
2101
mutex_lock (& info -> port .mutex );
@@ -2257,8 +2115,6 @@ static int moxa_set_serial_info(struct tty_struct *tty,
2257
2115
struct moxa_port * info = tty -> driver_data ;
2258
2116
unsigned int close_delay ;
2259
2117
2260
- if (tty -> index == MAX_PORTS )
2261
- return - EINVAL ;
2262
2118
if (!info )
2263
2119
return - ENODEV ;
2264
2120
0 commit comments