diff options
Diffstat (limited to 'drivers/staging/dgnc')
-rw-r--r-- | drivers/staging/dgnc/TODO | 6 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_cls.c | 4 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_driver.c | 9 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_driver.h | 6 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_neo.c | 4 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_sysfs.c | 110 | ||||
-rw-r--r-- | drivers/staging/dgnc/dgnc_tty.c | 110 | ||||
-rw-r--r-- | drivers/staging/dgnc/digi.h | 14 |
8 files changed, 114 insertions, 149 deletions
diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO index 2b2c6ea03..0e0825bd7 100644 --- a/drivers/staging/dgnc/TODO +++ b/drivers/staging/dgnc/TODO @@ -1,9 +1,9 @@ * checkpatch fixes -* remove unecessary comments -* remove unecessary error messages. Example kzalloc() has its +* remove unnecessary comments +* remove unnecessary error messages. Example kzalloc() has its own error message. Adding an extra one is useless. * use goto statements for error handling when appropriate -* there is a lot of unecessary code in the driver. It was +* there is a lot of unnecessary code in the driver. It was originally a standalone driver. Remove uneeded code. Please send patches to Greg Kroah-Hartman <greg@kroah.com> and diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index e3564d278..a629a7896 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -379,7 +379,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port) return; ch = brd->channels[port]; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + if (ch->magic != DGNC_CHANNEL_MAGIC) return; /* Here we try to figure out what caused the interrupt to happen */ @@ -714,8 +714,6 @@ static void cls_tasklet(unsigned long data) /* Loop on each port */ for (i = 0; i < ports; i++) { ch = bd->channels[i]; - if (!ch) - continue; /* * NOTE: Remember you CANNOT hold any channel diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 805dc617e..7546aff65 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -355,7 +355,6 @@ static void dgnc_cleanup_board(struct dgnc_board *brd) } } - kfree(brd->flipbuf); dgnc_Board[brd->boardnum] = NULL; @@ -581,14 +580,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->msgbuf_head = NULL; spin_unlock_irqrestore(&dgnc_global_lock, flags); - /* - * allocate flip buffer for board. - * - * Okay to malloc with GFP_KERNEL, we are not at interrupt - * context, and there are no locks held. - */ - brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); - wake_up_interruptible(&brd->state_wait); return 0; diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index f77fed57b..d04671fa4 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -66,14 +66,13 @@ /* 4 extra for alignment play space */ #define WRITEBUFLEN ((4096) + 4) -#define MYFLIPLEN N_TTY_BUF_SIZE #define dgnc_jiffies_from_ms(a) (((a) * HZ) / 1000) /* * Define a local default termios struct. All ports will be created * with this termios initially. This is the same structure that is defined - * as the default in tty_io.c with the same settings overriden as in serial.c + * as the default in tty_io.c with the same settings overridden as in serial.c * * In short, this should match the internal serial ports' defaults. */ @@ -212,8 +211,6 @@ struct dgnc_board { uint TtyRefCnt; - char *flipbuf; /* Our flip buffer, alloced if board is found */ - u16 dpatype; /* The board "type", as defined by DPA */ u16 dpastatus; /* The board "status", as defined by DPA */ @@ -288,7 +285,6 @@ struct un_t { #define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */ #define CH_BREAK_SENDING 0x1000 /* Break is being sent */ #define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ -#define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */ #define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ #define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ #define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */ diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index f5a4d3651..900e3ae55 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -395,7 +395,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) return; ch = brd->channels[port]; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + if (ch->magic != DGNC_CHANNEL_MAGIC) return; /* Here we try to figure out what caused the interrupt to happen */ @@ -1203,7 +1203,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, n); /* - * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed + * Since RX_FIFO_DATA_ERROR was 0, we are guaranteed * that all the data currently in the FIFO is free of * breaks and parity/frame/orun errors. */ diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 65551d190..44db8703e 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -53,7 +53,8 @@ static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); } -static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) +static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, + const char *buf, size_t count) { int ret; @@ -62,7 +63,8 @@ static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char return -EINVAL; return count; } -static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store); +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) @@ -104,7 +106,8 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) -static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -112,7 +115,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch DGNC_VERIFY_BOARD(p, bd); - count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); + count += sprintf(buf + count, + "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); for (i = 0; i < 0x40 * 2; i++) { if (!(i % 16)) count += sprintf(buf + count, "\n%04X ", i * 2); @@ -124,7 +128,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch } static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL); -static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf) +static ssize_t dgnc_serial_number_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -141,7 +146,8 @@ static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute 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) +static ssize_t dgnc_ports_state_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -159,7 +165,8 @@ static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute * 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) +static ssize_t dgnc_ports_baud_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -169,14 +176,17 @@ static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *a for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, - "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud); + "%d %d\n", bd->channels[i]->ch_portnum, + bd->channels[i]->ch_old_baud); } return count; } 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) +static ssize_t dgnc_ports_msignals_show(struct device *p, + struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -187,7 +197,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut for (i = 0; i < bd->nasync; i++) { if (bd->channels[i]->ch_open_count) { count += snprintf(buf + count, PAGE_SIZE - count, - "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum, + "%d %s %s %s %s %s %s\n", + bd->channels[i]->ch_portnum, (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "", (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "", (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "", @@ -204,7 +215,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut 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) +static ssize_t dgnc_ports_iflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -214,14 +226,16 @@ static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_iflag); } return count; } 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) +static ssize_t dgnc_ports_cflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -231,14 +245,16 @@ static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_cflag); } return count; } 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) +static ssize_t dgnc_ports_oflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -248,14 +264,16 @@ static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_oflag); } return count; } 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) +static ssize_t dgnc_ports_lflag_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -265,14 +283,17 @@ static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute * for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_c_lflag); } return count; } 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) +static ssize_t dgnc_ports_digi_flag_show(struct device *p, + struct device_attribute *attr, + char *buf) { struct dgnc_board *bd; int count = 0; @@ -282,14 +303,16 @@ static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribu for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_digi.digi_flags); } return count; } 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) +static ssize_t dgnc_ports_rxcount_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -299,14 +322,16 @@ static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_rxcount); } return count; } 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) +static ssize_t dgnc_ports_txcount_show(struct device *p, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; int count = 0; @@ -316,7 +341,8 @@ static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute for (i = 0; i < bd->nasync; i++) { count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", - bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount); + bd->channels[i]->ch_portnum, + bd->channels[i]->ch_txcount); } return count; } @@ -366,7 +392,8 @@ void dgnc_remove_ports_sysfiles(struct dgnc_board *bd) } -static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t dgnc_tty_state_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -386,12 +413,14 @@ static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *at if (bd->state != BOARD_READY) return 0; - return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); + return snprintf(buf, PAGE_SIZE, "%s", + un->un_open_count ? "Open" : "Closed"); } 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) +static ssize_t dgnc_tty_baud_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -416,7 +445,8 @@ static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *att 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) +static ssize_t dgnc_tty_msignals_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -450,7 +480,8 @@ static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute 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) +static ssize_t dgnc_tty_iflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -475,7 +506,8 @@ static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *at 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) +static ssize_t dgnc_tty_cflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -500,7 +532,8 @@ static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *at 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) +static ssize_t dgnc_tty_oflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -525,7 +558,8 @@ static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *at 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) +static ssize_t dgnc_tty_lflag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -550,7 +584,8 @@ static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *at 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) +static ssize_t dgnc_tty_digi_flag_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -575,7 +610,8 @@ static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute 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) +static ssize_t dgnc_tty_rxcount_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -600,7 +636,8 @@ static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute * 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) +static ssize_t dgnc_tty_txcount_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; @@ -625,7 +662,8 @@ static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute * 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) +static ssize_t dgnc_tty_name_show(struct device *d, + struct device_attribute *attr, char *buf) { struct dgnc_board *bd; struct channel_t *ch; diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index ce4187f60..fbfe79a70 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -42,16 +42,11 @@ #include "dgnc_sysfs.h" #include "dgnc_utils.h" -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) - /* * internal variables */ static struct dgnc_board *dgnc_BoardsByMajor[256]; static unsigned char *dgnc_TmpWriteBuf; -static DECLARE_MUTEX(dgnc_TmpWriteSem); /* * Default transparent print information. @@ -304,19 +299,15 @@ int dgnc_tty_init(struct dgnc_board *brd) brd->nasync = brd->maxports; - /* - * Allocate channel memory that might not have been allocated - * when the driver was first loaded. - */ for (i = 0; i < brd->nasync; i++) { - if (!brd->channels[i]) { - - /* - * Okay to malloc with GFP_KERNEL, we are not at - * interrupt context, and there are no locks held. - */ - brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL); - } + /* + * Okay to malloc with GFP_KERNEL, we are not at + * interrupt context, and there are no locks held. + */ + brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), + GFP_KERNEL); + if (!brd->channels[i]) + goto err_free_channels; } ch = brd->channels[0]; @@ -324,10 +315,6 @@ int dgnc_tty_init(struct dgnc_board *brd) /* Set up channel variables */ for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { - - if (!brd->channels[i]) - continue; - spin_lock_init(&ch->ch_lock); /* Store all our magic numbers */ @@ -375,6 +362,13 @@ int dgnc_tty_init(struct dgnc_board *brd) } return 0; + +err_free_channels: + for (i = i - 1; i >= 0; --i) { + kfree(brd->channels[i]); + brd->channels[i] = NULL; + } + return -ENOMEM; } @@ -404,7 +398,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL; brd->dgnc_Serial_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_tun.un_sysfs); tty_unregister_device(&brd->SerialDriver, i); } tty_unregister_driver(&brd->SerialDriver); @@ -415,7 +411,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd) dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL; brd->dgnc_TransparentPrint_Major = 0; for (i = 0; i < brd->nasync; i++) { - dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + if (brd->channels[i]) + dgnc_remove_tty_sysfs(brd->channels[i]-> + ch_pun.un_sysfs); tty_unregister_device(&brd->PrintDriver, i); } tty_unregister_driver(&brd->PrintDriver); @@ -424,13 +422,14 @@ void dgnc_tty_uninit(struct dgnc_board *brd) kfree(brd->SerialDriver.ttys); brd->SerialDriver.ttys = NULL; + kfree(brd->SerialDriver.termios); + brd->SerialDriver.termios = NULL; kfree(brd->PrintDriver.ttys); brd->PrintDriver.ttys = NULL; + kfree(brd->PrintDriver.termios); + brd->PrintDriver.termios = NULL; } - -#define TMPBUFLEN (1024) - /*======================================================================= * * dgnc_wmove - Write data to transmit queue. @@ -555,15 +554,6 @@ void dgnc_input(struct channel_t *ch) ld = tty_ldisc_ref(tp); -#ifdef TTY_DONT_FLIP - /* - * If the DONT_FLIP flag is on, don't flush our buffer, and act - * like the ld doesn't have any space to put the data right now. - */ - if (test_bit(TTY_DONT_FLIP, &tp->flags)) - len = 0; -#endif - /* * If we were unable to get a reference to the ld, * don't flush our buffer, and act like the ld doesn't @@ -897,10 +887,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) ch->ch_stops_sent = 0; ch->ch_bd->bd_ops->send_start_character(ch); } - /* No FLOW */ - else { - /* Nothing needed. */ - } } } @@ -1705,7 +1691,6 @@ static int dgnc_tty_write(struct tty_struct *tty, ushort tail; ushort tmask; uint remain; - int from_user = 0; if (tty == NULL || dgnc_TmpWriteBuf == NULL) return 0; @@ -1779,44 +1764,6 @@ static int dgnc_tty_write(struct tty_struct *tty, ch->ch_flags &= ~CH_PRON; } - /* - * If there is nothing left to copy, or I can't handle any more data, leave. - */ - if (count <= 0) - goto exit_retry; - - if (from_user) { - - count = min(count, WRITEBUFLEN); - - spin_unlock_irqrestore(&ch->ch_lock, flags); - - /* - * If data is coming from user space, copy it into a temporary - * buffer so we don't get swapped out while doing the copy to - * the board. - */ - /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgnc_TmpWriteSem)) - return -EINTR; - - /* - * copy_from_user() returns the number - * of bytes that could *NOT* be copied. - */ - count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char __user *) buf, count); - - if (!count) { - up(&dgnc_TmpWriteSem); - return -EFAULT; - } - - spin_lock_irqsave(&ch->ch_lock, flags); - - buf = dgnc_TmpWriteBuf; - - } - n = count; /* @@ -1853,12 +1800,7 @@ static int dgnc_tty_write(struct tty_struct *tty, ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; } - if (from_user) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - up(&dgnc_TmpWriteSem); - } else { - spin_unlock_irqrestore(&ch->ch_lock, flags); - } + spin_unlock_irqrestore(&ch->ch_lock, flags); if (count) { /* diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h index d637a7802..cf9dcae7c 100644 --- a/drivers/staging/dgnc/digi.h +++ b/drivers/staging/dgnc/digi.h @@ -130,19 +130,19 @@ struct digi_getcounter { #define BD_RUNNING 0x0 #define BD_NOFEP 0x5 -#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ -#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ #define DIGI_REALPORT_GETBUFFERS (('e'<<8) | 108) #define DIGI_REALPORT_SENDIMMEDIATE (('e'<<8) | 109) #define DIGI_REALPORT_GETCOUNTERS (('e'<<8) | 110) #define DIGI_REALPORT_GETEVENTS (('e'<<8) | 111) -#define EV_OPU 0x0001 /* !<Output paused by client */ -#define EV_OPS 0x0002 /* !<Output paused by reqular sw flowctrl */ -#define EV_IPU 0x0010 /* !<Input paused unconditionally by user */ -#define EV_IPS 0x0020 /* !<Input paused by high/low water marks */ -#define EV_TXB 0x0040 /* !<Transmit break pending */ +#define EV_OPU 0x0001 /* !<Output paused by client */ +#define EV_OPS 0x0002 /* !<Output paused by reqular sw flowctrl */ +#define EV_IPU 0x0010 /* !<Input paused unconditionally by user */ +#define EV_IPS 0x0020 /* !<Input paused by high/low water marks */ +#define EV_TXB 0x0040 /* !<Transmit break pending */ /* * This structure holds data needed for the intelligent <--> nonintelligent |