USB: kl5kusb105: Remove useless return variables
Subsystems (3)
PATCH 1/11 USB: kl5kusb105: Remove useless return variables
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
Verified by compilation only.
The coccinelle script that find and fixes this issue is:
// <smpl>
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
when strict
return
- ret
+ C
;
// </smpl>
--- drivers/usb/serial/kl5kusb105.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/usb/serial/kl5kusb105.c +1 -22
@@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)static int klsi_105_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear) { -int retval = -EINVAL ; - -/* if this ever gets implemented, it should be done something like this: -struct usb_serial *serial = port->serial; -struct klsi_105_private *priv = usb_get_serial_port_data(port); -unsigned long flags; -int control; - -spin_lock_irqsave (&priv->lock, flags); -if (set & TIOCM_RTS) -priv->control_state |= TIOCM_RTS; -if (set & TIOCM_DTR) -priv->control_state |= TIOCM_DTR; -if (clear & TIOCM_RTS) -priv->control_state &= ~TIOCM_RTS; -if (clear & TIOCM_DTR) -priv->control_state &= ~TIOCM_DTR; -control = priv->control_state; -spin_unlock_irqrestore (&priv->lock, flags); -retval = mct_u232_set_modem_ctrl(serial, control); -*/ -return retval; +return -EINVAL ; }module_usb_serial_driver (serial_drivers, id_table);
Quoted 49 lines · Peter Senna Tschudin
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
Verified by compilation only.
The coccinelle script that find and fixes this issue is:
// <smpl>
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
when strict
return
- ret
+ C
;
// </smpl>Signed-off-by Peter Senna Tschudin <[email protected]>--- drivers/usb/serial/kl5kusb105.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)drivers/usb/serial/kl5kusb105.c +0
-13@@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)static int klsi_105_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear) { -int retval = -EINVAL ; - -/* if this ever gets implemented, it should be done something like this: -struct usb_serial *serial = port->serial; -struct klsi_105_private *priv = usb_get_serial_port_data(port); -unsigned long flags; -int control; - -spin_lock_irqsave (&priv->lock, flags); -if (set & TIOCM_RTS) -priv->control_state |= TIOCM_RTS; -if (set & TIOCM_DTR) -priv->control_state |= TIOCM_DTR;
drivers/usb/serial/kl5kusb105.c static int klsi_105_tiocmget(struct tty_struct *tty) · line 608
Quoted 10 lines
drivers/usb/serial/kl5kusb105.c +1
-9-if (clear & TIOCM_RTS) -priv->control_state &= ~TIOCM_RTS; -if (clear & TIOCM_DTR) -priv->control_state &= ~TIOCM_DTR; -control = priv->control_state; -spin_unlock_irqrestore (&priv->lock, flags); -retval = mct_u232_set_modem_ctrl(serial, control); -*/ -return retval; +return -EINVAL ;
Your patch does a bit more than what the description says, although removing this out-commented code would be perfectly fine.
But please just remove the entire function (and the corresponding entry in the struct usb_serial_driver) and update the commit message.
Thanks,
Johan
Quoted 4 lines
drivers/usb/serial/kl5kusb105.c +0
-0}module_usb_serial_driver (serial_drivers, id_table);
Quoted 55 lines · Johan Hovold
Quoted 54 lines · Peter Senna Tschudin
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
Verified by compilation only.
The coccinelle script that find and fixes this issue is:
// <smpl>
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
when strict
return
- ret
+ C
;
// </smpl>Signed-off-by Peter Senna Tschudin <[email protected]>--- drivers/usb/serial/kl5kusb105.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)drivers/usb/serial/kl5kusb105.c +0
-18@@ -605,28 +605,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)static int klsi_105_tiocmset (struct tty_struct *tty,unsigned int set,unsigned int clear) { -int retval = -EINVAL ; - -/* if this ever gets implemented, it should be done something like this: -struct usb_serial *serial = port->serial; -struct klsi_105_private *priv = usb_get_serial_port_data(port); -unsigned long flags; -int control; - -spin_lock_irqsave (&priv->lock, flags); -if (set & TIOCM_RTS) -priv->control_state |= TIOCM_RTS; -if (set & TIOCM_DTR) -priv->control_state |= TIOCM_DTR; -if (clear & TIOCM_RTS) -priv->control_state &= ~TIOCM_RTS; -if (clear & TIOCM_DTR) -priv->control_state &= ~TIOCM_DTR; -control = priv->control_state;
Quoted 8 lines
drivers/usb/serial/kl5kusb105.c static int klsi_105_tiocmget(struct tty_struct *tty) · line 608
Quoted 5 lines
drivers/usb/serial/kl5kusb105.c +1
-4-spin_unlock_irqrestore (&priv->lock, flags); -retval = mct_u232_set_modem_ctrl(serial, control); -*/ -return retval; +return -EINVAL ;Your patch does a bit more than what the description says, although removing this out-commented code would be perfectly fine.
Sorry for that, my fault.
Quoted 3 lines
But please just remove the entire function (and the corresponding entry in the struct
usb_serial_driver) and update the commit message.
Sent V2.
Quoted 8 lines
Thanks,
JohanQuoted 4 lines
drivers/usb/serial/kl5kusb105.c +0
-0}module_usb_serial_driver (serial_drivers, id_table);
Signature · 1 line
Peter
Hello.
Quoted 3 lines · Peter Senna Tschudin
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
The patch does more than just that, it also removes commented out code.
Quoted 1 line
Verified by compilation only.
[...]
Quoted 1 line
Signed-off-by Peter Senna Tschudin <[email protected]>
WBR, Sergei
Quoted 11 lines · Sergei Shtylyov
Hello.
Quoted 3 lines · Peter Senna Tschudin
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
The patch does more than just that, it also removes commented out code.
That was my fault. It was fixed on V2:
http://marc.info/?l=kernel-janitors&m0155221232137&w=2
Quoted 13 lines
Quoted 2 lines
Verified by compilation only.
[...]
Quoted 1 line
Signed-off-by Peter Senna Tschudin <[email protected]>WBR, Sergei
Signature · 1 line
Peter
Hello.
Quoted 8 lines · Peter Senna Tschudin
Quoted 5 lines
Quoted 3 lines
This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable.
The patch does more than just that, it also removes commented out code.
That was my fault. It was fixed on V2:
http://marc.info/?l=kernel-janitors&m=140155221232137&w=2
Yes, I forgot to look at the follow-ups before replying.
WBR, Sergei