From bc702adeba07dba4be8a43e9e2e351df12fc1a6c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 31 Oct 2018 19:13:00 +0000 Subject: tlclk: clean an indentation issue, remove extraneous tabs Trivial fix to clean up an indentation issue, remove tabs Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/char/tlclk.c | 87 ++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 8eeb4190207d..6d81bb3bb503 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c @@ -506,28 +506,28 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d, val = (unsigned char)tmp; spin_lock_irqsave(&event_lock, flags); - if ((val == CLK_8kHz) || (val == CLK_16_384MHz)) { - SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x28); - SET_PORT_BITS(TLCLK_REG1, 0xfb, ~val); - } else if (val >= CLK_8_592MHz) { - SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38); - switch (val) { - case CLK_8_592MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); - break; - case CLK_11_184MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); - break; - case CLK_34_368MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); - break; - case CLK_44_736MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); - break; - } - } else - SET_PORT_BITS(TLCLK_REG3, 0xc7, val << 3); - + if ((val == CLK_8kHz) || (val == CLK_16_384MHz)) { + SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x28); + SET_PORT_BITS(TLCLK_REG1, 0xfb, ~val); + } else if (val >= CLK_8_592MHz) { + SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38); + switch (val) { + case CLK_8_592MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); + break; + case CLK_11_184MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); + break; + case CLK_34_368MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); + break; + case CLK_44_736MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); + break; + } + } else { + SET_PORT_BITS(TLCLK_REG3, 0xc7, val << 3); + } spin_unlock_irqrestore(&event_lock, flags); return strnlen(buf, count); @@ -548,27 +548,28 @@ static ssize_t store_select_amcb1_transmit_clock(struct device *d, val = (unsigned char)tmp; spin_lock_irqsave(&event_lock, flags); - if ((val == CLK_8kHz) || (val == CLK_16_384MHz)) { - SET_PORT_BITS(TLCLK_REG3, 0xf8, 0x5); - SET_PORT_BITS(TLCLK_REG1, 0xfb, ~val); - } else if (val >= CLK_8_592MHz) { - SET_PORT_BITS(TLCLK_REG3, 0xf8, 0x7); - switch (val) { - case CLK_8_592MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); - break; - case CLK_11_184MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); - break; - case CLK_34_368MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); - break; - case CLK_44_736MHz: - SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); - break; - } - } else - SET_PORT_BITS(TLCLK_REG3, 0xf8, val); + if ((val == CLK_8kHz) || (val == CLK_16_384MHz)) { + SET_PORT_BITS(TLCLK_REG3, 0xf8, 0x5); + SET_PORT_BITS(TLCLK_REG1, 0xfb, ~val); + } else if (val >= CLK_8_592MHz) { + SET_PORT_BITS(TLCLK_REG3, 0xf8, 0x7); + switch (val) { + case CLK_8_592MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); + break; + case CLK_11_184MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); + break; + case CLK_34_368MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); + break; + case CLK_44_736MHz: + SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); + break; + } + } else { + SET_PORT_BITS(TLCLK_REG3, 0xf8, val); + } spin_unlock_irqrestore(&event_lock, flags); return strnlen(buf, count); -- cgit v1.2.3-59-g8ed1b From 69f92163f47ab5ac1d3a26e17563576cd651d56e Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:32 +0000 Subject: char: lp: remove trailing whitespace Fix checkpatch error for trailing whitespace. Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 8c4dd1a3bb6a..7b15272c0510 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -46,8 +46,8 @@ * lp=auto (assign lp devices to all ports that * have printers attached, as determined * by the IEEE-1284 autoprobe) - * - * lp=reset (reset the printer during + * + * lp=reset (reset the printer during * initialisation) * * lp=off (disable the printer driver entirely) @@ -188,7 +188,7 @@ static int lp_preempt(void *handle) } -/* +/* * Try to negotiate to a new mode; if unsuccessful negotiate to * compatibility mode. Return the mode we ended up in. */ @@ -326,7 +326,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, */ lp_claim_parport_or_block (&lp_table[minor]); /* Go to the proper mode. */ - lp_table[minor].current_mode = lp_negotiate (port, + lp_table[minor].current_mode = lp_negotiate (port, lp_table[minor].best_mode); parport_set_timeout (lp_table[minor].dev, @@ -355,7 +355,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, /* incomplete write -> check error ! */ int error; - parport_negotiate (lp_table[minor].dev->port, + parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; @@ -372,8 +372,8 @@ static ssize_t lp_write(struct file * file, const char __user * buf, } parport_yield_blocking (lp_table[minor].dev); - lp_table[minor].current_mode - = lp_negotiate (port, + lp_table[minor].current_mode + = lp_negotiate (port, lp_table[minor].best_mode); } else if (need_resched()) @@ -389,13 +389,13 @@ static ssize_t lp_write(struct file * file, const char __user * buf, retv = -EFAULT; break; } - } + } } while (count > 0); - if (test_and_clear_bit(LP_PREEMPT_REQUEST, + if (test_and_clear_bit(LP_PREEMPT_REQUEST, &lp_table[minor].bits)) { printk(KERN_INFO "lp%d releasing parport\n", minor); - parport_negotiate (lp_table[minor].dev->port, + parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; lp_release_parport (&lp_table[minor]); @@ -542,7 +542,7 @@ static int lp_open(struct inode * inode, struct file * file) /* Determine if the peripheral supports ECP mode */ lp_claim_parport_or_block (&lp_table[minor]); if ( (lp_table[minor].dev->port->modes & PARPORT_MODE_ECP) && - !parport_negotiate (lp_table[minor].dev->port, + !parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_ECP)) { printk (KERN_INFO "lp%d: ECP mode\n", minor); lp_table[minor].best_mode = IEEE1284_MODE_ECP; @@ -615,7 +615,7 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd, case LPWAIT: LP_WAIT(minor) = arg; break; - case LPSETIRQ: + case LPSETIRQ: return -EINVAL; break; case LPGETIRQ: @@ -908,7 +908,7 @@ static int __init lp_setup (char *str) static int lp_register(int nr, struct parport *port) { - lp_table[nr].dev = parport_register_device(port, "lp", + lp_table[nr].dev = parport_register_device(port, "lp", lp_preempt, NULL, NULL, 0, (void *) &lp_table[nr]); if (lp_table[nr].dev == NULL) @@ -921,7 +921,7 @@ static int lp_register(int nr, struct parport *port) device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, "lp%d", nr); - printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, + printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); #ifdef CONFIG_LP_CONSOLE @@ -1060,7 +1060,7 @@ static int __init lp_init_module (void) else { char *ep; unsigned long r = simple_strtoul(parport[n], &ep, 0); - if (ep != parport[n]) + if (ep != parport[n]) parport_nr[n] = r; else { printk(KERN_ERR "lp: bad port specifier `%s'\n", parport[n]); -- cgit v1.2.3-59-g8ed1b From 1c3de93621b310276ae4d966a14ed01b711312c2 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:33 +0000 Subject: char: lp: move trailing statement to next line Fix checkpatch errors for trailing if else statements. Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 7b15272c0510..65bf32244f48 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -223,12 +223,15 @@ static void lp_error (int minor) return; polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE; - if (polling) lp_release_parport (&lp_table[minor]); + if (polling) + lp_release_parport (&lp_table[minor]); prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); schedule_timeout(LP_TIMEOUT_POLLED); finish_wait(&lp_table[minor].waitq, &wait); - if (polling) lp_claim_parport_or_block (&lp_table[minor]); - else parport_yield_blocking (lp_table[minor].dev); + if (polling) + lp_claim_parport_or_block (&lp_table[minor]); + else + parport_yield_blocking (lp_table[minor].dev); } static int lp_check_status(int minor) -- cgit v1.2.3-59-g8ed1b From 39992028c76c4dfcf26f965922fecb579b7f8d6e Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:34 +0000 Subject: char: lp: do not use return as a function return is not a function, parentheses are not required. Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 65bf32244f48..4153c6f5683a 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -184,7 +184,7 @@ static int lp_preempt(void *handle) { struct lp_struct *this_lp = (struct lp_struct *)handle; set_bit(LP_PREEMPT_REQUEST, &this_lp->bits); - return (1); + return 1; } @@ -199,7 +199,7 @@ static int lp_negotiate(struct parport * port, int mode) parport_negotiate (port, mode); } - return (mode); + return mode; } static int lp_reset(int minor) @@ -279,7 +279,7 @@ static int lp_wait_ready(int minor, int nonblock) /* If we're not in compatibility mode, we're ready now! */ if (lp_table[minor].current_mode != IEEE1284_MODE_COMPAT) { - return (0); + return 0; } do { -- cgit v1.2.3-59-g8ed1b From 1b3451e0edd3257594dbad79bef7b1e451463273 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:35 +0000 Subject: char: lp: use tabs instead of spaces Fixes the checkpatch error: ERROR: code indent should use tabs where possible Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 4153c6f5683a..15d03aa55a1a 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -262,7 +262,7 @@ static int lp_check_status(int minor) error = -EIO; } else { last = 0; /* Come here if LP_CAREFUL is set and no - errors are reported. */ + errors are reported. */ } lp_table[minor].last_error = last; @@ -295,7 +295,7 @@ static int lp_wait_ready(int minor, int nonblock) } static ssize_t lp_write(struct file * file, const char __user * buf, - size_t count, loff_t *ppos) + size_t count, loff_t *ppos) { unsigned int minor = iminor(file_inode(file)); struct parport *port = lp_table[minor].dev->port; @@ -325,8 +325,8 @@ static ssize_t lp_write(struct file * file, const char __user * buf, goto out_unlock; } - /* Claim Parport or sleep until it becomes available - */ + /* Claim Parport or sleep until it becomes available + */ lp_claim_parport_or_block (&lp_table[minor]); /* Go to the proper mode. */ lp_table[minor].current_mode = lp_negotiate (port, @@ -406,7 +406,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, out_unlock: mutex_unlock(&lp_table[minor].port_mutex); - return retv; + return retv; } #ifdef CONFIG_PARPORT_1284 @@ -545,8 +545,8 @@ static int lp_open(struct inode * inode, struct file * file) /* Determine if the peripheral supports ECP mode */ lp_claim_parport_or_block (&lp_table[minor]); if ( (lp_table[minor].dev->port->modes & PARPORT_MODE_ECP) && - !parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_ECP)) { + !parport_negotiate (lp_table[minor].dev->port, + IEEE1284_MODE_ECP)) { printk (KERN_INFO "lp%d: ECP mode\n", minor); lp_table[minor].best_mode = IEEE1284_MODE_ECP; } else { @@ -650,8 +650,8 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd, sizeof(struct lp_stats)); break; #endif - case LPGETFLAGS: - status = LP_F(minor); + case LPGETFLAGS: + status = LP_F(minor); if (copy_to_user(argp, &status, sizeof(int))) return -EFAULT; break; -- cgit v1.2.3-59-g8ed1b From 2081f9c03cc901ff288b65c4493d9272bf7df084 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:36 +0000 Subject: char: lp: fix whitespace with pointers Fixes checkpatch warning: "foo * bar should be foo *bar" Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 15d03aa55a1a..017ea457a9d7 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -192,7 +192,7 @@ static int lp_preempt(void *handle) * Try to negotiate to a new mode; if unsuccessful negotiate to * compatibility mode. Return the mode we ended up in. */ -static int lp_negotiate(struct parport * port, int mode) +static int lp_negotiate(struct parport *port, int mode) { if (parport_negotiate (port, mode) != 0) { mode = IEEE1284_MODE_COMPAT; @@ -294,7 +294,7 @@ static int lp_wait_ready(int minor, int nonblock) return error; } -static ssize_t lp_write(struct file * file, const char __user * buf, +static ssize_t lp_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { unsigned int minor = iminor(file_inode(file)); @@ -412,7 +412,7 @@ out_unlock: #ifdef CONFIG_PARPORT_1284 /* Status readback conforming to ieee1284 */ -static ssize_t lp_read(struct file * file, char __user * buf, +static ssize_t lp_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { DEFINE_WAIT(wait); @@ -491,7 +491,7 @@ static ssize_t lp_read(struct file * file, char __user * buf, #endif /* IEEE 1284 support */ -static int lp_open(struct inode * inode, struct file * file) +static int lp_open(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); int ret = 0; @@ -561,7 +561,7 @@ out: return ret; } -static int lp_release(struct inode * inode, struct file * file) +static int lp_release(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); -- cgit v1.2.3-59-g8ed1b From 885b3680c4a6c052da937770652aec81f8e5590b Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Sun, 25 Nov 2018 19:47:37 +0000 Subject: char: lp: fix spacing style before open parenthesis Fixes the checkpatch warning: "space prohibited between function name and open parenthesis" Signed-off-by: Sudip Mukherjee Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 184 +++++++++++++++++++++++++++--------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 017ea457a9d7..e0a92d764eee 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -166,7 +166,7 @@ static struct parport *console_registered; static void lp_claim_parport_or_block(struct lp_struct *this_lp) { if (!test_and_set_bit(LP_PARPORT_CLAIMED, &this_lp->bits)) { - parport_claim_or_block (this_lp->dev); + parport_claim_or_block(this_lp->dev); } } @@ -174,7 +174,7 @@ static void lp_claim_parport_or_block(struct lp_struct *this_lp) static void lp_release_parport(struct lp_struct *this_lp) { if (test_and_clear_bit(LP_PARPORT_CLAIMED, &this_lp->bits)) { - parport_release (this_lp->dev); + parport_release(this_lp->dev); } } @@ -194,9 +194,9 @@ static int lp_preempt(void *handle) */ static int lp_negotiate(struct parport *port, int mode) { - if (parport_negotiate (port, mode) != 0) { + if (parport_negotiate(port, mode) != 0) { mode = IEEE1284_MODE_COMPAT; - parport_negotiate (port, mode); + parport_negotiate(port, mode); } return mode; @@ -205,16 +205,16 @@ static int lp_negotiate(struct parport *port, int mode) static int lp_reset(int minor) { int retval; - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); w_ctr(minor, LP_PSELECP); - udelay (LP_DELAY); + udelay(LP_DELAY); w_ctr(minor, LP_PSELECP | LP_PINITP); retval = r_str(minor); - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); return retval; } -static void lp_error (int minor) +static void lp_error(int minor) { DEFINE_WAIT(wait); int polling; @@ -224,14 +224,14 @@ static void lp_error (int minor) polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE; if (polling) - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE); schedule_timeout(LP_TIMEOUT_POLLED); finish_wait(&lp_table[minor].waitq, &wait); if (polling) - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); else - parport_yield_blocking (lp_table[minor].dev); + parport_yield_blocking(lp_table[minor].dev); } static int lp_check_status(int minor) @@ -283,10 +283,10 @@ static int lp_wait_ready(int minor, int nonblock) } do { - error = lp_check_status (minor); + error = lp_check_status(minor); if (error && (nonblock || (LP_F(minor) & LP_ABORT))) break; - if (signal_pending (current)) { + if (signal_pending(current)) { error = -EINTR; break; } @@ -320,26 +320,26 @@ static ssize_t lp_write(struct file *file, const char __user *buf, if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) return -EINTR; - if (copy_from_user (kbuf, buf, copy_size)) { + if (copy_from_user(kbuf, buf, copy_size)) { retv = -EFAULT; goto out_unlock; } /* Claim Parport or sleep until it becomes available */ - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); /* Go to the proper mode. */ - lp_table[minor].current_mode = lp_negotiate (port, - lp_table[minor].best_mode); + lp_table[minor].current_mode = lp_negotiate(port, + lp_table[minor].best_mode); - parport_set_timeout (lp_table[minor].dev, - (nonblock ? PARPORT_INACTIVITY_O_NONBLOCK - : lp_table[minor].timeout)); + parport_set_timeout(lp_table[minor].dev, + (nonblock ? PARPORT_INACTIVITY_O_NONBLOCK + : lp_table[minor].timeout)); - if ((retv = lp_wait_ready (minor, nonblock)) == 0) + if ((retv = lp_wait_ready(minor, nonblock)) == 0) do { /* Write the data. */ - written = parport_write (port, kbuf, copy_size); + written = parport_write(port, kbuf, copy_size); if (written > 0) { copy_size -= written; count -= written; @@ -347,7 +347,7 @@ static ssize_t lp_write(struct file *file, const char __user *buf, retv += written; } - if (signal_pending (current)) { + if (signal_pending(current)) { if (retv == 0) retv = -EINTR; @@ -358,11 +358,11 @@ static ssize_t lp_write(struct file *file, const char __user *buf, /* incomplete write -> check error ! */ int error; - parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_COMPAT); + parport_negotiate(lp_table[minor].dev->port, + IEEE1284_MODE_COMPAT); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; - error = lp_wait_ready (minor, nonblock); + error = lp_wait_ready(minor, nonblock); if (error) { if (retv == 0) @@ -374,13 +374,13 @@ static ssize_t lp_write(struct file *file, const char __user *buf, break; } - parport_yield_blocking (lp_table[minor].dev); + parport_yield_blocking(lp_table[minor].dev); lp_table[minor].current_mode - = lp_negotiate (port, - lp_table[minor].best_mode); + = lp_negotiate(port, + lp_table[minor].best_mode); } else if (need_resched()) - schedule (); + schedule(); if (count) { copy_size = count; @@ -398,10 +398,10 @@ static ssize_t lp_write(struct file *file, const char __user *buf, if (test_and_clear_bit(LP_PREEMPT_REQUEST, &lp_table[minor].bits)) { printk(KERN_INFO "lp%d releasing parport\n", minor); - parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_COMPAT); + parport_negotiate(lp_table[minor].dev->port, + IEEE1284_MODE_COMPAT); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); } out_unlock: mutex_unlock(&lp_table[minor].port_mutex); @@ -429,21 +429,21 @@ static ssize_t lp_read(struct file *file, char __user *buf, if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) return -EINTR; - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); - parport_set_timeout (lp_table[minor].dev, - (nonblock ? PARPORT_INACTIVITY_O_NONBLOCK - : lp_table[minor].timeout)); + parport_set_timeout(lp_table[minor].dev, + (nonblock ? PARPORT_INACTIVITY_O_NONBLOCK + : lp_table[minor].timeout)); - parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); - if (parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_NIBBLE)) { + parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); + if (parport_negotiate(lp_table[minor].dev->port, + IEEE1284_MODE_NIBBLE)) { retval = -EIO; goto out; } while (retval == 0) { - retval = parport_read (port, kbuf, count); + retval = parport_read(port, kbuf, count); if (retval > 0) break; @@ -456,11 +456,11 @@ static ssize_t lp_read(struct file *file, char __user *buf, /* Wait for data. */ if (lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE) { - parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_COMPAT); - lp_error (minor); - if (parport_negotiate (lp_table[minor].dev->port, - IEEE1284_MODE_NIBBLE)) { + parport_negotiate(lp_table[minor].dev->port, + IEEE1284_MODE_COMPAT); + lp_error(minor); + if (parport_negotiate(lp_table[minor].dev->port, + IEEE1284_MODE_NIBBLE)) { retval = -EIO; goto out; } @@ -470,18 +470,18 @@ static ssize_t lp_read(struct file *file, char __user *buf, finish_wait(&lp_table[minor].waitq, &wait); } - if (signal_pending (current)) { + if (signal_pending(current)) { retval = -ERESTARTSYS; break; } - cond_resched (); + cond_resched(); } - parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); + parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); out: - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); - if (retval > 0 && copy_to_user (buf, kbuf, retval)) + if (retval > 0 && copy_to_user(buf, kbuf, retval)) retval = -EFAULT; mutex_unlock(&lp_table[minor].port_mutex); @@ -516,9 +516,9 @@ static int lp_open(struct inode *inode, struct file *file) should most likely only ever be used by the tunelp application. */ if ((LP_F(minor) & LP_ABORTOPEN) && !(file->f_flags & O_NONBLOCK)) { int status; - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); status = r_str(minor); - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); if (status & LP_POUTPA) { printk(KERN_INFO "lp%d out of paper\n", minor); LP_F(minor) &= ~LP_BUSY; @@ -543,18 +543,18 @@ static int lp_open(struct inode *inode, struct file *file) goto out; } /* Determine if the peripheral supports ECP mode */ - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); if ( (lp_table[minor].dev->port->modes & PARPORT_MODE_ECP) && - !parport_negotiate (lp_table[minor].dev->port, + !parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_ECP)) { - printk (KERN_INFO "lp%d: ECP mode\n", minor); + printk(KERN_INFO "lp%d: ECP mode\n", minor); lp_table[minor].best_mode = IEEE1284_MODE_ECP; } else { lp_table[minor].best_mode = IEEE1284_MODE_COMPAT; } /* Leave peripheral in compatibility mode */ - parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); - lp_release_parport (&lp_table[minor]); + parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); + lp_release_parport(&lp_table[minor]); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; out: mutex_unlock(&lp_mutex); @@ -565,10 +565,10 @@ static int lp_release(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); - lp_claim_parport_or_block (&lp_table[minor]); - parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); + lp_claim_parport_or_block(&lp_table[minor]); + parport_negotiate(lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); kfree(lp_table[minor].lp_buffer); lp_table[minor].lp_buffer = NULL; LP_F(minor) &= ~LP_BUSY; @@ -629,9 +629,9 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd, case LPGETSTATUS: if (mutex_lock_interruptible(&lp_table[minor].port_mutex)) return -EINTR; - lp_claim_parport_or_block (&lp_table[minor]); + lp_claim_parport_or_block(&lp_table[minor]); status = r_str(minor); - lp_release_parport (&lp_table[minor]); + lp_release_parport(&lp_table[minor]); mutex_unlock(&lp_table[minor].port_mutex); if (copy_to_user(argp, &status, sizeof(int))) @@ -804,31 +804,31 @@ static const struct file_operations lp_fops = { /* The console must be locked when we get here. */ -static void lp_console_write (struct console *co, const char *s, - unsigned count) +static void lp_console_write(struct console *co, const char *s, + unsigned count) { struct pardevice *dev = lp_table[CONSOLE_LP].dev; struct parport *port = dev->port; ssize_t written; - if (parport_claim (dev)) + if (parport_claim(dev)) /* Nothing we can do. */ return; - parport_set_timeout (dev, 0); + parport_set_timeout(dev, 0); /* Go to compatibility mode. */ - parport_negotiate (port, IEEE1284_MODE_COMPAT); + parport_negotiate(port, IEEE1284_MODE_COMPAT); do { /* Write the data, converting LF->CRLF as we go. */ ssize_t canwrite = count; - char *lf = memchr (s, '\n', count); + char *lf = memchr(s, '\n', count); if (lf) canwrite = lf - s; if (canwrite > 0) { - written = parport_write (port, s, canwrite); + written = parport_write(port, s, canwrite); if (written <= 0) continue; @@ -846,14 +846,14 @@ static void lp_console_write (struct console *co, const char *s, s++; count--; do { - written = parport_write (port, crlf, i); + written = parport_write(port, crlf, i); if (written > 0) i -= written, crlf += written; } while (i > 0 && (CONSOLE_LP_STRICT || written > 0)); } } while (count > 0 && (CONSOLE_LP_STRICT || written > 0)); - parport_release (dev); + parport_release(dev); } static struct console lpcons = { @@ -874,7 +874,7 @@ module_param_array(parport, charp, NULL, 0); module_param(reset, bool, 0); #ifndef MODULE -static int __init lp_setup (char *str) +static int __init lp_setup(char *str) { static int parport_ptr; int x; @@ -932,17 +932,17 @@ static int lp_register(int nr, struct parport *port) if (port->modes & PARPORT_MODE_SAFEININT) { register_console(&lpcons); console_registered = port; - printk (KERN_INFO "lp%d: console ready\n", CONSOLE_LP); + printk(KERN_INFO "lp%d: console ready\n", CONSOLE_LP); } else - printk (KERN_ERR "lp%d: cannot run console on %s\n", - CONSOLE_LP, port->name); + printk(KERN_ERR "lp%d: cannot run console on %s\n", + CONSOLE_LP, port->name); } #endif return 0; } -static void lp_attach (struct parport *port) +static void lp_attach(struct parport *port) { unsigned int i; @@ -972,7 +972,7 @@ static void lp_attach (struct parport *port) } } -static void lp_detach (struct parport *port) +static void lp_detach(struct parport *port) { /* Write this some day. */ #ifdef CONFIG_LP_CONSOLE @@ -989,7 +989,7 @@ static struct parport_driver lp_driver = { .detach = lp_detach, }; -static int __init lp_init (void) +static int __init lp_init(void) { int i, err = 0; @@ -1006,17 +1006,17 @@ static int __init lp_init (void) #ifdef LP_STATS lp_table[i].lastcall = 0; lp_table[i].runchars = 0; - memset (&lp_table[i].stats, 0, sizeof (struct lp_stats)); + memset(&lp_table[i].stats, 0, sizeof(struct lp_stats)); #endif lp_table[i].last_error = 0; - init_waitqueue_head (&lp_table[i].waitq); - init_waitqueue_head (&lp_table[i].dataq); + init_waitqueue_head(&lp_table[i].waitq); + init_waitqueue_head(&lp_table[i].dataq); mutex_init(&lp_table[i].port_mutex); lp_table[i].timeout = 10 * HZ; } - if (register_chrdev (LP_MAJOR, "lp", &lp_fops)) { - printk (KERN_ERR "lp: unable to get major %d\n", LP_MAJOR); + if (register_chrdev(LP_MAJOR, "lp", &lp_fops)) { + printk(KERN_ERR "lp: unable to get major %d\n", LP_MAJOR); return -EIO; } @@ -1026,17 +1026,17 @@ static int __init lp_init (void) goto out_reg; } - if (parport_register_driver (&lp_driver)) { - printk (KERN_ERR "lp: unable to register with parport\n"); + if (parport_register_driver(&lp_driver)) { + printk(KERN_ERR "lp: unable to register with parport\n"); err = -EIO; goto out_class; } if (!lp_count) { - printk (KERN_INFO "lp: driver loaded but no devices found\n"); + printk(KERN_INFO "lp: driver loaded but no devices found\n"); #ifndef CONFIG_PARPORT_1284 if (parport_nr[0] == LP_PARPORT_AUTO) - printk (KERN_INFO "lp: (is IEEE 1284 support enabled?)\n"); + printk(KERN_INFO "lp: (is IEEE 1284 support enabled?)\n"); #endif } @@ -1049,7 +1049,7 @@ out_reg: return err; } -static int __init lp_init_module (void) +static int __init lp_init_module(void) { if (parport[0]) { /* The user gave some parameters. Let's see what they were. */ @@ -1077,14 +1077,14 @@ static int __init lp_init_module (void) return lp_init(); } -static void lp_cleanup_module (void) +static void lp_cleanup_module(void) { unsigned int offset; - parport_unregister_driver (&lp_driver); + parport_unregister_driver(&lp_driver); #ifdef CONFIG_LP_CONSOLE - unregister_console (&lpcons); + unregister_console(&lpcons); #endif unregister_chrdev(LP_MAJOR, "lp"); -- cgit v1.2.3-59-g8ed1b From ddfa728ad1b1dbb4172ba65f3043d2d50c694f3d Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Fri, 30 Nov 2018 21:41:28 -0500 Subject: char: virtio: Change to use DEFINE_SHOW_ATTRIBUTE macro Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/char/virtio_console.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 5b5b5d72eab7..fbeb71953526 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1309,7 +1309,7 @@ static const struct attribute_group port_attribute_group = { .attrs = port_sysfs_entries, }; -static int debugfs_show(struct seq_file *s, void *data) +static int port_debugfs_show(struct seq_file *s, void *data) { struct port *port = s->private; @@ -1327,18 +1327,7 @@ static int debugfs_show(struct seq_file *s, void *data) return 0; } -static int debugfs_open(struct inode *inode, struct file *file) -{ - return single_open(file, debugfs_show, inode->i_private); -} - -static const struct file_operations port_debugfs_ops = { - .owner = THIS_MODULE, - .open = debugfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(port_debugfs); static void set_console_size(struct port *port, u16 rows, u16 cols) { @@ -1490,7 +1479,7 @@ static int add_port(struct ports_device *portdev, u32 id) port->debugfs_file = debugfs_create_file(debugfs_name, 0444, pdrvdata.debugfs_dir, port, - &port_debugfs_ops); + &port_debugfs_fops); } return 0; -- cgit v1.2.3-59-g8ed1b From f88fd666051b08eb3f3118e2dd8508bf0247af4c Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 5 Dec 2018 13:50:19 -0600 Subject: char/rtc: Use of_node_name_eq for node name comparisons Convert string compares of DT node names to use of_node_name_eq helper instead. This removes direct access to the node name pointer. The open coded iterating thru the child node names is converted to use for_each_child_of_node() instead. Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/char/rtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 4948c8bda6b1..62b7c721c732 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -866,8 +866,8 @@ static int __init rtc_init(void) #ifdef CONFIG_SPARC32 for_each_node_by_name(ebus_dp, "ebus") { struct device_node *dp; - for (dp = ebus_dp; dp; dp = dp->sibling) { - if (!strcmp(dp->name, "rtc")) { + for_each_child_of_node(ebus_dp, dp) { + if (of_node_name_eq(dp, "rtc")) { op = of_find_device_by_node(dp); if (op) { rtc_port = op->resource[0].start; -- cgit v1.2.3-59-g8ed1b From 0edf39d2c7dbb4947358dd102b6ff35eaaa92d68 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Dec 2018 14:27:30 +0000 Subject: char: lp: introduce list to save port number When we are registering lp in LP_PARPORT_AUTO mode, we are not keeping any record of the parallel port number to which lp is connecting. Add an array to save the port number to it. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index e0a92d764eee..7e207ff0f2fe 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -141,6 +141,7 @@ static DEFINE_MUTEX(lp_mutex); static struct lp_struct lp_table[LP_NO]; +static int port_num[LP_NO]; static unsigned int lp_count = 0; static struct class *lp_class; @@ -938,6 +939,7 @@ static int lp_register(int nr, struct parport *port) CONSOLE_LP, port->name); } #endif + port_num[nr] = port->number; return 0; } @@ -1013,6 +1015,7 @@ static int __init lp_init(void) init_waitqueue_head(&lp_table[i].dataq); mutex_init(&lp_table[i].port_mutex); lp_table[i].timeout = 10 * HZ; + port_num[i] = -1; } if (register_chrdev(LP_MAJOR, "lp", &lp_fops)) { @@ -1091,6 +1094,7 @@ static void lp_cleanup_module(void) for (offset = 0; offset < LP_NO; offset++) { if (lp_table[offset].dev == NULL) continue; + port_num[offset] = -1; parport_unregister_device(lp_table[offset].dev); device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); } -- cgit v1.2.3-59-g8ed1b From d6318c0e8318c200aa95b50769d3635907381c08 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Dec 2018 14:27:31 +0000 Subject: char: lp: detach the device when parallel port is removed When the parallel port is usb based and the lp attaches to it, we do get /dev/lp0, but when we remove the usb device and the parallel port is gone, we are still left with /dev/lp0. Unregister the device properly in the detach routine based on the port number it has connected to. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 7e207ff0f2fe..e21ed4007d0f 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -976,6 +976,8 @@ static void lp_attach(struct parport *port) static void lp_detach(struct parport *port) { + int n; + /* Write this some day. */ #ifdef CONFIG_LP_CONSOLE if (console_registered == port) { @@ -983,6 +985,14 @@ static void lp_detach(struct parport *port) console_registered = NULL; } #endif /* CONFIG_LP_CONSOLE */ + + for (n = 0; n < LP_NO; n++) { + if (port_num[n] == port->number) { + port_num[n] = -1; + device_destroy(lp_class, MKDEV(LP_MAJOR, n)); + parport_unregister_device(lp_table[n].dev); + } + } } static struct parport_driver lp_driver = { @@ -1082,8 +1092,6 @@ static int __init lp_init_module(void) static void lp_cleanup_module(void) { - unsigned int offset; - parport_unregister_driver(&lp_driver); #ifdef CONFIG_LP_CONSOLE @@ -1091,13 +1099,6 @@ static void lp_cleanup_module(void) #endif unregister_chrdev(LP_MAJOR, "lp"); - for (offset = 0; offset < LP_NO; offset++) { - if (lp_table[offset].dev == NULL) - continue; - port_num[offset] = -1; - parport_unregister_device(lp_table[offset].dev); - device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); - } class_destroy(lp_class); } -- cgit v1.2.3-59-g8ed1b From dc34da42860d8ce01f64ac11752eecccf53c1a6c Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Dec 2018 14:27:32 +0000 Subject: char: lp: use first unused lp number while registering When the parallel port is usb based and the lp attaches to it based on LP_PARPORT_AUTO, we do get /dev/lp0 and when we remove the usb device /dev/lp0 is unregistered. But if we now reconnect the usb device we get /dev/lp1, another disconnection and reconnection and we get /dev/lp2. Use the port number array to find the first unused lp number and use that to register the lp device with the parallel port. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index e21ed4007d0f..0e081f521f51 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -958,7 +958,11 @@ static void lp_attach(struct parport *port) printk(KERN_INFO "lp: ignoring parallel port (max. %d)\n",LP_NO); return; } - if (!lp_register(lp_count, port)) + for (i = 0; i < LP_NO; i++) + if (port_num[i] == -1) + break; + + if (!lp_register(i, port)) lp_count++; break; -- cgit v1.2.3-59-g8ed1b From e379c1a46068969a2b822a15dbc9a37577e1e04f Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Dec 2018 14:27:33 +0000 Subject: char: lp: properly count the lp devices When the parallel port is usb based and the lp attaches to it based on LP_PARPORT_AUTO, we do get /dev/lp0 and when we remove the usb device /dev/lp0 is unregistered. If we now reconnect the usb device we get our /dev/lp0 back. But if we now disconnect and reconnect eight times we donot get any lp device and dmesg shows: lp: ignoring parallel port (max. 8) Decrement the lp_count when the device detaches as this represents the number of lp devices connected to the system. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 0e081f521f51..cef2ea386f5e 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -993,6 +993,7 @@ static void lp_detach(struct parport *port) for (n = 0; n < LP_NO; n++) { if (port_num[n] == port->number) { port_num[n] = -1; + lp_count--; device_destroy(lp_class, MKDEV(LP_MAJOR, n)); parport_unregister_device(lp_table[n].dev); } -- cgit v1.2.3-59-g8ed1b From fdfaef212694a139ebd5119f9a07f2e8e24be8a6 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 7 Dec 2018 14:27:34 +0000 Subject: char: lp: use new parport device model Modify lp driver to use the new parallel port device model. Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/char/lp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index cef2ea386f5e..5c8d780637bd 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -912,9 +912,13 @@ static int __init lp_setup(char *str) static int lp_register(int nr, struct parport *port) { - lp_table[nr].dev = parport_register_device(port, "lp", - lp_preempt, NULL, NULL, 0, - (void *) &lp_table[nr]); + struct pardev_cb ppdev_cb; + + memset(&ppdev_cb, 0, sizeof(ppdev_cb)); + ppdev_cb.preempt = lp_preempt; + ppdev_cb.private = &lp_table[nr]; + lp_table[nr].dev = parport_register_dev_model(port, "lp", + &ppdev_cb, nr); if (lp_table[nr].dev == NULL) return 1; lp_table[nr].flags |= LP_EXIST; @@ -1002,8 +1006,9 @@ static void lp_detach(struct parport *port) static struct parport_driver lp_driver = { .name = "lp", - .attach = lp_attach, + .match_port = lp_attach, .detach = lp_detach, + .devmodel = true, }; static int __init lp_init(void) -- cgit v1.2.3-59-g8ed1b