From 4906011d17f0cc5ee3ea8b8fc4214619a457d554 Mon Sep 17 00:00:00 2001 From: Brett Gordon Date: Thu, 10 Dec 2015 16:32:15 -0500 Subject: [PATCH] coco3: tty drivewire: and replace constants with defines --- Kernel/platform-coco3/ttydw.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Kernel/platform-coco3/ttydw.c b/Kernel/platform-coco3/ttydw.c index 4c704aad..11361ef5 100644 --- a/Kernel/platform-coco3/ttydw.c +++ b/Kernel/platform-coco3/ttydw.c @@ -89,6 +89,8 @@ #define DW_VOPEN 0x29 #define DW_VCLOSE 0x2A +#define DW_NS_OFF ( DW_MIN_OFF + DW_VSER_NUM ) + /* Internal Structure to represent state of DW ports */ struct dw_in{ @@ -131,13 +133,19 @@ struct dw_in *dw_gettab( uint8_t minor ){ /* Translates a DW port no. to a proper minor no */ int dw_minor( uint8_t port ){ - return port + DW_MIN_OFF - 1 ; + if( port >= 16 ) return port - 16 + DW_NS_OFF ; + int ret = port + DW_MIN_OFF - 1 ; + return ret; + } /* Translates a Minor to a port no */ int dw_port( uint8_t minor ){ - return minor - DW_MIN_OFF + 1 ; + int ret = minor - DW_MIN_OFF + 1; + if( minor >= DW_NS_OFF ) + return minor + 16 - DW_NS_OFF ; + return ret; } @@ -248,9 +256,9 @@ void dw_vpoll( ){ } /* VWIN channel single datum */ if( buf[0] < 144 ){ - int minor=dw_minor( buf[0] ); + int minor=dw_minor( buf[0]-48 ); tty_inproc( minor, buf[1] ); - continue; + continue; } /* something we don't handle? */ kprintf("out of band data\n"); -- 2.34.1