diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-01-20 14:01:31 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-01-20 14:01:31 -0300 |
commit | b4b7ff4b08e691656c9d77c758fc355833128ac0 (patch) | |
tree | 82fcb00e6b918026dc9f2d1f05ed8eee83874cc0 /drivers/staging/dgnc | |
parent | 35acfa0fc609f2a2cd95cef4a6a9c3a5c38f1778 (diff) |
Linux-libre 4.4-gnupck-4.4-gnu
Diffstat (limited to 'drivers/staging/dgnc')
-rw-r--r-- | drivers/staging/dgnc/dgnc_cls.c | 50 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_driver.c | 52 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_driver.h | 59 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_mgmt.c | 15 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_neo.c | 65 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_sysfs.c | 95 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_tty.c | 324 |
7 files changed, 271 insertions, 389 deletions
diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index a629a7896..75040daa4 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -115,7 +115,6 @@ static inline void cls_set_cts_flow_control(struct channel_t *ch) &ch->ch_cls_uart->isr_fcr); ch->ch_t_tlevel = 16; - } static inline void cls_set_ixon_flow_control(struct channel_t *ch) @@ -161,7 +160,6 @@ static inline void cls_set_ixon_flow_control(struct channel_t *ch) writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), &ch->ch_cls_uart->isr_fcr); - } static inline void cls_set_no_output_flow_control(struct channel_t *ch) @@ -205,7 +203,6 @@ static inline void cls_set_no_output_flow_control(struct channel_t *ch) ch->ch_r_watermark = 0; ch->ch_t_tlevel = 16; ch->ch_r_tlevel = 16; - } static inline void cls_set_rts_flow_control(struct channel_t *ch) @@ -244,7 +241,6 @@ static inline void cls_set_rts_flow_control(struct channel_t *ch) ch->ch_r_watermark = 4; ch->ch_r_tlevel = 8; - } static inline void cls_set_ixoff_flow_control(struct channel_t *ch) @@ -286,7 +282,6 @@ static inline void cls_set_ixoff_flow_control(struct channel_t *ch) writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), &ch->ch_cls_uart->isr_fcr); - } static inline void cls_set_no_input_flow_control(struct channel_t *ch) @@ -325,7 +320,6 @@ static inline void cls_set_no_input_flow_control(struct channel_t *ch) ch->ch_t_tlevel = 16; ch->ch_r_tlevel = 16; - } /* @@ -384,7 +378,6 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port) /* Here we try to figure out what caused the interrupt to happen */ while (1) { - isr = readb(&ch->ch_cls_uart->isr_fcr); /* Bail if no pending interrupt on port */ @@ -445,7 +438,7 @@ static void cls_param(struct tty_struct *tty) if (!tty || tty->magic != TTY_MAGIC) return; - un = (struct un_t *) tty->driver_data; + un = (struct un_t *)tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; @@ -478,7 +471,6 @@ static void cls_param(struct tty_struct *tty) ch->ch_old_baud = 0; return; } else if (ch->ch_custom_speed) { - baud = ch->ch_custom_speed; /* Handle transition from B0 */ if (ch->ch_flags & CH_BAUD0) { @@ -526,7 +518,7 @@ static void cls_param(struct tty_struct *tty) * unit is NOT open */ if (!(ch->ch_tun.un_flags & UN_ISOPEN) && - (un->un_type == DGNC_PRINT)) + (un->un_type == DGNC_PRINT)) baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; else baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; @@ -540,7 +532,7 @@ static void cls_param(struct tty_struct *tty) jindex = baud; if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && - (jindex < 16)) { + (jindex < 16)) { baud = bauds[iindex][jindex]; } else { baud = 0; @@ -628,13 +620,13 @@ static void cls_param(struct tty_struct *tty) * we are in hardware flow control mode, or CLOCAL/FORCEDCD is not set. */ if ((ch->ch_digi.digi_flags & CTSPACE) || - (ch->ch_digi.digi_flags & RTSPACE) || - (ch->ch_c_cflag & CRTSCTS) || - !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || - !(ch->ch_c_cflag & CLOCAL)) - ier |= UART_IER_MSI; + (ch->ch_digi.digi_flags & RTSPACE) || + (ch->ch_c_cflag & CRTSCTS) || + !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || + !(ch->ch_c_cflag & CLOCAL)) + ier |= UART_IER_MSI; else - ier &= ~UART_IER_MSI; + ier &= ~UART_IER_MSI; ier |= UART_IER_THRI; @@ -649,7 +641,7 @@ static void cls_param(struct tty_struct *tty) * disable flow control */ if ((ch->ch_startc == _POSIX_VDISABLE) || - (ch->ch_stopc == _POSIX_VDISABLE)) + (ch->ch_stopc == _POSIX_VDISABLE)) cls_set_no_output_flow_control(ch); else cls_set_ixon_flow_control(ch); @@ -665,7 +657,7 @@ static void cls_param(struct tty_struct *tty) * flow control */ if ((ch->ch_startc == _POSIX_VDISABLE) || - (ch->ch_stopc == _POSIX_VDISABLE)) + (ch->ch_stopc == _POSIX_VDISABLE)) cls_set_no_input_flow_control(ch); else cls_set_ixoff_flow_control(ch); @@ -684,7 +676,7 @@ static void cls_param(struct tty_struct *tty) */ static void cls_tasklet(unsigned long data) { - struct dgnc_board *bd = (struct dgnc_board *) data; + struct dgnc_board *bd = (struct dgnc_board *)data; struct channel_t *ch; unsigned long flags; int i; @@ -710,7 +702,6 @@ static void cls_tasklet(unsigned long data) * If board is ready, parse deeper to see if there is anything to do. */ if ((state == BOARD_READY) && (ports > 0)) { - /* Loop on each port */ for (i = 0; i < ports; i++) { ch = bd->channels[i]; @@ -746,7 +737,6 @@ static void cls_tasklet(unsigned long data) } spin_unlock_irqrestore(&bd->bd_intr_lock, flags); - } /* @@ -854,10 +844,8 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch) * Discard character if we are ignoring the error mask. */ if (linestatus & error_mask) { - unsigned char discard; - linestatus = 0; - discard = readb(&ch->ch_cls_uart->txrx); + readb(&ch->ch_cls_uart->txrx); continue; } @@ -916,7 +904,7 @@ static int cls_drain(struct tty_struct *tty, uint seconds) if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; - un = (struct un_t *) tty->driver_data; + un = (struct un_t *)tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return -ENXIO; @@ -945,7 +933,7 @@ static void cls_flush_uart_write(struct channel_t *ch) return; writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT), - &ch->ch_cls_uart->isr_fcr); + &ch->ch_cls_uart->isr_fcr); udelay(10); ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); @@ -991,7 +979,7 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch) /* If port is "stopped", don't send any data to the UART */ if ((ch->ch_flags & CH_FORCED_STOP) || - (ch->ch_flags & CH_BREAK_SENDING)) + (ch->ch_flags & CH_BREAK_SENDING)) goto exit_unlock; if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) @@ -1008,7 +996,6 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch) n = min(n, qlen); while (n > 0) { - /* * If RTS Toggle mode is on, turn on RTS now if not already set, * and make sure we get an event when the data transfer has @@ -1182,7 +1169,7 @@ static void cls_uart_init(struct channel_t *ch) readb(&ch->ch_cls_uart->txrx); writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), - &ch->ch_cls_uart->isr_fcr); + &ch->ch_cls_uart->isr_fcr); udelay(10); ch->ch_flags |= (CH_FIFO_ENABLED | CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); @@ -1309,6 +1296,5 @@ static void cls_vpd(struct dgnc_board *brd) } pr_info("\n"); - if (re_map_vpdbase) - iounmap(re_map_vpdbase); + iounmap(re_map_vpdbase); } diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 7546aff65..fc6d2989e 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -13,7 +13,6 @@ * PURPOSE. See the GNU General Public License for more details. */ - #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> @@ -39,7 +38,6 @@ MODULE_SUPPORTED_DEVICE("dgnc"); */ static int dgnc_start(void); static int dgnc_finalize_board_init(struct dgnc_board *brd); -static void dgnc_init_globals(void); static int dgnc_found_board(struct pci_dev *pdev, int id); static void dgnc_cleanup_board(struct dgnc_board *brd); static void dgnc_poll_handler(ulong dummy); @@ -57,13 +55,13 @@ static const struct file_operations dgnc_BoardFops = { .release = dgnc_mgmt_close }; - /* * Globals */ uint dgnc_NumBoards; struct dgnc_board *dgnc_Board[MAXBOARDS]; DEFINE_SPINLOCK(dgnc_global_lock); +DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ uint dgnc_Major; int dgnc_poll_tick = 20; /* Poll interval - 20 ms */ @@ -75,12 +73,10 @@ static struct class *dgnc_class; /* * Poller stuff */ -static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ static ulong dgnc_poll_time; /* Time of next poll */ static uint dgnc_poll_stop; /* Used to tell poller to stop */ static struct timer_list dgnc_poll_timer; - static const struct pci_device_id dgnc_pci_tbl[] = { {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_DID), .driver_data = 0}, {PCI_DEVICE(DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID), .driver_data = 1}, @@ -171,7 +167,7 @@ static void dgnc_cleanup_module(void) */ static int __init dgnc_init_module(void) { - int rc = 0; + int rc; /* * Initialize global stuff @@ -216,8 +212,8 @@ static int dgnc_start(void) unsigned long flags; struct device *dev; - /* make sure that the globals are init'd before we do anything else */ - dgnc_init_globals(); + /* make sure timer is initialized before we do anything else */ + init_timer(&dgnc_poll_timer); /* * Register our base character device into the kernel. @@ -241,7 +237,7 @@ static int dgnc_start(void) } dev = device_create(dgnc_class, NULL, - MKDEV(dgnc_Major, 0), + MKDEV(dgnc_Major, 0), NULL, "dgnc_mgmt"); if (IS_ERR(dev)) { rc = PTR_ERR(dev); @@ -355,13 +351,11 @@ static void dgnc_cleanup_board(struct dgnc_board *brd) } } - dgnc_Board[brd->boardnum] = NULL; kfree(brd); } - /* * dgnc_found_board() * @@ -422,9 +416,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) pci_irq = pdev->irq; brd->irq = pci_irq; - switch (brd->device) { - case PCI_DEVICE_CLASSIC_4_DID: case PCI_DEVICE_CLASSIC_8_DID: case PCI_DEVICE_CLASSIC_4_422_DID: @@ -442,7 +434,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) * 4 Memory Mapped UARTs and Status */ - /* get the PCI Base Address Registers */ brd->membase = pci_resource_start(pdev, 4); @@ -461,7 +452,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->iobase = pci_resource_start(pdev, 1); brd->iobase_end = pci_resource_end(pdev, 1); - brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE; + brd->iobase = ((unsigned int)(brd->iobase)) & 0xFFFE; /* Assign the board_ops struct */ brd->bd_ops = &dgnc_cls_ops; @@ -483,7 +474,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) break; - case PCI_DEVICE_NEO_4_DID: case PCI_DEVICE_NEO_8_DID: case PCI_DEVICE_NEO_2DB9_DID: @@ -525,7 +515,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) dgnc_do_remap(brd); if (brd->re_map_membase) { - /* Read and store the dvid after remapping */ brd->dvid = readb(brd->re_map_membase + 0x8D); @@ -538,7 +527,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) dev_err(&brd->pdev->dev, "Didn't find any compatible Neo/Classic PCI boards.\n"); return -ENXIO; - } /* @@ -571,7 +559,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) /* init our poll helper tasklet */ tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, - (unsigned long) brd); + (unsigned long)brd); spin_lock_irqsave(&dgnc_global_lock, flags); brd->msgbuf = NULL; @@ -590,10 +578,8 @@ failed: brd->dpastatus = BD_NOFEP; return -ENXIO; - } - static int dgnc_finalize_board_init(struct dgnc_board *brd) { int rc = 0; @@ -621,14 +607,12 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) */ static void dgnc_do_remap(struct dgnc_board *brd) { - if (!brd || brd->magic != DGNC_BOARD_MAGIC) return; brd->re_map_membase = ioremap(brd->membase, 0x1000); } - /***************************************************************************** * * Function: @@ -688,7 +672,7 @@ static void dgnc_poll_handler(ulong dummy) new_time = dgnc_poll_time - jiffies; - if ((ulong) new_time >= 2 * dgnc_poll_tick) + if ((ulong)new_time >= 2 * dgnc_poll_tick) dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0); @@ -698,23 +682,3 @@ static void dgnc_poll_handler(ulong dummy) if (!dgnc_poll_stop) add_timer(&dgnc_poll_timer); } - -/* - * dgnc_init_globals() - * - * This is where we initialize the globals from the static insmod - * configuration variables. These are declared near the head of - * this file. - */ -static void dgnc_init_globals(void) -{ - int i = 0; - - dgnc_NumBoards = 0; - - for (i = 0; i < MAXBOARDS; i++) - dgnc_Board[i] = NULL; - - init_timer(&dgnc_poll_timer); -} - diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 06ece5151..ce7cd9b96 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -61,7 +61,9 @@ #define PORT_NUM(dev) ((dev) & 0x7f) #define IS_PRINT(dev) (((dev) & 0xff) >= 0x80) -/* MAX number of stop characters we will send when our read queue is getting full */ +/* MAX number of stop characters we will send + * when our read queue is getting full + */ #define MAX_STOPS_SENT 5 /* 4 extra for alignment play space */ @@ -165,12 +167,15 @@ struct dgnc_board { uint maxports; /* MAX ports this board can handle */ unsigned char dvid; /* Board specific device id */ unsigned char vpd[128]; /* VPD of board, if found */ - unsigned char serial_num[20]; /* Serial number of board, if found in VPD */ + unsigned char serial_num[20]; /* Serial number of board, + * if found in VPD + */ spinlock_t bd_lock; /* Used to protect board */ - spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and - * the interrupt routine from each other. + spinlock_t bd_intr_lock; /* Used to protect the poller tasklet + * and the interrupt routine from each + * other. */ uint state; /* State of card. */ @@ -189,14 +194,16 @@ struct dgnc_board { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - u8 __iomem *re_map_membase;/* Remapped memory of the card */ + u8 __iomem *re_map_membase; /* Remapped memory of the card */ ulong iobase; /* Start of io base of the card */ ulong iobase_end; /* End of io base of the card */ uint bd_uart_offset; /* Space between each UART */ - struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */ + struct channel_t *channels[MAXPORTS]; /* array of pointers + * to our channels. + */ struct tty_driver SerialDriver; char SerialName[200]; @@ -211,8 +218,12 @@ struct dgnc_board { uint TtyRefCnt; - u16 dpatype; /* The board "type", as defined by DPA */ - u16 dpastatus; /* The board "status", as defined by DPA */ + u16 dpatype; /* The board "type", + * as defined by DPA + */ + u16 dpastatus; /* The board "status", + * as defined by DPA + */ /* * Mgmt data. @@ -304,7 +315,7 @@ struct un_t { ************************************************************************/ struct channel_t { int magic; /* Channel Magic Number */ - struct dgnc_board *ch_bd; /* Board structure pointer */ + struct dgnc_board *ch_bd; /* Board structure pointer */ struct digi_t ch_digi; /* Transparent Print structure */ struct un_t ch_tun; /* Terminal unit info */ struct un_t ch_pun; /* Printer unit info */ @@ -316,7 +327,9 @@ struct channel_t { uint ch_open_count; /* open count */ uint ch_flags; /* Channel flags */ - ulong ch_close_delay; /* How long we should drop RTS/DTR for */ + ulong ch_close_delay; /* How long we should + * drop RTS/DTR for + */ ulong ch_cpstime; /* Time for CPS calculations */ @@ -332,11 +345,15 @@ struct channel_t { uint ch_wopen; /* Waiting for open process cnt */ - unsigned char ch_mostat; /* FEP output modem status */ - unsigned char ch_mistat; /* FEP input modem status */ + unsigned char ch_mostat; /* FEP output modem status */ + unsigned char ch_mistat; /* FEP input modem status */ - struct neo_uart_struct __iomem *ch_neo_uart; /* Pointer to the "mapped" UART struct */ - struct cls_uart_struct __iomem *ch_cls_uart; /* Pointer to the "mapped" UART struct */ + struct neo_uart_struct __iomem *ch_neo_uart; /* Pointer to the + * "mapped" UART struct + */ + struct cls_uart_struct __iomem *ch_cls_uart; /* Pointer to the + * "mapped" UART struct + */ unsigned char ch_cached_lsr; /* Cached value of the LSR register */ @@ -360,10 +377,13 @@ struct channel_t { unsigned char ch_r_watermark; /* Receive Watermark */ - ulong ch_stop_sending_break; /* Time we should STOP sending a break */ + ulong ch_stop_sending_break; /* Time we should STOP + * sending a break + */ - uint ch_stops_sent; /* How many times I have sent a stop character - * to try to stop the other guy sending. + uint ch_stops_sent; /* How many times I have sent a stop + * character to try to stop the other + * guy sending. */ ulong ch_err_parity; /* Count of parity errors on channel */ ulong ch_err_frame; /* Count of framing errors on channel */ @@ -390,7 +410,10 @@ struct channel_t { extern uint dgnc_Major; /* Our driver/mgmt major */ extern int dgnc_poll_tick; /* Poll interval - 20 ms */ extern spinlock_t dgnc_global_lock; /* Driver global spinlock */ +extern spinlock_t dgnc_poll_lock; /* Poll scheduling lock */ extern uint dgnc_NumBoards; /* Total number of boards */ -extern struct dgnc_board *dgnc_Board[MAXBOARDS]; /* Array of board structs */ +extern struct dgnc_board *dgnc_Board[MAXBOARDS]; /* Array of board + * structs + */ #endif diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index b13318a82..518fbd5e2 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -32,11 +32,9 @@ #include "dgnc_pci.h" #include "dgnc_mgmt.h" - /* Our "in use" variables, to enforce 1 open only */ static int dgnc_mgmt_in_use[MAXMGMTDEVICES]; - /* * dgnc_mgmt_open() * @@ -67,7 +65,6 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) return 0; } - /* * dgnc_mgmt_close() * @@ -90,7 +87,6 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) return 0; } - /* * dgnc_mgmt_ioctl() * @@ -100,10 +96,9 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { unsigned long flags; - void __user *uarg = (void __user *) arg; + void __user *uarg = (void __user *)arg; switch (cmd) { - case DIGI_GETDD: { /* @@ -115,6 +110,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) spin_lock_irqsave(&dgnc_global_lock, flags); + memset(&ddi, 0, sizeof(ddi)); ddi.dinfo_nboards = dgnc_NumBoards; sprintf(ddi.dinfo_version, "%s", DG_PART); @@ -147,8 +143,9 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) di.info_bdtype = dgnc_Board[brd]->dpatype; di.info_bdstate = dgnc_Board[brd]->dpastatus; di.info_ioport = 0; - di.info_physaddr = (ulong) dgnc_Board[brd]->membase; - di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end; + di.info_physaddr = (ulong)dgnc_Board[brd]->membase; + di.info_physsize = (ulong)dgnc_Board[brd]->membase + - dgnc_Board[brd]->membase_end; if (dgnc_Board[brd]->state != BOARD_FAILED) di.info_nports = dgnc_Board[brd]->nasync; else @@ -254,8 +251,6 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - - } return 0; diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 900e3ae55..8106f5234 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -13,7 +13,6 @@ * PURPOSE. See the GNU General Public License for more details. */ - #include <linux/kernel.h> #include <linux/sched.h> /* For jiffies, task states */ #include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */ @@ -57,7 +56,6 @@ static uint neo_get_uart_bytes_left(struct channel_t *ch); static void neo_send_immediate_char(struct channel_t *ch, unsigned char c); static irqreturn_t neo_intr(int irq, void *voidbrd); - struct board_ops dgnc_neo_ops = { .tasklet = neo_tasklet, .intr = neo_intr, @@ -81,7 +79,6 @@ struct board_ops dgnc_neo_ops = { static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; - /* * This function allows calls to ensure that all outstanding * PCI writes have been completed, by doing a PCI read against @@ -100,7 +97,6 @@ static inline void neo_set_cts_flow_control(struct channel_t *ch) unsigned char ier = readb(&ch->ch_neo_uart->ier); unsigned char efr = readb(&ch->ch_neo_uart->efr); - /* Turn on auto CTS flow control */ #if 1 ier |= UART_17158_IER_CTSDSR; @@ -131,7 +127,6 @@ static inline void neo_set_cts_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static inline void neo_set_rts_flow_control(struct channel_t *ch) { unsigned char ier = readb(&ch->ch_neo_uart->ier); @@ -174,7 +169,6 @@ static inline void neo_set_rts_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static inline void neo_set_ixon_flow_control(struct channel_t *ch) { unsigned char ier = readb(&ch->ch_neo_uart->ier); @@ -211,7 +205,6 @@ static inline void neo_set_ixon_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static inline void neo_set_ixoff_flow_control(struct channel_t *ch) { unsigned char ier = readb(&ch->ch_neo_uart->ier); @@ -249,7 +242,6 @@ static inline void neo_set_ixoff_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static inline void neo_set_no_input_flow_control(struct channel_t *ch) { unsigned char ier = readb(&ch->ch_neo_uart->ier); @@ -266,7 +258,6 @@ static inline void neo_set_no_input_flow_control(struct channel_t *ch) else efr &= ~(UART_17158_EFR_ECB | UART_17158_EFR_IXOFF); - /* Why? Becuz Exar's spec says we have to zero it out before setting it */ writeb(0, &ch->ch_neo_uart->efr); @@ -289,7 +280,6 @@ static inline void neo_set_no_input_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static inline void neo_set_no_output_flow_control(struct channel_t *ch) { unsigned char ier = readb(&ch->ch_neo_uart->ier); @@ -327,11 +317,9 @@ static inline void neo_set_no_output_flow_control(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - /* change UARTs start/stop chars */ static inline void neo_set_new_start_stop_chars(struct channel_t *ch) { - /* if hardware flow control is set, then skip this whole thing */ if (ch->ch_digi.digi_flags & (CTSPACE | RTSPACE) || ch->ch_c_cflag & CRTSCTS) return; @@ -346,7 +334,6 @@ static inline void neo_set_new_start_stop_chars(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - /* * No locks are assumed to be held when calling this function. */ @@ -377,7 +364,6 @@ static inline void neo_clear_break(struct channel_t *ch, int force) spin_unlock_irqrestore(&ch->ch_lock, flags); } - /* * Parse the ISR register. */ @@ -400,7 +386,6 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) /* Here we try to figure out what caused the interrupt to happen */ while (1) { - isr = readb(&ch->ch_neo_uart->isr_fcr); /* Bail if no pending interrupt */ @@ -507,7 +492,6 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) } } - static inline void neo_parse_lsr(struct dgnc_board *brd, uint port) { struct channel_t *ch; @@ -587,7 +571,6 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port) } } - /* * neo_param() * Send any/all changes to the line to the UART. @@ -607,7 +590,7 @@ static void neo_param(struct tty_struct *tty) if (!tty || tty->magic != TTY_MAGIC) return; - un = (struct un_t *) tty->driver_data; + un = (struct un_t *)tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; @@ -641,7 +624,6 @@ static void neo_param(struct tty_struct *tty) return; } else if (ch->ch_custom_speed) { - baud = ch->ch_custom_speed; /* Handle transition from B0 */ if (ch->ch_flags & CH_BAUD0) { @@ -841,13 +823,12 @@ static void neo_param(struct tty_struct *tty) neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); } - /* * Our board poller function. */ static void neo_tasklet(unsigned long data) { - struct dgnc_board *bd = (struct dgnc_board *) data; + struct dgnc_board *bd = (struct dgnc_board *)data; struct channel_t *ch; unsigned long flags; int i; @@ -917,10 +898,8 @@ static void neo_tasklet(unsigned long data) /* Allow interrupt routine to access the interrupt register again */ spin_unlock_irqrestore(&bd->bd_intr_lock, flags); - } - /* * dgnc_neo_intr() * @@ -972,7 +951,6 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) /* Loop on each port */ while ((uart_poll & 0xff) != 0) { - tmp = uart_poll; /* Check current port to see if it has interrupt pending */ @@ -995,7 +973,6 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) /* Switch on type of interrupt we have */ switch (type) { - case UART_17158_RXRDY_TIMEOUT: /* * RXRDY Time-out is cleared by reading data in the @@ -1067,7 +1044,6 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) return IRQ_HANDLED; } - /* * Neo specific way of turning off the receiver. * Used as a way to enforce queue flow control when in @@ -1082,7 +1058,6 @@ static void neo_disable_receiver(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - /* * Neo specific way of turning on the receiver. * Used as a way to un-enforce queue flow control when in @@ -1097,7 +1072,6 @@ static void neo_enable_receiver(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) { int qleft = 0; @@ -1153,7 +1127,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) total -= 3; } - /* * Finally, bound the copy to make sure we don't overflow * our own queue... @@ -1163,7 +1136,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) total = min(total, qleft); while (total > 0) { - /* * Grab the linestatus register, we need to check * to see if there are any errors in the FIFO. @@ -1179,7 +1151,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) break; /* Make sure we don't go over the end of our queue */ - n = min(((uint) total), (RQUEUESIZE - (uint) head)); + n = min(((uint)total), (RQUEUESIZE - (uint)head)); /* * Cut down n even further if needed, this is to fix @@ -1228,7 +1200,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) * Also deal with any possible queue overflow here as well. */ while (1) { - /* * Its possible we have a linestatus from the loop above * this, so we "OR" on any extra bits. @@ -1285,7 +1256,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) } memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1); - ch->ch_equeue[head] = (unsigned char) linestatus; + ch->ch_equeue[head] = (unsigned char)linestatus; /* Ditch any remaining linestatus value. */ linestatus = 0; @@ -1306,7 +1277,6 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) spin_unlock_irqrestore(&ch->ch_lock, flags); } - /* * This function basically goes to sleep for secs, or until * it gets signalled that the port has fully drained. @@ -1321,7 +1291,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; - un = (struct un_t *) tty->driver_data; + un = (struct un_t *)tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return -ENXIO; @@ -1345,7 +1315,6 @@ static int neo_drain(struct tty_struct *tty, uint seconds) return rc; } - /* * Flush the WRITE FIFO on the Neo. * @@ -1363,7 +1332,6 @@ static void neo_flush_uart_write(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); for (i = 0; i < 10; i++) { - /* Check to see if the UART feels it completely flushed the FIFO. */ tmp = readb(&ch->ch_neo_uart->isr_fcr); if (tmp & 4) @@ -1375,7 +1343,6 @@ static void neo_flush_uart_write(struct channel_t *ch) ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); } - /* * Flush the READ FIFO on the Neo. * @@ -1393,7 +1360,6 @@ static void neo_flush_uart_read(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); for (i = 0; i < 10; i++) { - /* Check to see if the UART feels it completely flushed the FIFO. */ tmp = readb(&ch->ch_neo_uart->isr_fcr); if (tmp & 2) @@ -1403,7 +1369,6 @@ static void neo_flush_uart_read(struct channel_t *ch) } } - static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) { ushort head; @@ -1425,7 +1390,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) /* If port is "stopped", don't send any data to the UART */ if ((ch->ch_flags & CH_FORCED_STOP) || - (ch->ch_flags & CH_BREAK_SENDING)) + (ch->ch_flags & CH_BREAK_SENDING)) goto exit_unlock; /* @@ -1482,7 +1447,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) n = readb(&ch->ch_neo_uart->tfifo); - if ((unsigned int) n > ch->ch_t_tlevel) + if ((unsigned int)n > ch->ch_t_tlevel) goto exit_unlock; n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel; @@ -1499,7 +1464,6 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) n = min(n, qlen); while (n > 0) { - s = ((head >= tail) ? head : WQUEUESIZE) - tail; s = min(s, n); @@ -1551,7 +1515,6 @@ exit_unlock: spin_unlock_irqrestore(&ch->ch_lock, flags); } - static void neo_parse_modem(struct channel_t *ch, unsigned char signals) { unsigned char msignals = signals; @@ -1608,7 +1571,6 @@ static void neo_parse_modem(struct channel_t *ch, unsigned char signals) ch->ch_mistat &= ~UART_MSR_CTS; } - /* Make the UART raise any of the output signals we want up */ static void neo_assert_modem_signals(struct channel_t *ch) { @@ -1629,7 +1591,6 @@ static void neo_assert_modem_signals(struct channel_t *ch) udelay(10); } - static void neo_send_start_character(struct channel_t *ch) { if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) @@ -1643,7 +1604,6 @@ static void neo_send_start_character(struct channel_t *ch) } } - static void neo_send_stop_character(struct channel_t *ch) { if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) @@ -1657,18 +1617,15 @@ static void neo_send_stop_character(struct channel_t *ch) } } - /* * neo_uart_init */ static void neo_uart_init(struct channel_t *ch) { - writeb(0, &ch->ch_neo_uart->ier); writeb(0, &ch->ch_neo_uart->efr); writeb(UART_EFR_ECB, &ch->ch_neo_uart->efr); - /* Clear out UART and FIFO */ readb(&ch->ch_neo_uart->txrx); writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr); @@ -1682,7 +1639,6 @@ static void neo_uart_init(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - /* * Make the UART completely turn off. */ @@ -1696,7 +1652,6 @@ static void neo_uart_off(struct channel_t *ch) neo_pci_posting_flush(ch->ch_bd); } - static uint neo_get_uart_bytes_left(struct channel_t *ch) { unsigned char left = 0; @@ -1718,7 +1673,6 @@ static uint neo_get_uart_bytes_left(struct channel_t *ch) return left; } - /* Channel lock MUST be held by the calling function! */ static void neo_send_break(struct channel_t *ch, int msecs) { @@ -1754,7 +1708,6 @@ static void neo_send_break(struct channel_t *ch, int msecs) } } - /* * neo_send_immediate_char. * @@ -1772,7 +1725,6 @@ static void neo_send_immediate_char(struct channel_t *ch, unsigned char c) neo_pci_posting_flush(ch->ch_bd); } - static unsigned int neo_read_eeprom(unsigned char __iomem *base, unsigned int address) { unsigned int enable; @@ -1813,7 +1765,6 @@ static unsigned int neo_read_eeprom(unsigned char __iomem *base, unsigned int ad return val; } - static void neo_vpd(struct dgnc_board *brd) { unsigned int i = 0; @@ -1841,6 +1792,6 @@ static void neo_vpd(struct dgnc_board *brd) /* Search for the serial number */ for (i = 0; i < NEO_VPD_IMAGEBYTES - 3; i++) if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N') - strncpy(brd->serial_num, &(brd->vpd[i + 3]), 9); + strncpy(brd->serial_num, &brd->vpd[i + 3], 9); } } diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 44db8703e..74a072599 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -13,7 +13,6 @@ * PURPOSE. See the GNU General Public License for more details. */ - #include <linux/kernel.h> #include <linux/module.h> #include <linux/ctype.h> @@ -26,28 +25,24 @@ #include "dgnc_driver.h" #include "dgnc_mgmt.h" - static ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); } static DRIVER_ATTR(version, S_IRUSR, dgnc_driver_version_show, NULL); - static ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf) { return snprintf(buf, PAGE_SIZE, "%d\n", dgnc_NumBoards); } static DRIVER_ATTR(boards, S_IRUSR, dgnc_driver_boards_show, NULL); - static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf) { return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); } static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL); - static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) { return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); @@ -56,17 +51,23 @@ static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) { + unsigned long flags; + int tick; int ret; - ret = sscanf(buf, "%d\n", &dgnc_poll_tick); + ret = sscanf(buf, "%d\n", &tick); if (ret != 1) return -EINVAL; + + spin_lock_irqsave(&dgnc_poll_lock, flags); + dgnc_poll_tick = tick; + spin_unlock_irqrestore(&dgnc_poll_lock, flags); + return count; } static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store); - void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) { int rc = 0; @@ -80,7 +81,6 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) pr_err("DGNC: sysfs driver_create_file failed!\n"); } - void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) { struct device_driver *driverfs = &dgnc_driver->driver; @@ -91,7 +91,6 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) driver_remove_file(driverfs, &driver_attr_pollrate); } - #define DGNC_VERIFY_BOARD(p, bd) \ do { \ if (!p) \ @@ -104,8 +103,6 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) return 0; \ } while (0) - - static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -145,7 +142,6 @@ static ssize_t dgnc_serial_number_show(struct device *p, } static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL); - static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -164,7 +160,6 @@ static ssize_t dgnc_ports_state_show(struct device *p, } static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL); - static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -183,7 +178,6 @@ static ssize_t dgnc_ports_baud_show(struct device *p, } static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL); - static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) @@ -214,7 +208,6 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, } static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL); - static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -233,7 +226,6 @@ static ssize_t dgnc_ports_iflag_show(struct device *p, } static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL); - static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -252,7 +244,6 @@ static ssize_t dgnc_ports_cflag_show(struct device *p, } static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL); - static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -271,7 +262,6 @@ static ssize_t dgnc_ports_oflag_show(struct device *p, } static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL); - static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -290,7 +280,6 @@ static ssize_t dgnc_ports_lflag_show(struct device *p, } static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL); - static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) @@ -310,7 +299,6 @@ static ssize_t dgnc_ports_digi_flag_show(struct device *p, } static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL); - static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -329,7 +317,6 @@ static ssize_t dgnc_ports_rxcount_show(struct device *p, } static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL); - static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) { @@ -348,7 +335,6 @@ static ssize_t dgnc_ports_txcount_show(struct device *p, } static DEVICE_ATTR(ports_txcount, S_IRUSR, dgnc_ports_txcount_show, NULL); - /* this function creates the sys files that will export each signal status * to sysfs each value will be put in a separate filename */ @@ -357,41 +343,39 @@ void dgnc_create_ports_sysfiles(struct dgnc_board *bd) int rc = 0; dev_set_drvdata(&bd->pdev->dev, bd); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_vpd); - rc |= device_create_file(&(bd->pdev->dev), &dev_attr_serial_number); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_state); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_baud); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_msignals); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_iflag); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_cflag); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_oflag); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_lflag); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_digi_flag); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_rxcount); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_ports_txcount); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_vpd); + rc |= device_create_file(&bd->pdev->dev, &dev_attr_serial_number); if (rc) dev_err(&bd->pdev->dev, "dgnc: sysfs device_create_file failed!\n"); } - /* removes all the sys files created for that port */ void dgnc_remove_ports_sysfiles(struct dgnc_board *bd) { - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); - device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); - device_remove_file(&(bd->pdev->dev), &dev_attr_vpd); - device_remove_file(&(bd->pdev->dev), &dev_attr_serial_number); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_state); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_baud); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_msignals); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_iflag); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_cflag); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_oflag); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_lflag); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_digi_flag); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_rxcount); + device_remove_file(&bd->pdev->dev, &dev_attr_ports_txcount); + device_remove_file(&bd->pdev->dev, &dev_attr_vpd); + device_remove_file(&bd->pdev->dev, &dev_attr_serial_number); } - static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -418,7 +402,6 @@ static ssize_t dgnc_tty_state_show(struct device *d, } static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL); - static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -444,7 +427,6 @@ static ssize_t dgnc_tty_baud_show(struct device *d, } static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL); - static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -479,7 +461,6 @@ static ssize_t dgnc_tty_msignals_show(struct device *d, } static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL); - static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -505,7 +486,6 @@ static ssize_t dgnc_tty_iflag_show(struct device *d, } static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL); - static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -531,7 +511,6 @@ static ssize_t dgnc_tty_cflag_show(struct device *d, } static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL); - static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -557,7 +536,6 @@ static ssize_t dgnc_tty_oflag_show(struct device *d, } static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL); - static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -583,7 +561,6 @@ static ssize_t dgnc_tty_lflag_show(struct device *d, } static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL); - static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -609,7 +586,6 @@ static ssize_t dgnc_tty_digi_flag_show(struct device *d, } static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL); - static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -635,7 +611,6 @@ static ssize_t dgnc_tty_rxcount_show(struct device *d, } static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL); - static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -661,7 +636,6 @@ static ssize_t dgnc_tty_txcount_show(struct device *d, } static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL); - static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) { @@ -689,7 +663,6 @@ static ssize_t dgnc_tty_name_show(struct device *d, } static DEVICE_ATTR(custom_name, S_IRUSR, dgnc_tty_name_show, NULL); - static struct attribute *dgnc_sysfs_tty_entries[] = { &dev_attr_state.attr, &dev_attr_baud.attr, @@ -705,13 +678,11 @@ static struct attribute *dgnc_sysfs_tty_entries[] = { NULL }; - static struct attribute_group dgnc_tty_attribute_group = { .name = NULL, .attrs = dgnc_sysfs_tty_entries, }; - void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) { int ret; @@ -724,10 +695,8 @@ void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) } dev_set_drvdata(c, un); - } - void dgnc_remove_tty_sysfs(struct device *c) { sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index fbfe79a70..48e4b9057 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -63,7 +63,6 @@ static struct digi_t dgnc_digi_init = { .digi_term = "ansi" /* default terminal type */ }; - /* * Define a local default termios struct. All ports will be created * with this termios initially. @@ -80,14 +79,17 @@ static struct ktermios DgncDefaultTermios = { .c_line = 0, }; - /* Our function prototypes */ static int dgnc_tty_open(struct tty_struct *tty, struct file *file); static void dgnc_tty_close(struct tty_struct *tty, struct file *file); -static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); -static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); -static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); -static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); +static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, + struct channel_t *ch); +static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, + unsigned long arg); +static int dgnc_tty_digigeta(struct tty_struct *tty, + struct digi_t __user *retinfo); +static int dgnc_tty_digiseta(struct tty_struct *tty, + struct digi_t __user *new_info); static int dgnc_tty_write_room(struct tty_struct *tty); static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c); static int dgnc_tty_chars_in_buffer(struct tty_struct *tty); @@ -98,17 +100,21 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty); static void dgnc_tty_flush_chars(struct tty_struct *tty); static void dgnc_tty_flush_buffer(struct tty_struct *tty); static void dgnc_tty_hangup(struct tty_struct *tty); -static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); -static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value); +static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, + unsigned int __user *value); +static int dgnc_get_modem_info(struct channel_t *ch, + unsigned int __user *value); static int dgnc_tty_tiocmget(struct tty_struct *tty); -static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); +static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, + unsigned int clear); static int dgnc_tty_send_break(struct tty_struct *tty, int msec); static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout); -static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); -static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); +static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, + int count); +static void dgnc_tty_set_termios(struct tty_struct *tty, + struct ktermios *old_termios); static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch); - static const struct tty_operations dgnc_tty_ops = { .open = dgnc_tty_open, .close = dgnc_tty_close, @@ -163,7 +169,6 @@ int dgnc_tty_preinit(void) return 0; } - /* * dgnc_tty_register() * @@ -186,18 +191,24 @@ int dgnc_tty_register(struct dgnc_board *brd) brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL; brd->SerialDriver.init_termios = DgncDefaultTermios; brd->SerialDriver.driver_name = DRVSTR; - brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); /* * The kernel wants space to store pointers to * tty_struct's and termios's. */ - brd->SerialDriver.ttys = kcalloc(brd->maxports, sizeof(*brd->SerialDriver.ttys), GFP_KERNEL); + brd->SerialDriver.ttys = kcalloc(brd->maxports, + sizeof(*brd->SerialDriver.ttys), + GFP_KERNEL); if (!brd->SerialDriver.ttys) return -ENOMEM; kref_init(&brd->SerialDriver.kref); - brd->SerialDriver.termios = kcalloc(brd->maxports, sizeof(*brd->SerialDriver.termios), GFP_KERNEL); + brd->SerialDriver.termios = kcalloc(brd->maxports, + sizeof(*brd->SerialDriver.termios), + GFP_KERNEL); if (!brd->SerialDriver.termios) return -ENOMEM; @@ -235,18 +246,24 @@ int dgnc_tty_register(struct dgnc_board *brd) brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL; brd->PrintDriver.init_termios = DgncDefaultTermios; brd->PrintDriver.driver_name = DRVSTR; - brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV | + TTY_DRIVER_HARDWARE_BREAK); /* * The kernel wants space to store pointers to * tty_struct's and termios's. Must be separated from * the Serial Driver so we don't get confused */ - brd->PrintDriver.ttys = kcalloc(brd->maxports, sizeof(*brd->PrintDriver.ttys), GFP_KERNEL); + brd->PrintDriver.ttys = kcalloc(brd->maxports, + sizeof(*brd->PrintDriver.ttys), + GFP_KERNEL); if (!brd->PrintDriver.ttys) return -ENOMEM; kref_init(&brd->PrintDriver.kref); - brd->PrintDriver.termios = kcalloc(brd->maxports, sizeof(*brd->PrintDriver.termios), GFP_KERNEL); + brd->PrintDriver.termios = kcalloc(brd->maxports, + sizeof(*brd->PrintDriver.termios), + GFP_KERNEL); if (!brd->PrintDriver.termios) return -ENOMEM; @@ -275,7 +292,6 @@ int dgnc_tty_register(struct dgnc_board *brd) return rc; } - /* * dgnc_tty_init() * @@ -349,16 +365,15 @@ int dgnc_tty_init(struct dgnc_board *brd) struct device *classp; classp = tty_register_device(&brd->SerialDriver, i, - &(ch->ch_bd->pdev->dev)); + &ch->ch_bd->pdev->dev); ch->ch_tun.un_sysfs = classp; dgnc_create_tty_sysfs(&ch->ch_tun, classp); classp = tty_register_device(&brd->PrintDriver, i, - &(ch->ch_bd->pdev->dev)); + &ch->ch_bd->pdev->dev); ch->ch_pun.un_sysfs = classp; dgnc_create_tty_sysfs(&ch->ch_pun, classp); } - } return 0; @@ -371,7 +386,6 @@ err_free_channels: return -ENOMEM; } - /* * dgnc_tty_post_uninit() * @@ -383,7 +397,6 @@ void dgnc_tty_post_uninit(void) dgnc_TmpWriteBuf = NULL; } - /* * dgnc_tty_uninit() * @@ -476,9 +489,6 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) ch->ch_w_head = head; } - - - /*======================================================================= * * dgnc_input - Process received data. @@ -529,9 +539,10 @@ void dgnc_input(struct channel_t *ch) * If the device is not open, or CREAD is off, * flush input data and return immediately. */ - if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || - !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { - + if (!tp || (tp->magic != TTY_MAGIC) || + !(ch->ch_tun.un_flags & UN_ISOPEN) || + !(tp->termios.c_cflag & CREAD) || + (ch->ch_tun.un_flags & UN_CLOSING)) { ch->ch_r_head = tail; /* Force queue flow control to be released, if needed */ @@ -614,16 +625,28 @@ void dgnc_input(struct channel_t *ch) if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { for (i = 0; i < s; i++) { if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_BREAK); - else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_PARITY); - else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_FRAME); + tty_insert_flip_char(tp->port, + *(ch->ch_rqueue + tail + i), + TTY_BREAK); + else if (*(ch->ch_equeue + tail + i) & + UART_LSR_PE) + tty_insert_flip_char(tp->port, + *(ch->ch_rqueue + tail + i), + TTY_PARITY); + else if (*(ch->ch_equeue + tail + i) & + UART_LSR_FE) + tty_insert_flip_char(tp->port, + *(ch->ch_rqueue + tail + i), + TTY_FRAME); else - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); + tty_insert_flip_char(tp->port, + *(ch->ch_rqueue + tail + i), + TTY_NORMAL); } } else { - tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); + tty_insert_flip_string(tp->port, + ch->ch_rqueue + tail, + s); } tail += s; @@ -650,7 +673,6 @@ exit_unlock: tty_ldisc_deref(ld); } - /************************************************************************ * Determines when CARRIER changes state and takes appropriate * action. @@ -683,13 +705,12 @@ void dgnc_carrier(struct channel_t *ch) * Test for a VIRTUAL carrier transition to HIGH. */ if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { - /* * When carrier rises, wake any threads waiting * for carrier in the open routine. */ - if (waitqueue_active(&(ch->ch_flags_wait))) + if (waitqueue_active(&ch->ch_flags_wait)) wake_up_interruptible(&ch->ch_flags_wait); } @@ -697,13 +718,12 @@ void dgnc_carrier(struct channel_t *ch) * Test for a PHYSICAL carrier transition to HIGH. */ if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { - /* * When carrier rises, wake any threads waiting * for carrier in the open routine. */ - if (waitqueue_active(&(ch->ch_flags_wait))) + if (waitqueue_active(&ch->ch_flags_wait)) wake_up_interruptible(&ch->ch_flags_wait); } @@ -718,7 +738,6 @@ void dgnc_carrier(struct channel_t *ch) */ if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && (phys_carrier == 0)) { - /* * When carrier drops: * @@ -731,7 +750,7 @@ void dgnc_carrier(struct channel_t *ch) * * Enable all select calls. */ - if (waitqueue_active(&(ch->ch_flags_wait))) + if (waitqueue_active(&ch->ch_flags_wait)) wake_up_interruptible(&ch->ch_flags_wait); if (ch->ch_tun.un_open_count > 0) @@ -801,8 +820,8 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) */ if (testrate_high != newrate) { /* - * Otherwise, pick the rate that is closer (i.e. whichever rate - * has a smaller delta). + * Otherwise, pick the rate that is closer + * (i.e. whichever rate has a smaller delta). */ deltahigh = testrate_high - newrate; deltalow = newrate - testrate_low; @@ -817,10 +836,9 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) ch->ch_custom_speed = newrate; } - void dgnc_check_queue_flow_control(struct channel_t *ch) { - int qleft = 0; + int qleft; /* Store how much space we have left in the queue */ qleft = ch->ch_r_tail - ch->ch_r_head - 1; @@ -844,7 +862,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) */ if (qleft < 256) { /* HWFLOW */ - if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { + if (ch->ch_digi.digi_flags & CTSPACE || + ch->ch_c_cflag & CRTSCTS) { if (!(ch->ch_flags & CH_RECEIVER_OFF)) { ch->ch_bd->bd_ops->disable_receiver(ch); ch->ch_flags |= (CH_RECEIVER_OFF); @@ -876,7 +895,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) */ if (qleft > (RQUEUESIZE / 2)) { /* HWFLOW */ - if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { + if (ch->ch_digi.digi_flags & RTSPACE || + ch->ch_c_cflag & CRTSCTS) { if (ch->ch_flags & CH_RECEIVER_OFF) { ch->ch_bd->bd_ops->enable_receiver(ch); ch->ch_flags &= ~(CH_RECEIVER_OFF); @@ -890,7 +910,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) } } - void dgnc_wakeup_writes(struct channel_t *ch) { int qlen = 0; @@ -915,9 +934,9 @@ void dgnc_wakeup_writes(struct channel_t *ch) if (ch->ch_tun.un_flags & UN_ISOPEN) { if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_tun.un_tty->ldisc->ops->write_wakeup) { + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) { spin_unlock_irqrestore(&ch->ch_lock, flags); - (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); + ch->ch_tun.un_tty->ldisc->ops->write_wakeup(ch->ch_tun.un_tty); spin_lock_irqsave(&ch->ch_lock, flags); } @@ -928,7 +947,8 @@ void dgnc_wakeup_writes(struct channel_t *ch) * the queue AND FIFO are both empty. */ if (ch->ch_tun.un_flags & UN_EMPTY) { - if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { + if ((qlen == 0) && + (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { ch->ch_tun.un_flags &= ~(UN_EMPTY); /* @@ -956,9 +976,9 @@ void dgnc_wakeup_writes(struct channel_t *ch) if (ch->ch_pun.un_flags & UN_ISOPEN) { if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_pun.un_tty->ldisc->ops->write_wakeup) { + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) { spin_unlock_irqrestore(&ch->ch_lock, flags); - (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); + ch->ch_pun.un_tty->ldisc->ops->write_wakeup(ch->ch_pun.un_tty); spin_lock_irqsave(&ch->ch_lock, flags); } @@ -969,7 +989,8 @@ void dgnc_wakeup_writes(struct channel_t *ch) * the queue AND FIFO are both empty. */ if (ch->ch_pun.un_flags & UN_EMPTY) { - if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) + if ((qlen == 0) && + (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) ch->ch_pun.un_flags &= ~(UN_EMPTY); } @@ -979,8 +1000,6 @@ void dgnc_wakeup_writes(struct channel_t *ch) spin_unlock_irqrestore(&ch->ch_lock, flags); } - - /************************************************************************ * * TTY Entry points and helper functions @@ -1019,7 +1038,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) * sleep waiting for it to happen or they cancel the open. */ rc = wait_event_interruptible(brd->state_wait, - (brd->state & BOARD_READY)); + (brd->state & BOARD_READY)); if (rc) return rc; @@ -1063,7 +1082,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) */ spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0)); + rc = wait_event_interruptible(ch->ch_flags_wait, + ((ch->ch_flags & CH_OPENING) == 0)); /* If ret is non-zero, user ctrl-c'ed us */ if (rc) @@ -1077,7 +1097,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) * ch_flags_wait to wake us back up. */ rc = wait_event_interruptible(ch->ch_flags_wait, - (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING) == 0)); + (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & + UN_CLOSING) == 0)); /* If ret is non-zero, user ctrl-c'ed us */ if (rc) @@ -1085,11 +1106,9 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) spin_lock_irqsave(&ch->ch_lock, flags); - /* Store our unit into driver_data, so we always have it available. */ tty->driver_data = un; - /* * Initialize tty's */ @@ -1100,7 +1119,6 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) /* Maybe do something here to the TTY struct as well? */ } - /* * Allocate channel buffers for read/write/error. * Set flag, so we don't get trounced on. @@ -1126,7 +1144,6 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) * Initialize if neither terminal or printer is open. */ if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { - /* * Flush input queues. */ @@ -1190,13 +1207,14 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) return rc; } - /* * dgnc_block_til_ready() * * Wait for DCD, if needed. */ -static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) +static int dgnc_block_til_ready(struct tty_struct *tty, + struct file *file, + struct channel_t *ch) { int retval = 0; struct un_t *un = NULL; @@ -1204,7 +1222,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc uint old_flags = 0; int sleep_on_un_flags = 0; - if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGNC_CHANNEL_MAGIC) + if (!tty || tty->magic != TTY_MAGIC || !file || !ch || + ch->magic != DGNC_CHANNEL_MAGIC) return -ENXIO; un = tty->driver_data; @@ -1217,11 +1236,11 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc /* Loop forever */ while (1) { - sleep_on_un_flags = 0; /* - * If board has failed somehow during our sleep, bail with error. + * If board has failed somehow during our sleep, + * bail with error. */ if (ch->ch_bd->state == BOARD_FAILED) { retval = -ENXIO; @@ -1241,8 +1260,9 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc * touched safely, the close routine will signal the * ch_wait_flags to wake us back up. */ - if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { - + if (!((ch->ch_tun.un_flags | + ch->ch_pun.un_flags) & + UN_CLOSING)) { /* * Our conditions to leave cleanly and happily: * 1) NONBLOCKING on the tty is set. @@ -1294,11 +1314,13 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc spin_unlock_irqrestore(&ch->ch_lock, flags); /* - * Wait for something in the flags to change from the current value. + * Wait for something in the flags to change + * from the current value. */ if (sleep_on_un_flags) retval = wait_event_interruptible(un->un_flags_wait, - (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); + (old_flags != (ch->ch_tun.un_flags | + ch->ch_pun.un_flags))); else retval = wait_event_interruptible(ch->ch_flags_wait, (old_flags != ch->ch_flags)); @@ -1314,13 +1336,9 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc spin_unlock_irqrestore(&ch->ch_lock, flags); - if (retval) - return retval; - - return 0; + return retval; } - /* * dgnc_tty_hangup() * @@ -1339,22 +1357,18 @@ static void dgnc_tty_hangup(struct tty_struct *tty) /* flush the transmit queues */ dgnc_tty_flush_buffer(tty); - } - /* * dgnc_tty_close() * */ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) { - struct ktermios *ts; struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; unsigned long flags; - int rc = 0; if (!tty || tty->magic != TTY_MAGIC) return; @@ -1371,8 +1385,6 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - ts = &tty->termios; - spin_lock_irqsave(&ch->ch_lock, flags); /* @@ -1412,13 +1424,12 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) tty->closing = 1; - /* * Only officially close channel if count is 0 and * DIGI_PRINTER bit is not set. */ - if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { - + if ((ch->ch_open_count == 0) && + !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { ch->ch_flags &= ~(CH_STOPI | CH_FORCED_STOPI); /* @@ -1426,7 +1437,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) */ if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); + (int)ch->ch_digi.digi_offlen); ch->ch_flags &= ~CH_PRON; } @@ -1434,7 +1445,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) /* wait for output to drain */ /* This will also return if we take an interrupt */ - rc = bd->bd_ops->drain(tty, 0); + bd->bd_ops->drain(tty, 0); dgnc_tty_flush_buffer(tty); tty_ldisc_flush(tty); @@ -1447,7 +1458,6 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) * If we have HUPCL set, lower DTR and RTS */ if (ch->ch_c_cflag & HUPCL) { - /* Drop RTS/DTR */ ch->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS); bd->bd_ops->assert_modem_signals(ch); @@ -1474,7 +1484,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) */ if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); + (int)ch->ch_digi.digi_offlen); ch->ch_flags &= ~CH_PRON; } } @@ -1488,7 +1498,6 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) spin_unlock_irqrestore(&ch->ch_lock, flags); } - /* * dgnc_tty_chars_in_buffer() * @@ -1507,7 +1516,7 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) uint chars = 0; unsigned long flags; - if (tty == NULL) + if (!tty) return 0; un = tty->driver_data; @@ -1538,7 +1547,6 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) return chars; } - /* * dgnc_maxcps_room * @@ -1574,15 +1582,17 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) int cps_limit = 0; unsigned long current_time = jiffies; unsigned long buffer_time = current_time + - (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; + (HZ * ch->ch_digi.digi_bufsize) / + ch->ch_digi.digi_maxcps; if (ch->ch_cpstime < current_time) { /* buffer is empty */ - ch->ch_cpstime = current_time; /* reset ch_cpstime */ + ch->ch_cpstime = current_time; /* reset ch_cpstime */ cps_limit = ch->ch_digi.digi_bufsize; } else if (ch->ch_cpstime < buffer_time) { /* still room in the buffer */ - cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; + cps_limit = ((buffer_time - ch->ch_cpstime) * + ch->ch_digi.digi_maxcps) / HZ; } else { /* no room in the buffer */ cps_limit = 0; @@ -1594,7 +1604,6 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) return bytes_available; } - /* * dgnc_tty_write_room() * @@ -1610,7 +1619,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) int ret = 0; unsigned long flags; - if (tty == NULL || dgnc_TmpWriteBuf == NULL) + if (!tty || !dgnc_TmpWriteBuf) return 0; un = tty->driver_data; @@ -1655,7 +1664,6 @@ static int dgnc_tty_write_room(struct tty_struct *tty) return ret; } - /* * dgnc_tty_put_char() * @@ -1672,7 +1680,6 @@ static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) return 1; } - /* * dgnc_tty_write() * @@ -1680,19 +1687,18 @@ static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) * In here exists all the Transparent Print magic as well. */ static int dgnc_tty_write(struct tty_struct *tty, - const unsigned char *buf, int count) + const unsigned char *buf, int count) { struct channel_t *ch = NULL; struct un_t *un = NULL; int bufcount = 0, n = 0; - int orig_count = 0; unsigned long flags; ushort head; ushort tail; ushort tmask; uint remain; - if (tty == NULL || dgnc_TmpWriteBuf == NULL) + if (!tty || !dgnc_TmpWriteBuf) return 0; un = tty->driver_data; @@ -1711,7 +1717,6 @@ static int dgnc_tty_write(struct tty_struct *tty, * This helps to figure out if we should ask the FEP * to send us an event when it has more space available. */ - orig_count = count; spin_lock_irqsave(&ch->ch_lock, flags); @@ -1748,7 +1753,7 @@ static int dgnc_tty_write(struct tty_struct *tty, */ if ((un->un_type == DGNC_PRINT) && !(ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_onstr, - (int) ch->ch_digi.digi_onlen); + (int)ch->ch_digi.digi_onlen); head = (ch->ch_w_head) & tmask; ch->ch_flags |= CH_PRON; } @@ -1759,7 +1764,7 @@ static int dgnc_tty_write(struct tty_struct *tty, */ if ((un->un_type != DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_offstr, - (int) ch->ch_digi.digi_offlen); + (int)ch->ch_digi.digi_offlen); head = (ch->ch_w_head) & tmask; ch->ch_flags &= ~CH_PRON; } @@ -1818,7 +1823,6 @@ exit_retry: return 0; } - /* * Return modem signals to ld. */ @@ -1866,7 +1870,6 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) return result; } - /* * dgnc_tty_tiocmset() * @@ -1874,7 +1877,7 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty) */ static int dgnc_tty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) + unsigned int set, unsigned int clear) { struct dgnc_board *bd; struct channel_t *ch; @@ -1918,7 +1921,6 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, return 0; } - /* * dgnc_tty_send_break() * @@ -1965,10 +1967,8 @@ static int dgnc_tty_send_break(struct tty_struct *tty, int msec) spin_unlock_irqrestore(&ch->ch_lock, flags); return 0; - } - /* * dgnc_tty_wait_until_sent() * @@ -1979,7 +1979,6 @@ static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; - int rc; if (!tty || tty->magic != TTY_MAGIC) return; @@ -1996,10 +1995,9 @@ static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - rc = bd->bd_ops->drain(tty, 0); + bd->bd_ops->drain(tty, 0); } - /* * dgnc_send_xchar() * @@ -2036,9 +2034,6 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n"); } - - - /* * Return modem signals to ld. */ @@ -2075,12 +2070,11 @@ static inline int dgnc_get_mstat(struct channel_t *ch) return result; } - - /* * Return modem signals to ld. */ -static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value) +static int dgnc_get_modem_info(struct channel_t *ch, + unsigned int __user *value) { int result; @@ -2095,13 +2089,14 @@ static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value return put_user(result, value); } - /* * dgnc_set_modem_info() * * Set modem signals, called by ld. */ -static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) +static int dgnc_set_modem_info(struct tty_struct *tty, + unsigned int command, + unsigned int __user *value) { struct dgnc_board *bd; struct channel_t *ch; @@ -2175,7 +2170,6 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns return 0; } - /* * dgnc_tty_digigeta() * @@ -2184,7 +2178,8 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns * * */ -static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) +static int dgnc_tty_digigeta(struct tty_struct *tty, + struct digi_t __user *retinfo) { struct channel_t *ch; struct un_t *un; @@ -2217,7 +2212,6 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin return 0; } - /* * dgnc_tty_digiseta() * @@ -2226,7 +2220,8 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin * * */ -static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) +static int dgnc_tty_digiseta(struct tty_struct *tty, + struct digi_t __user *new_info) { struct dgnc_board *bd; struct channel_t *ch; @@ -2257,17 +2252,21 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i /* * Handle transistions to and from RTS Toggle. */ - if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && (new_digi.digi_flags & DIGI_RTS_TOGGLE)) + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && + (new_digi.digi_flags & DIGI_RTS_TOGGLE)) ch->ch_mostat &= ~(UART_MCR_RTS); - if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && !(new_digi.digi_flags & DIGI_RTS_TOGGLE)) + if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && + !(new_digi.digi_flags & DIGI_RTS_TOGGLE)) ch->ch_mostat |= (UART_MCR_RTS); /* * Handle transistions to and from DTR Toggle. */ - if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && (new_digi.digi_flags & DIGI_DTR_TOGGLE)) + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && + (new_digi.digi_flags & DIGI_DTR_TOGGLE)) ch->ch_mostat &= ~(UART_MCR_DTR); - if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && !(new_digi.digi_flags & DIGI_DTR_TOGGLE)) + if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && + !(new_digi.digi_flags & DIGI_DTR_TOGGLE)) ch->ch_mostat |= (UART_MCR_DTR); memcpy(&ch->ch_digi, &new_digi, sizeof(new_digi)); @@ -2300,11 +2299,11 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i return 0; } - /* * dgnc_set_termios() */ -static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) +static void dgnc_tty_set_termios(struct tty_struct *tty, + struct ktermios *old_termios) { struct dgnc_board *bd; struct channel_t *ch; @@ -2341,7 +2340,6 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te spin_unlock_irqrestore(&ch->ch_lock, flags); } - static void dgnc_tty_throttle(struct tty_struct *tty) { struct channel_t *ch; @@ -2366,7 +2364,6 @@ static void dgnc_tty_throttle(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - static void dgnc_tty_unthrottle(struct tty_struct *tty) { struct channel_t *ch; @@ -2391,7 +2388,6 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - static void dgnc_tty_start(struct tty_struct *tty) { struct dgnc_board *bd; @@ -2421,7 +2417,6 @@ static void dgnc_tty_start(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - static void dgnc_tty_stop(struct tty_struct *tty) { struct dgnc_board *bd; @@ -2451,7 +2446,6 @@ static void dgnc_tty_stop(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - /* * dgnc_tty_flush_chars() * @@ -2494,8 +2488,6 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - - /* * dgnc_tty_flush_buffer() * @@ -2540,8 +2532,6 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, flags); } - - /***************************************************************************** * * The IOCTL function and all of its helpers @@ -2554,14 +2544,14 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) * The usual assortment of ioctl's */ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg) + unsigned long arg) { struct dgnc_board *bd; struct channel_t *ch; struct un_t *un; int rc; unsigned long flags; - void __user *uarg = (void __user *) arg; + void __user *uarg = (void __user *)arg; if (!tty || tty->magic != TTY_MAGIC) return -ENODEV; @@ -2586,7 +2576,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } switch (cmd) { - /* Here are all the standard ioctl's that we MUST implement */ case TCSBRK: @@ -2617,7 +2606,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return 0; - case TCSBRKP: /* support for POSIX tcsendbreak() * According to POSIX.1 spec (7.2.2.1.2) breaks should be @@ -2668,18 +2656,20 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); + rc = put_user(C_CLOCAL(tty) ? 1 : 0, + (unsigned long __user *)arg); return rc; case TIOCSSOFTCAR: spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = get_user(arg, (unsigned long __user *) arg); + rc = get_user(arg, (unsigned long __user *)arg); if (rc) return rc; spin_lock_irqsave(&ch->ch_lock, flags); - tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | + (arg ? CLOCAL : 0)); ch->ch_bd->bd_ops->param(tty); spin_unlock_irqrestore(&ch->ch_lock, flags); @@ -2728,15 +2718,16 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ch->ch_bd->bd_ops->flush_uart_write(ch); if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + ch->ch_tun.un_flags &= + ~(UN_LOW|UN_EMPTY); wake_up_interruptible(&ch->ch_tun.un_flags_wait); } if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { - ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + ch->ch_pun.un_flags &= + ~(UN_LOW|UN_EMPTY); wake_up_interruptible(&ch->ch_pun.un_flags_wait); } - } } @@ -2797,7 +2788,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* set information for ditty */ if (cmd == (DIGI_SETAW)) { - spin_unlock_irqrestore(&ch->ch_lock, flags); rc = ch->ch_bd->bd_ops->drain(tty, 0); @@ -2817,9 +2807,11 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case DIGI_LOOPBACK: { uint loopback = 0; - /* Let go of locks when accessing user space, could sleep */ + /* Let go of locks when accessing user space, + * could sleep + */ spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = get_user(loopback, (unsigned int __user *) arg); + rc = get_user(loopback, (unsigned int __user *)arg); if (rc) return rc; spin_lock_irqsave(&ch->ch_lock, flags); @@ -2837,7 +2829,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case DIGI_GETCUSTOMBAUD: spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = put_user(ch->ch_custom_speed, (unsigned int __user *) arg); + rc = put_user(ch->ch_custom_speed, (unsigned int __user *)arg); return rc; case DIGI_SETCUSTOMBAUD: @@ -2845,7 +2837,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, int new_rate; /* Let go of locks when accessing user space, could sleep */ spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = get_user(new_rate, (int __user *) arg); + rc = get_user(new_rate, (int __user *)arg); if (rc) return rc; spin_lock_irqsave(&ch->ch_lock, flags); @@ -2867,7 +2859,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned char c; spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = get_user(c, (unsigned char __user *) arg); + rc = get_user(c, (unsigned char __user *)arg); if (rc) return rc; spin_lock_irqsave(&ch->ch_lock, flags); @@ -2915,14 +2907,16 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */ if (ch->ch_flags & CH_BREAK_SENDING) events |= EV_TXB; - if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) + if ((ch->ch_flags & CH_STOP) || + (ch->ch_flags & CH_FORCED_STOP)) events |= (EV_OPU | EV_OPS); - if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI)) + if ((ch->ch_flags & CH_STOPI) || + (ch->ch_flags & CH_FORCED_STOPI)) events |= (EV_IPU | EV_IPS); spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = put_user(events, (unsigned int __user *) arg); + rc = put_user(events, (unsigned int __user *)arg); return rc; } |