diff options
Diffstat (limited to 'drivers/staging/dgrp')
| -rw-r--r-- | drivers/staging/dgrp/dgrp_dpa_ops.c | 2 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_driver.c | 15 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_net_ops.c | 6 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_sysfs.c | 36 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_tty.c | 28 | ||||
| -rw-r--r-- | drivers/staging/dgrp/drp.h | 2 |
6 files changed, 48 insertions, 41 deletions
diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index 114799cddd8..69bfe309376 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -392,7 +392,7 @@ static long dgrp_dpa_ioctl(struct file *file, unsigned int cmd, getnode.nd_rx_byte = nd->nd_rx_byte; memset(&getnode.nd_ps_desc, 0, MAX_DESC_LEN); - strncpy(getnode.nd_ps_desc, nd->nd_ps_desc, MAX_DESC_LEN); + strlcpy(getnode.nd_ps_desc, nd->nd_ps_desc, MAX_DESC_LEN); if (copy_to_user(uarg, &getnode, sizeof(struct digi_node))) return -EFAULT; diff --git a/drivers/staging/dgrp/dgrp_driver.c b/drivers/staging/dgrp/dgrp_driver.c index e456dc6cb36..b60a8da6350 100644 --- a/drivers/staging/dgrp/dgrp_driver.c +++ b/drivers/staging/dgrp/dgrp_driver.c @@ -23,7 +23,6 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/tty.h> -#include <linux/init.h> /* * PortServer includes @@ -52,19 +51,12 @@ MODULE_PARM_DESC(register_prdevices, "Turn on/off registering transparent print module_param_named(pollrate, dgrp_poll_tick, int, 0644); MODULE_PARM_DESC(pollrate, "Poll interval in ms"); -/* Driver load/unload functions */ -static int dgrp_init_module(void); -static void dgrp_cleanup_module(void); - -module_init(dgrp_init_module); -module_exit(dgrp_cleanup_module); - /* * init_module() * * Module load. This is where it all starts. */ -static int dgrp_init_module(void) +static int __init dgrp_init_module(void) { int ret; @@ -89,7 +81,7 @@ static int dgrp_init_module(void) /* * Module unload. This is where it all ends. */ -static void dgrp_cleanup_module(void) +static void __exit dgrp_cleanup_module(void) { struct nd_struct *nd, *next; @@ -108,3 +100,6 @@ static void dgrp_cleanup_module(void) kfree(nd); } } + +module_init(dgrp_init_module); +module_exit(dgrp_cleanup_module); diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 5b7833f593f..33ac7fb88cb 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -278,7 +278,7 @@ static void parity_scan(struct ch_struct *ch, unsigned char *cbuf, switch (ch->ch_pscan_state) { default: /* reset to sanity and fall through */ - ch->ch_pscan_state = 0 ; + ch->ch_pscan_state = 0; case 0: /* No FF seen yet */ @@ -1607,7 +1607,7 @@ static int dgrp_send(struct nd_struct *nd, long tmax) if ((ch->ch_pun.un_flag & UN_LOW) != 0 ? (n <= TBUF_LOW) : (ch->ch_pun.un_flag & UN_TIME) != 0 ? - ((jiffies - ch->ch_waketime) >= 0) : + time_is_before_jiffies(ch->ch_waketime) : (n == 0 && ch->ch_s_tpos == ch->ch_s_tin) && ((ch->ch_pun.un_flag & UN_EMPTY) != 0 || ((ch->ch_tun.un_open_count && @@ -3083,7 +3083,7 @@ check_query: nd->nd_hw_ver = (b[8] << 8) | b[9]; nd->nd_sw_ver = (b[10] << 8) | b[11]; nd->nd_hw_id = b[6]; - desclen = ((plen - 12) > MAX_DESC_LEN) ? MAX_DESC_LEN : + desclen = (plen - 12 > MAX_DESC_LEN - 1) ? MAX_DESC_LEN - 1 : plen - 12; if (desclen <= 0) { diff --git a/drivers/staging/dgrp/dgrp_sysfs.c b/drivers/staging/dgrp/dgrp_sysfs.c index 7d1b36d1e75..2f9345ff0ab 100644 --- a/drivers/staging/dgrp/dgrp_sysfs.c +++ b/drivers/staging/dgrp/dgrp_sysfs.c @@ -65,7 +65,9 @@ static ssize_t dgrp_class_pollrate_store(struct device *c, struct device_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "0x%x\n", &dgrp_poll_tick); + if (sscanf(buf, "0x%x\n", &dgrp_poll_tick) != 1) + return -EINVAL; + return count; } static DEVICE_ATTR(pollrate, 0600, dgrp_class_pollrate_show, @@ -157,7 +159,7 @@ static ssize_t dgrp_node_state_show(struct device *c, if (!c) return 0; - nd = (struct nd_struct *) dev_get_drvdata(c); + nd = dev_get_drvdata(c); if (!nd) return 0; @@ -174,7 +176,7 @@ static ssize_t dgrp_node_description_show(struct device *c, if (!c) return 0; - nd = (struct nd_struct *) dev_get_drvdata(c); + nd = dev_get_drvdata(c); if (!nd) return 0; @@ -192,7 +194,7 @@ static ssize_t dgrp_node_hw_version_show(struct device *c, if (!c) return 0; - nd = (struct nd_struct *) dev_get_drvdata(c); + nd = dev_get_drvdata(c); if (!nd) return 0; @@ -212,7 +214,7 @@ static ssize_t dgrp_node_hw_id_show(struct device *c, if (!c) return 0; - nd = (struct nd_struct *) dev_get_drvdata(c); + nd = dev_get_drvdata(c); if (!nd) return 0; @@ -232,7 +234,7 @@ static ssize_t dgrp_node_sw_version_show(struct device *c, if (!c) return 0; - nd = (struct nd_struct *) dev_get_drvdata(c); + nd = dev_get_drvdata(c); if (!nd) return 0; @@ -273,7 +275,7 @@ void dgrp_create_node_class_sysfs_files(struct nd_struct *nd) sprintf(name, "node%ld", nd->nd_major); nd->nd_class_dev = device_create(dgrp_class, dgrp_class_nodes_dev, - MKDEV(0, nd->nd_major), NULL, name); + MKDEV(0, nd->nd_major), NULL, "%s", name); ret = sysfs_create_group(&nd->nd_class_dev->kobj, &dgrp_node_attribute_group); @@ -311,7 +313,7 @@ static ssize_t dgrp_tty_state_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; @@ -328,7 +330,7 @@ static ssize_t dgrp_tty_baud_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -348,7 +350,7 @@ static ssize_t dgrp_tty_msignals_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -377,7 +379,7 @@ static ssize_t dgrp_tty_iflag_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -396,7 +398,7 @@ static ssize_t dgrp_tty_cflag_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -415,7 +417,7 @@ static ssize_t dgrp_tty_oflag_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -434,7 +436,7 @@ static ssize_t dgrp_tty_digi_flag_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -453,7 +455,7 @@ static ssize_t dgrp_tty_rxcount_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -472,7 +474,7 @@ static ssize_t dgrp_tty_txcount_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; @@ -493,7 +495,7 @@ static ssize_t dgrp_tty_name_show(struct device *d, if (!d) return 0; - un = (struct un_struct *) dev_get_drvdata(d); + un = dev_get_drvdata(d); if (!un) return 0; ch = un->un_ch; diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c index 654f6010b47..30d26029b21 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c @@ -371,7 +371,7 @@ static void drp_param(struct ch_struct *ch) ch->ch_flag |= CH_BAUD0; } } else if (ch->ch_custom_speed) { - ch->ch_brate = PORTSERVER_DIVIDEND / ch->ch_custom_speed ; + ch->ch_brate = PORTSERVER_DIVIDEND / ch->ch_custom_speed; if (ch->ch_flag & CH_BAUD0) { ch->ch_mout |= DM_DTR | DM_RTS; @@ -752,7 +752,7 @@ static int dgrp_tty_open(struct tty_struct *tty, struct file *file) if (ch->ch_open_error != 0 && otype == ch->ch_otype) { retval = (ch->ch_open_error <= 2) ? - delay_error : -ENXIO ; + delay_error : -ENXIO; goto unlock; } @@ -1120,7 +1120,9 @@ static void dgrp_tty_close(struct tty_struct *tty, struct file *file) if (!sent_printer_offstr) dgrp_tty_flush_buffer(tty); + spin_unlock_irqrestore(&nd->nd_lock, lock_flags); tty_ldisc_flush(tty); + spin_lock_irqsave(&nd->nd_lock, lock_flags); break; } @@ -1317,7 +1319,8 @@ static int dgrp_calculate_txprint_bounds(struct ch_struct *ch, int space, if (ch->ch_tun.un_open_count != 0 && ch->ch_tun.un_tty->ops->chars_in_buffer && - ((ch->ch_tun.un_tty->ops->chars_in_buffer)(ch->ch_tun.un_tty) != 0)) { + ((ch->ch_tun.un_tty->ops->chars_in_buffer) + (ch->ch_tun.un_tty) != 0)) { *un_flag = UN_PWAIT; return 0; } @@ -1499,7 +1502,8 @@ static int dgrp_tty_write(struct tty_struct *tty, */ if (ch->ch_tun.un_open_count != 0 && - ((ch->ch_tun.un_tty->ops->chars_in_buffer)(ch->ch_tun.un_tty) != 0)) { + ((ch->ch_tun.un_tty->ops->chars_in_buffer) + (ch->ch_tun.un_tty) != 0)) { un->un_flag |= UN_PWAIT; count = 0; goto out; @@ -1664,7 +1668,8 @@ static int dgrp_tty_write(struct tty_struct *tty, if (n >= t) { memcpy(ch->ch_tbuf + ch->ch_tin, buf, t); - if (nd->nd_dpa_debug && nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(un->un_tty)))) + if (nd->nd_dpa_debug && nd->nd_dpa_port == + PORT_NUM(MINOR(tty_devnum(un->un_tty)))) dgrp_dpa_data(nd, 0, (char *) buf, t); buf += t; n -= t; @@ -1673,7 +1678,8 @@ static int dgrp_tty_write(struct tty_struct *tty, } memcpy(ch->ch_tbuf + ch->ch_tin, buf, n); - if (nd->nd_dpa_debug && nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(un->un_tty)))) + if (nd->nd_dpa_debug && nd->nd_dpa_port == + PORT_NUM(MINOR(tty_devnum(un->un_tty)))) dgrp_dpa_data(nd, 0, (char *) buf, n); buf += n; ch->ch_tin += n; @@ -2654,7 +2660,8 @@ static int dgrp_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ch->ch_send |= RR_RX_FLUSH; (ch->ch_nd)->nd_tx_work = 1; (ch->ch_nd)->nd_tx_ready = 1; - wake_up_interruptible(&(ch->ch_nd)->nd_tx_waitq); + wake_up_interruptible( + &(ch->ch_nd)->nd_tx_waitq); } if (arg == TCIFLUSH) break; @@ -2680,7 +2687,8 @@ static int dgrp_tty_ioctl(struct tty_struct *tty, unsigned int cmd, Linux HPUX Function TCSETA TCSETA - set the termios TCSETAF TCSETAF - wait for drain first, then set termios - TCSETAW TCSETAW - wait for drain, flush the input queue, then set termios + TCSETAW TCSETAW - wait for drain, + flush the input queue, then set termios - looking at the tty_ioctl code, these command all call our tty_set_termios at the driver's end, when a TCSETA* is sent, it is expecting the tty to have a termio structure, @@ -2796,6 +2804,7 @@ static int dgrp_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } /* pretend we didn't recognize this */ + /* fall-through */ case DIGI_SETA: return dgrp_tty_digiseta(tty, (struct digi_struct *) arg); @@ -3205,7 +3214,8 @@ dgrp_tty_init(struct nd_struct *nd) int max_majors = 1U << (32 - MINORBITS); for (i = 256; i < max_majors; i++) { nd->nd_serial_ttdriver->major = i; - rc = tty_register_driver(nd->nd_serial_ttdriver); + rc = tty_register_driver + (nd->nd_serial_ttdriver); if (rc >= 0) break; } diff --git a/drivers/staging/dgrp/drp.h b/drivers/staging/dgrp/drp.h index 84a1e7be489..4024b488eba 100644 --- a/drivers/staging/dgrp/drp.h +++ b/drivers/staging/dgrp/drp.h @@ -674,7 +674,7 @@ struct nd_struct { ushort nd_hw_ver; /* HW version returned from PS */ ushort nd_sw_ver; /* SW version returned from PS */ uint nd_hw_id; /* HW ID returned from PS */ - u8 nd_ps_desc[MAX_DESC_LEN+1]; /* Description from PS */ + u8 nd_ps_desc[MAX_DESC_LEN]; /* Description from PS */ uint nd_vpd_len; /* VPD len, if any */ u8 nd_vpd[VPDSIZE]; /* VPD, if any */ |
