diff options
Diffstat (limited to 'drivers/staging/dgrp')
| -rw-r--r-- | drivers/staging/dgrp/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_common.c | 31 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_common.h | 67 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_dpa_ops.c | 32 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_driver.c | 21 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_mon_ops.c | 26 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_net_ops.c | 51 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_ports_ops.c | 18 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_specproc.c | 466 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_sysfs.c | 66 | ||||
| -rw-r--r-- | drivers/staging/dgrp/dgrp_tty.c | 29 | ||||
| -rw-r--r-- | drivers/staging/dgrp/drp.h | 2 |
12 files changed, 194 insertions, 617 deletions
diff --git a/drivers/staging/dgrp/Kconfig b/drivers/staging/dgrp/Kconfig index 39f4bb65ec8..e4c41552923 100644 --- a/drivers/staging/dgrp/Kconfig +++ b/drivers/staging/dgrp/Kconfig @@ -1,7 +1,7 @@ config DGRP tristate "Digi Realport driver" default n - depends on SYSFS + depends on SYSFS && TTY ---help--- Support for Digi Realport devices. These devices allow you to access remote serial ports as if they are local tty devices. This diff --git a/drivers/staging/dgrp/dgrp_common.c b/drivers/staging/dgrp/dgrp_common.c index 3553998b72b..9a9b45624ba 100644 --- a/drivers/staging/dgrp/dgrp_common.c +++ b/drivers/staging/dgrp/dgrp_common.c @@ -167,34 +167,3 @@ void dgrp_carrier(struct ch_struct *ch) ch->ch_flag &= ~CH_PHYS_CD; } - -/** - * dgrp_chk_perm() -- check permissions for net device - * @inode: pointer to inode structure for the net communication device - * @op: operation to be tested - * - * The file permissions and ownerships are tested to determine whether - * the operation "op" is permitted on the file pointed to by the inode. - * Returns 0 if the operation is permitted, -EACCESS otherwise - */ -int dgrp_chk_perm(int mode, int op) -{ - if (!uid_eq(GLOBAL_ROOT_UID, current_euid())) - mode >>= 6; - else if (in_egroup_p(GLOBAL_ROOT_GID)) - mode >>= 3; - - if ((mode & op & 0007) == op) - return 0; - - if (capable(CAP_SYS_ADMIN)) - return 0; - - return -EACCES; -} - -/* dgrp_chk_perm wrapper for permission call in struct inode_operations */ -int dgrp_inode_permission(struct inode *inode, int op) -{ - return dgrp_chk_perm(inode->i_mode, op); -} diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h index 0583fe9c7b0..23aba6c4d22 100644 --- a/drivers/staging/dgrp/dgrp_common.h +++ b/drivers/staging/dgrp/dgrp_common.h @@ -49,24 +49,24 @@ extern struct dgrp_poll_data dgrp_poll_data; extern void dgrp_poll_handler(unsigned long arg); /* from dgrp_mon_ops.c */ -extern void dgrp_register_mon_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_mon_ops; /* from dgrp_tty.c */ extern int dgrp_tty_init(struct nd_struct *nd); extern void dgrp_tty_uninit(struct nd_struct *nd); /* from dgrp_ports_ops.c */ -extern void dgrp_register_ports_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_ports_ops; /* from dgrp_net_ops.c */ -extern void dgrp_register_net_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_net_ops; /* from dgrp_dpa_ops.c */ -extern void dgrp_register_dpa_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_dpa_ops; extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int); /* from dgrp_sysfs.c */ -extern void dgrp_create_class_sysfs_files(void); +extern int dgrp_create_class_sysfs_files(void); extern void dgrp_remove_class_sysfs_files(void); extern void dgrp_create_node_class_sysfs_files(struct nd_struct *nd); @@ -76,61 +76,6 @@ extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c); extern void dgrp_remove_tty_sysfs(struct device *c); /* from dgrp_specproc.c */ -/* - * The list of DGRP entries with r/w capabilities. These - * magic numbers are used for identification purposes. - */ -enum { - DGRP_CONFIG = 1, /* Configure portservers */ - DGRP_NETDIR = 2, /* Directory for "net" devices */ - DGRP_MONDIR = 3, /* Directory for "mon" devices */ - DGRP_PORTSDIR = 4, /* Directory for "ports" devices */ - DGRP_INFO = 5, /* Get info. about the running module */ - DGRP_NODEINFO = 6, /* Get info. about the configured nodes */ - DGRP_DPADIR = 7, /* Directory for the "dpa" devices */ -}; - -/* - * Directions for proc handlers - */ -enum { - INBOUND = 1, /* Data being written to kernel */ - OUTBOUND = 2, /* Data being read from the kernel */ -}; - -/** - * dgrp_proc_entry: structure for dgrp proc dirs - * @id: ID number associated with this particular entry. Should be - * unique across all of DGRP. - * @name: text name associated with the /proc entry - * @mode: file access permisssions for the /proc entry - * @child: pointer to table describing a subdirectory for this entry - * @de: pointer to directory entry for this object once registered. Used - * to grab the handle of the object for unregistration - * @excl_sem: semaphore to provide exclusive to struct - * @excl_cnt: counter of current accesses - * - * Each entry in a DGRP proc directory is described with a - * dgrp_proc_entry structure. A collection of these - * entries (in an array) represents the members associated - * with a particular /proc directory, and is referred to - * as a table. All tables are terminated by an entry with - * zeros for every member. - */ -struct dgrp_proc_entry { - int id; /* Integer identifier */ - const char *name; /* ASCII identifier */ - mode_t mode; /* File access permissions */ - struct dgrp_proc_entry *child; /* Child pointer */ - - /* file ops to use, pass NULL to use default */ - struct file_operations *proc_file_ops; - - struct proc_dir_entry *de; /* proc entry pointer */ - struct semaphore excl_sem; /* Protects exclusive access var */ - int excl_cnt; /* Counts number of curr accesses */ -}; - extern void dgrp_unregister_proc(void); extern void dgrp_register_proc(void); @@ -144,8 +89,6 @@ extern void dgrp_register_proc(void); *-----------------------------------------------------------------------*/ void dgrp_carrier(struct ch_struct *ch); -extern int dgrp_inode_permission(struct inode *inode, int op); -extern int dgrp_chk_perm(int mode, int op); /* diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index 021cca498f2..69bfe309376 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -40,6 +40,7 @@ #include <linux/cred.h> #include <linux/sched.h> #include <linux/ratelimit.h> +#include <linux/slab.h> #include <asm/unaligned.h> #include "dgrp_common.h" @@ -52,7 +53,7 @@ static long dgrp_dpa_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static unsigned int dgrp_dpa_select(struct file *, struct poll_table_struct *); -static const struct file_operations dpa_ops = { +const struct file_operations dgrp_dpa_ops = { .owner = THIS_MODULE, .read = dgrp_dpa_read, .poll = dgrp_dpa_select, @@ -61,12 +62,6 @@ static const struct file_operations dpa_ops = { .release = dgrp_dpa_release, }; -static struct inode_operations dpa_inode_ops = { - .permission = dgrp_inode_permission -}; - - - struct digi_node { uint nd_state; /* Node state: 1 = up, 0 = down. */ uint nd_chan_count; /* Number of channels found */ @@ -111,17 +106,6 @@ struct digi_debug { #define DIGI_SETDEBUG (('d'<<8) | 247) /* set debug info */ -void dgrp_register_dpa_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &dpa_inode_ops; - de->proc_fops = &dpa_ops; - - node->nd_dpa_de = de; - spin_lock_init(&node->nd_dpa_lock); -} - /* * dgrp_dpa_open -- open the DPA device for a particular PortServer */ @@ -130,8 +114,6 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file) struct nd_struct *nd; int rtn = 0; - struct proc_dir_entry *de; - rtn = try_module_get(THIS_MODULE); if (!rtn) return -ENXIO; @@ -154,12 +136,7 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - nd = (struct nd_struct *)de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; @@ -415,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; @@ -432,6 +409,7 @@ static long dgrp_dpa_ioctl(struct file *file, unsigned int cmd, case DIGI_GETVPD: + memset(&vpd, 0, sizeof(vpd)); if (nd->nd_vpd_len > 0) { vpd.vpd_len = nd->nd_vpd_len; memcpy(&vpd.vpd_data, &nd->nd_vpd, nd->nd_vpd_len); diff --git a/drivers/staging/dgrp/dgrp_driver.c b/drivers/staging/dgrp/dgrp_driver.c index aa262588e9b..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,20 +51,15 @@ 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; + INIT_LIST_HEAD(&nd_struct_list); spin_lock_init(&dgrp_poll_data.poll_lock); @@ -74,7 +68,9 @@ static int dgrp_init_module(void) dgrp_poll_data.timer.function = dgrp_poll_handler; dgrp_poll_data.timer.data = (unsigned long) &dgrp_poll_data; - dgrp_create_class_sysfs_files(); + ret = dgrp_create_class_sysfs_files(); + if (ret) + return ret; dgrp_register_proc(); @@ -85,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; @@ -104,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_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c index 4792d056a36..d18be4180e3 100644 --- a/drivers/staging/dgrp/dgrp_mon_ops.c +++ b/drivers/staging/dgrp/dgrp_mon_ops.c @@ -37,6 +37,7 @@ #include <linux/tty.h> #include <linux/sched.h> #include <asm/unaligned.h> +#include <linux/slab.h> #include <linux/proc_fs.h> #include <linux/uaccess.h> @@ -49,7 +50,7 @@ static ssize_t dgrp_mon_read(struct file *, char __user *, size_t, loff_t *); static long dgrp_mon_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -static const struct file_operations mon_ops = { +const struct file_operations dgrp_mon_ops = { .owner = THIS_MODULE, .read = dgrp_mon_read, .unlocked_ioctl = dgrp_mon_ioctl, @@ -57,20 +58,6 @@ static const struct file_operations mon_ops = { .release = dgrp_mon_release, }; -static struct inode_operations mon_inode_ops = { - .permission = dgrp_inode_permission -}; - -void dgrp_register_mon_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &mon_inode_ops; - de->proc_fops = &mon_ops; - node->nd_mon_de = de; - sema_init(&node->nd_mon_semaphore, 1); -} - /** * dgrp_mon_open() -- open /proc/dgrp/ports device for a PortServer * @inode: struct inode * @@ -81,7 +68,6 @@ void dgrp_register_mon_hook(struct proc_dir_entry *de) static int dgrp_mon_open(struct inode *inode, struct file *file) { struct nd_struct *nd; - struct proc_dir_entry *de; struct timeval tv; uint32_t time; u8 *buf; @@ -109,13 +95,7 @@ static int dgrp_mon_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - - nd = (struct nd_struct *)de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 2d1bbfd5b67..33ac7fb88cb 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -35,8 +35,9 @@ #include <linux/module.h> #include <linux/proc_fs.h> -#include <linux/types.h> +#include <linux/slab.h> #include <linux/string.h> +#include <linux/device.h> #include <linux/tty.h> #include <linux/tty_flip.h> #include <linux/spinlock.h> @@ -71,7 +72,7 @@ static long dgrp_net_ioctl(struct file *file, unsigned int cmd, static unsigned int dgrp_net_select(struct file *file, struct poll_table_struct *table); -static const struct file_operations net_ops = { +const struct file_operations dgrp_net_ops = { .owner = THIS_MODULE, .read = dgrp_net_read, .write = dgrp_net_write, @@ -81,23 +82,6 @@ static const struct file_operations net_ops = { .release = dgrp_net_release, }; -static struct inode_operations net_inode_ops = { - .permission = dgrp_inode_permission -}; - -void dgrp_register_net_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &net_inode_ops; - de->proc_fops = &net_ops; - node->nd_net_de = de; - sema_init(&node->nd_net_semaphore, 1); - node->nd_state = NS_CLOSED; - dgrp_create_node_class_sysfs_files(node); -} - - /** * dgrp_dump() -- prints memory for debugging purposes. * @mem: Memory location which should be printed to the console @@ -211,7 +195,7 @@ static void dgrp_input(struct ch_struct *ch) data_len = (ch->ch_rin - ch->ch_rout) & RBUF_MASK; /* len is the amount of data we are going to transfer here */ - len = tty_buffer_request_room(tty, data_len); + len = tty_buffer_request_room(&ch->port, data_len); /* Check DPA flow control */ if ((nd->nd_dpa_debug) && @@ -232,9 +216,9 @@ static void dgrp_input(struct ch_struct *ch) (nd->nd_dpa_port == PORT_NUM(MINOR(tty_devnum(tty))))) dgrp_dpa_data(nd, 1, myflipbuf, len); - tty_insert_flip_string_flags(tty, myflipbuf, + tty_insert_flip_string_flags(&ch->port, myflipbuf, myflipflagbuf, len); - tty_flip_buffer_push(tty); + tty_flip_buffer_push(&ch->port); ch->ch_rxcount += len; } @@ -294,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 */ @@ -800,7 +784,6 @@ out_err: static int dgrp_net_open(struct inode *inode, struct file *file) { struct nd_struct *nd; - struct proc_dir_entry *de; ulong lock_flags; int rtn; @@ -824,13 +807,7 @@ static int dgrp_net_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - - nd = (struct nd_struct *) de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; @@ -1630,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 && @@ -2956,9 +2933,9 @@ check_query: I_BRKINT(ch->ch_tun.un_tty) && !(I_IGNBRK(ch->ch_tun.un_tty))) { - tty_buffer_request_room(ch->ch_tun.un_tty, 1); - tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); - tty_flip_buffer_push(ch->ch_tun.un_tty); + tty_buffer_request_room(&ch->port, 1); + tty_insert_flip_char(&ch->port, 0, TTY_BREAK); + tty_flip_buffer_push(&ch->port); } @@ -3106,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) { @@ -3404,7 +3381,7 @@ static long dgrp_net_ioctl(struct file *file, unsigned int cmd, if (size != sizeof(struct link_struct)) return -EINVAL; - if (copy_from_user((void *)(&link), (void __user *) arg, size)) + if (copy_from_user(&link, (void __user *)arg, size)) return -EFAULT; if (link.lk_fast_rate < 9600) diff --git a/drivers/staging/dgrp/dgrp_ports_ops.c b/drivers/staging/dgrp/dgrp_ports_ops.c index cd1fc208862..4ce030815f2 100644 --- a/drivers/staging/dgrp/dgrp_ports_ops.c +++ b/drivers/staging/dgrp/dgrp_ports_ops.c @@ -47,7 +47,7 @@ /* File operation declarations */ static int dgrp_ports_open(struct inode *, struct file *); -static const struct file_operations ports_ops = { +const struct file_operations dgrp_ports_ops = { .owner = THIS_MODULE, .open = dgrp_ports_open, .read = seq_read, @@ -55,20 +55,6 @@ static const struct file_operations ports_ops = { .release = seq_release }; -static struct inode_operations ports_inode_ops = { - .permission = dgrp_inode_permission -}; - - -void dgrp_register_ports_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &ports_inode_ops; - de->proc_fops = &ports_ops; - node->nd_ports_de = de; -} - static void *dgrp_ports_seq_start(struct seq_file *seq, loff_t *pos) { if (*pos == 0) @@ -163,7 +149,7 @@ static int dgrp_ports_open(struct inode *inode, struct file *file) rtn = seq_open(file, &ports_seq_ops); if (!rtn) { seq = file->private_data; - seq->private = PDE(inode)->data; + seq->private = PDE_DATA(inode); } return rtn; diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index c214078a89e..205d80ef445 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -37,6 +37,7 @@ #include <linux/sched.h> #include <linux/cred.h> #include <linux/proc_fs.h> +#include <linux/slab.h> #include <linux/ctype.h> #include <linux/seq_file.h> #include <linux/uaccess.h> @@ -44,155 +45,91 @@ #include "dgrp_common.h" -static struct dgrp_proc_entry dgrp_table[]; static struct proc_dir_entry *dgrp_proc_dir_entry; static int dgrp_add_id(long id); static int dgrp_remove_nd(struct nd_struct *nd); -static void unregister_dgrp_device(struct proc_dir_entry *de); -static void register_dgrp_device(struct nd_struct *node, +static struct proc_dir_entry *add_proc_file(struct nd_struct *node, struct proc_dir_entry *root, - void (*register_hook)(struct proc_dir_entry *de)); + const struct file_operations *fops); /* File operation declarations */ -static int dgrp_gen_proc_open(struct inode *, struct file *); -static int dgrp_gen_proc_close(struct inode *, struct file *); static int parse_write_config(char *); +static ssize_t dgrp_config_proc_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *pos); -static const struct file_operations dgrp_proc_file_ops = { - .owner = THIS_MODULE, - .open = dgrp_gen_proc_open, - .release = dgrp_gen_proc_close, -}; - -static struct inode_operations proc_inode_ops = { - .permission = dgrp_inode_permission -}; - - -static void register_proc_table(struct dgrp_proc_entry *, - struct proc_dir_entry *); -static void unregister_proc_table(struct dgrp_proc_entry *, - struct proc_dir_entry *); - -static struct dgrp_proc_entry dgrp_net_table[]; -static struct dgrp_proc_entry dgrp_mon_table[]; -static struct dgrp_proc_entry dgrp_ports_table[]; -static struct dgrp_proc_entry dgrp_dpa_table[]; - -static ssize_t config_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos); +static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file); +static int dgrp_info_proc_open(struct inode *inode, struct file *file); +static int dgrp_config_proc_open(struct inode *inode, struct file *file); -static int nodeinfo_proc_open(struct inode *inode, struct file *file); -static int info_proc_open(struct inode *inode, struct file *file); -static int config_proc_open(struct inode *inode, struct file *file); - -static struct file_operations config_proc_file_ops = { +static const struct file_operations config_proc_file_ops = { .owner = THIS_MODULE, - .open = config_proc_open, + .open = dgrp_config_proc_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .write = config_proc_write + .write = dgrp_config_proc_write, }; -static struct file_operations info_proc_file_ops = { +static const struct file_operations info_proc_file_ops = { .owner = THIS_MODULE, - .open = info_proc_open, + .open = dgrp_info_proc_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = single_release, }; -static struct file_operations nodeinfo_proc_file_ops = { +static const struct file_operations nodeinfo_proc_file_ops = { .owner = THIS_MODULE, - .open = nodeinfo_proc_open, + .open = dgrp_nodeinfo_proc_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; -static struct dgrp_proc_entry dgrp_table[] = { - { - .id = DGRP_CONFIG, - .name = "config", - .mode = 0644, - .proc_file_ops = &config_proc_file_ops, - }, - { - .id = DGRP_INFO, - .name = "info", - .mode = 0644, - .proc_file_ops = &info_proc_file_ops, - }, - { - .id = DGRP_NODEINFO, - .name = "nodeinfo", - .mode = 0644, - .proc_file_ops = &nodeinfo_proc_file_ops, - }, - { - .id = DGRP_NETDIR, - .name = "net", - .mode = 0500, - .child = dgrp_net_table - }, - { - .id = DGRP_MONDIR, - .name = "mon", - .mode = 0500, - .child = dgrp_mon_table - }, - { - .id = DGRP_PORTSDIR, - .name = "ports", - .mode = 0500, - .child = dgrp_ports_table - }, - { - .id = DGRP_DPADIR, - .name = "dpa", - .mode = 0500, - .child = dgrp_dpa_table - } -}; - static struct proc_dir_entry *net_entry_pointer; static struct proc_dir_entry *mon_entry_pointer; static struct proc_dir_entry *dpa_entry_pointer; static struct proc_dir_entry *ports_entry_pointer; -static struct dgrp_proc_entry dgrp_net_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_mon_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_ports_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_dpa_table[] = { - {0} -}; +static void remove_files(struct nd_struct *nd) +{ + char buf[3]; + ID_TO_CHAR(nd->nd_ID, buf); + dgrp_remove_node_class_sysfs_files(nd); + if (nd->nd_net_de) + remove_proc_entry(buf, net_entry_pointer); + if (nd->nd_mon_de) + remove_proc_entry(buf, mon_entry_pointer); + if (nd->nd_dpa_de) + remove_proc_entry(buf, dpa_entry_pointer); + if (nd->nd_ports_de) + remove_proc_entry(buf, ports_entry_pointer); +} void dgrp_unregister_proc(void) { - unregister_proc_table(dgrp_table, dgrp_proc_dir_entry); net_entry_pointer = NULL; mon_entry_pointer = NULL; dpa_entry_pointer = NULL; ports_entry_pointer = NULL; if (dgrp_proc_dir_entry) { - remove_proc_entry(dgrp_proc_dir_entry->name, - dgrp_proc_dir_entry->parent); + struct nd_struct *nd; + list_for_each_entry(nd, &nd_struct_list, list) + remove_files(nd); + remove_proc_entry("dgrp/config", NULL); + remove_proc_entry("dgrp/info", NULL); + remove_proc_entry("dgrp/nodeinfo", NULL); + remove_proc_entry("dgrp/net", NULL); + remove_proc_entry("dgrp/mon", NULL); + remove_proc_entry("dgrp/dpa", NULL); + remove_proc_entry("dgrp/ports", NULL); + remove_proc_entry("dgrp", NULL); dgrp_proc_dir_entry = NULL; } - } void dgrp_register_proc(void) @@ -200,224 +137,33 @@ void dgrp_register_proc(void) /* * Register /proc/dgrp */ - dgrp_proc_dir_entry = proc_create("dgrp", S_IFDIR, NULL, - &dgrp_proc_file_ops); - register_proc_table(dgrp_table, dgrp_proc_dir_entry); -} - -/* - * /proc/sys support - */ -static int dgrp_proc_match(int len, const char *name, struct proc_dir_entry *de) -{ - if (!de || !de->low_ino) - return 0; - if (de->namelen != len) - return 0; - return !memcmp(name, de->name, len); -} - - -/* - * Scan the entries in table and add them all to /proc at the position - * referred to by "root" - */ -static void register_proc_table(struct dgrp_proc_entry *table, - struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - int len; - mode_t mode; - - if (table == NULL) + dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); + if (!dgrp_proc_dir_entry) return; - - for (; table->id; table++) { - /* Can't do anything without a proc name. */ - if (!table->name) - continue; - - /* Maybe we can't do anything with it... */ - if (!table->proc_file_ops && - !table->child) { - pr_warn("dgrp: Can't register %s\n", - table->name); - continue; - } - - len = strlen(table->name); - mode = table->mode; - - de = NULL; - if (!table->child) - mode |= S_IFREG; - else { - mode |= S_IFDIR; - for (de = root->subdir; de; de = de->next) { - if (dgrp_proc_match(len, table->name, de)) - break; - } - /* If the subdir exists already, de is non-NULL */ - } - - if (!de) { - de = create_proc_entry(table->name, mode, root); - if (!de) - continue; - de->data = (void *) table; - if (!table->child) { - de->proc_iops = &proc_inode_ops; - if (table->proc_file_ops) - de->proc_fops = table->proc_file_ops; - else - de->proc_fops = &dgrp_proc_file_ops; - } - } - table->de = de; - if (de->mode & S_IFDIR) - register_proc_table(table->child, de); - - if (table->id == DGRP_NETDIR) - net_entry_pointer = de; - - if (table->id == DGRP_MONDIR) - mon_entry_pointer = de; - - if (table->id == DGRP_DPADIR) - dpa_entry_pointer = de; - - if (table->id == DGRP_PORTSDIR) - ports_entry_pointer = de; - } + proc_create("dgrp/config", 0644, NULL, &config_proc_file_ops); + proc_create("dgrp/info", 0644, NULL, &info_proc_file_ops); + proc_create("dgrp/nodeinfo", 0644, NULL, &nodeinfo_proc_file_ops); + net_entry_pointer = proc_mkdir_mode("dgrp/net", 0500, NULL); + mon_entry_pointer = proc_mkdir_mode("dgrp/mon", 0500, NULL); + dpa_entry_pointer = proc_mkdir_mode("dgrp/dpa", 0500, NULL); + ports_entry_pointer = proc_mkdir_mode("dgrp/ports", 0500, NULL); } -/* - * Unregister a /proc sysctl table and any subdirectories. - */ -static void unregister_proc_table(struct dgrp_proc_entry *table, - struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - struct nd_struct *tmp; - - if (table == NULL) - return; - - list_for_each_entry(tmp, &nd_struct_list, list) { - if ((table == dgrp_net_table) && (tmp->nd_net_de)) { - unregister_dgrp_device(tmp->nd_net_de); - dgrp_remove_node_class_sysfs_files(tmp); - } - - if ((table == dgrp_mon_table) && (tmp->nd_mon_de)) - unregister_dgrp_device(tmp->nd_mon_de); - - if ((table == dgrp_dpa_table) && (tmp->nd_dpa_de)) - unregister_dgrp_device(tmp->nd_dpa_de); - - if ((table == dgrp_ports_table) && (tmp->nd_ports_de)) - unregister_dgrp_device(tmp->nd_ports_de); - } - - for (; table->id; table++) { - de = table->de; - - if (!de) - continue; - if (de->mode & S_IFDIR) { - if (!table->child) { - pr_alert("dgrp: malformed sysctl tree on free\n"); - continue; - } - unregister_proc_table(table->child, de); - - /* Don't unregister directories which still have entries */ - if (de->subdir) - continue; - } - - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - pr_alert("proc entry %s in use, not removing\n", - de->name); - continue; - } - - remove_proc_entry(de->name, de->parent); - table->de = NULL; - } -} - -static int dgrp_gen_proc_open(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgrp_proc_entry *entry; - int ret = 0; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) { - ret = -ENXIO; - goto done; - } - - entry = (struct dgrp_proc_entry *) de->data; - if (!entry) { - ret = -ENXIO; - goto done; - } - - down(&entry->excl_sem); - - if (entry->excl_cnt) - ret = -EBUSY; - else - entry->excl_cnt++; - - up(&entry->excl_sem); - -done: - return ret; -} - -static int dgrp_gen_proc_close(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgrp_proc_entry *entry; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - goto done; - - entry = (struct dgrp_proc_entry *) de->data; - if (!entry) - goto done; - - down(&entry->excl_sem); - - if (entry->excl_cnt) - entry->excl_cnt = 0; - - up(&entry->excl_sem); - -done: - return 0; -} - -static void *config_proc_start(struct seq_file *m, loff_t *pos) +static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos) { return seq_list_start_head(&nd_struct_list, *pos); } -static void *config_proc_next(struct seq_file *p, void *v, loff_t *pos) +static void *dgrp_config_proc_next(struct seq_file *p, void *v, loff_t *pos) { return seq_list_next(v, &nd_struct_list, pos); } -static void config_proc_stop(struct seq_file *m, void *v) +static void dgrp_config_proc_stop(struct seq_file *m, void *v) { } -static int config_proc_show(struct seq_file *m, void *v) +static int dgrp_config_proc_show(struct seq_file *m, void *v) { struct nd_struct *nd; char tmp_id[4]; @@ -443,13 +189,13 @@ static int config_proc_show(struct seq_file *m, void *v) } static const struct seq_operations proc_config_ops = { - .start = config_proc_start, - .next = config_proc_next, - .stop = config_proc_stop, - .show = config_proc_show + .start = dgrp_config_proc_start, + .next = dgrp_config_proc_next, + .stop = dgrp_config_proc_stop, + .show = dgrp_config_proc_show, }; -static int config_proc_open(struct inode *inode, struct file *file) +static int dgrp_config_proc_open(struct inode *inode, struct file *file) { return seq_open(file, &proc_config_ops); } @@ -460,8 +206,9 @@ static int config_proc_open(struct inode *inode, struct file *file) * write) is treated as an independent request. See the "parse" * description for more details. */ -static ssize_t config_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) +static ssize_t dgrp_config_proc_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *pos) { ssize_t retval; char *inbuf, *sp; @@ -625,7 +372,7 @@ static int parse_write_config(char *buf) return retval; } -static int info_proc_show(struct seq_file *m, void *v) +static int dgrp_info_proc_show(struct seq_file *m, void *v) { seq_printf(m, "version: %s\n", DIGI_VERSION); seq_puts(m, "register_with_sysfs: 1\n"); @@ -635,27 +382,27 @@ static int info_proc_show(struct seq_file *m, void *v) return 0; } -static int info_proc_open(struct inode *inode, struct file *file) +static int dgrp_info_proc_open(struct inode *inode, struct file *file) { - return single_open(file, info_proc_show, NULL); + return single_open(file, dgrp_info_proc_show, NULL); } -static void *nodeinfo_start(struct seq_file *m, loff_t *pos) +static void *dgrp_nodeinfo_start(struct seq_file *m, loff_t *pos) { return seq_list_start_head(&nd_struct_list, *pos); } -static void *nodeinfo_next(struct seq_file *p, void *v, loff_t *pos) +static void *dgrp_nodeinfo_next(struct seq_file *p, void *v, loff_t *pos) { return seq_list_next(v, &nd_struct_list, pos); } -static void nodeinfo_stop(struct seq_file *m, void *v) +static void dgrp_nodeinfo_stop(struct seq_file *m, void *v) { } -static int nodeinfo_show(struct seq_file *m, void *v) +static int dgrp_nodeinfo_show(struct seq_file *m, void *v) { struct nd_struct *nd; char hwver[8]; @@ -697,13 +444,13 @@ static int nodeinfo_show(struct seq_file *m, void *v) static const struct seq_operations nodeinfo_ops = { - .start = nodeinfo_start, - .next = nodeinfo_next, - .stop = nodeinfo_stop, - .show = nodeinfo_show + .start = dgrp_nodeinfo_start, + .next = dgrp_nodeinfo_next, + .stop = dgrp_nodeinfo_stop, + .show = dgrp_nodeinfo_show, }; -static int nodeinfo_proc_open(struct inode *inode, struct file *file) +static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file) { return seq_open(file, &nodeinfo_ops); } @@ -730,6 +477,10 @@ static int dgrp_add_id(long id) init_waitqueue_head(&nd->nd_tx_waitq); init_waitqueue_head(&nd->nd_mon_wqueue); init_waitqueue_head(&nd->nd_dpa_wqueue); + sema_init(&nd->nd_mon_semaphore, 1); + sema_init(&nd->nd_net_semaphore, 1); + spin_lock_init(&nd->nd_dpa_lock); + nd->nd_state = NS_CLOSED; for (i = 0; i < SEQ_MAX; i++) init_waitqueue_head(&nd->nd_seq_wque[i]); @@ -744,12 +495,12 @@ static int dgrp_add_id(long id) if (ret) goto error_out; - register_dgrp_device(nd, net_entry_pointer, dgrp_register_net_hook); - register_dgrp_device(nd, mon_entry_pointer, dgrp_register_mon_hook); - register_dgrp_device(nd, dpa_entry_pointer, dgrp_register_dpa_hook); - register_dgrp_device(nd, ports_entry_pointer, - dgrp_register_ports_hook); - + dgrp_create_node_class_sysfs_files(nd); + nd->nd_net_de = add_proc_file(nd, net_entry_pointer, &dgrp_net_ops); + nd->nd_mon_de = add_proc_file(nd, mon_entry_pointer, &dgrp_mon_ops); + nd->nd_dpa_de = add_proc_file(nd, dpa_entry_pointer, &dgrp_dpa_ops); + nd->nd_ports_de = add_proc_file(nd, ports_entry_pointer, + &dgrp_ports_ops); return 0; /* FIXME this guy should free the tty driver stored in nd and destroy @@ -768,19 +519,7 @@ static int dgrp_remove_nd(struct nd_struct *nd) if (nd->nd_tty_ref_cnt) return -EBUSY; - if (nd->nd_net_de) { - unregister_dgrp_device(nd->nd_net_de); - dgrp_remove_node_class_sysfs_files(nd); - } - - if (nd->nd_mon_de) - unregister_dgrp_device(nd->nd_mon_de); - - if (nd->nd_ports_de) - unregister_dgrp_device(nd->nd_ports_de); - - if (nd->nd_dpa_de) - unregister_dgrp_device(nd->nd_dpa_de); + remove_files(nd); dgrp_tty_uninit(nd); @@ -792,38 +531,11 @@ static int dgrp_remove_nd(struct nd_struct *nd) return 0; } -static void register_dgrp_device(struct nd_struct *node, +static struct proc_dir_entry *add_proc_file(struct nd_struct *node, struct proc_dir_entry *root, - void (*register_hook)(struct proc_dir_entry *de)) + const struct file_operations *fops) { char buf[3]; - struct proc_dir_entry *de; - ID_TO_CHAR(node->nd_ID, buf); - - de = create_proc_entry(buf, 0600 | S_IFREG, root); - if (!de) - return; - - de->data = (void *) node; - - if (register_hook) - register_hook(de); - -} - -static void unregister_dgrp_device(struct proc_dir_entry *de) -{ - if (!de) - return; - - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - pr_alert("%s - proc entry %s in use. Not removing.\n", - __func__, de->name); - return; - } - - remove_proc_entry(de->name, de->parent); - de = NULL; + return proc_create_data(buf, 0600, root, fops, node); } diff --git a/drivers/staging/dgrp/dgrp_sysfs.c b/drivers/staging/dgrp/dgrp_sysfs.c index be179adfb7c..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, @@ -85,30 +87,50 @@ static struct attribute_group dgrp_global_settings_attribute_group = { -void dgrp_create_class_sysfs_files(void) +int dgrp_create_class_sysfs_files(void) { int ret = 0; int max_majors = 1U << (32 - MINORBITS); dgrp_class = class_create(THIS_MODULE, "digi_realport"); + if (IS_ERR(dgrp_class)) + return PTR_ERR(dgrp_class); ret = class_create_file(dgrp_class, &class_attr_driver_version); + if (ret) + goto err_class; dgrp_class_global_settings_dev = device_create(dgrp_class, NULL, MKDEV(0, max_majors + 1), NULL, "driver_settings"); - + if (IS_ERR(dgrp_class_global_settings_dev)) { + ret = PTR_ERR(dgrp_class_global_settings_dev); + goto err_file; + } ret = sysfs_create_group(&dgrp_class_global_settings_dev->kobj, &dgrp_global_settings_attribute_group); if (ret) { pr_alert("%s: failed to create sysfs global settings device attributes.\n", __func__); - sysfs_remove_group(&dgrp_class_global_settings_dev->kobj, - &dgrp_global_settings_attribute_group); - return; + goto err_dev1; } dgrp_class_nodes_dev = device_create(dgrp_class, NULL, MKDEV(0, max_majors + 2), NULL, "nodes"); + if (IS_ERR(dgrp_class_nodes_dev)) { + ret = PTR_ERR(dgrp_class_nodes_dev); + goto err_group; + } + return 0; +err_group: + sysfs_remove_group(&dgrp_class_global_settings_dev->kobj, + &dgrp_global_settings_attribute_group); +err_dev1: + device_destroy(dgrp_class, MKDEV(0, max_majors + 1)); +err_file: + class_remove_file(dgrp_class, &class_attr_driver_version); +err_class: + class_destroy(dgrp_class); + return ret; } @@ -137,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; @@ -154,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; @@ -172,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; @@ -192,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; @@ -212,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; @@ -253,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); @@ -291,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; @@ -308,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; @@ -328,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; @@ -357,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; @@ -376,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; @@ -395,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; @@ -414,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; @@ -433,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; @@ -452,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; @@ -473,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 51d3ed3dca2..30d26029b21 100644 --- a/drivers/staging/dgrp/dgrp_tty.c +++ b/drivers/staging/dgrp/dgrp_tty.c @@ -39,6 +39,7 @@ #include <linux/slab.h> #include <linux/tty.h> #include <linux/tty_flip.h> +#include <linux/device.h> #include <linux/sched.h> #include <linux/uaccess.h> @@ -370,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; @@ -751,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; } @@ -1119,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; } @@ -1316,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; } @@ -1498,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; @@ -1663,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; @@ -1672,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; @@ -2653,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; @@ -2679,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, @@ -2795,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); @@ -3204,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 */ |
