usb: Simplify return statements
Subsystems (7)
v2 cover usb: Simplify return statements
From: Saurabh Karajgaonkar <[email protected]>
This patch series is created using simple_return.cocci coccinelle script. It replaces the redundant instances where variable is first assigned return value from a function call and then used in return statement, by direct function call in the return statement.
Changes for v2:
- corrected indentation issues [Patch 06/09, 08/09, 09/09]
- Patch 04/09 Acked by Patrice Chotard <[email protected]>
Saurabh Karajgaonkar (9):
usb: phy: phy-mxs-usb: Simplify return statement
usb: phy: phy-keystone: Simplify return statement
usb: musb: musb_dsps: Simplify return statement
usb: host: ehci-st: Simplify return statement
usb: host: oxu210hp-hcd: Simplify return statement
usb: host: u132-hcd: Simplify return statement
usb: host: xhci: Simplify return statement
usb: serial: mxuport: Simplify return statement
usb: misc: ftdi-elan: Simplify return statement
drivers/usb/host/ehci-st.c | 7 +------ drivers/usb/host/oxu210hp-hcd.c | 7 +------ drivers/usb/host/u132-hcd.c | 35 +++++++++-------------------------- drivers/usb/host/xhci.c | 6 +----- drivers/usb/misc/ftdi-elan.c | 12 ++---------- drivers/usb/musb/musb_dsps.c | 6 +----- drivers/usb/phy/phy-keystone.c | 6 +----- drivers/usb/phy/phy-mxs-usb.c | 6 +----- drivers/usb/serial/mxuport.c | 10 +++------- 9 files changed, 20 insertions(+), 75 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/9 usb: phy: phy-mxs-usb: Simplify return statement
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/phy/phy-mxs-usb.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +1 -5
@@ -506,11 +506,7 @@ static int mxs_phy_probe(struct platform_device *pdev)device_set_wakeup_capable (&pdev->dev, true); - ret =usb_add_phy_dev (&mxs_phy->phy); -if (ret) -return ret; - -return 0 ; +return usb_add_phy_dev (&mxs_phy->phy); }static int mxs_phy_remove (struct platform_device *pdev)
Signature · 1 line
1.9.1
PATCH v2 2/9 usb: phy: phy-keystone: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/phy/phy-keystone.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/phy/phy-keystone.c +1 -5
@@ -96,11 +96,7 @@ static int keystone_usbphy_probe(struct platform_device *pdev)platform_set_drvdata (pdev, k_phy); - ret =usb_add_phy_dev (&k_phy->usb_phy_gen.phy); -if (ret) -return ret; - -return 0 ; +return usb_add_phy_dev (&k_phy->usb_phy_gen.phy); }static int keystone_usbphy_remove (struct platform_device *pdev)
Signature · 1 line
1.9.1
PATCH v2 3/9 usb: musb: musb_dsps: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/musb/musb_dsps.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/musb/musb_dsps.c +1 -5
@@ -482,11 +482,7 @@ static int dsps_musb_init(struct musb *musb)dsps_writeb (musb->mregs,MUSB_BABBLE_CTL , val); } - ret =dsps_musb_dbg_init (musb, glue); -if (ret) -return ret; - -return 0 ; +return dsps_musb_dbg_init (musb, glue); }static int dsps_musb_exit (struct musb *musb)
Signature · 1 line
1.9.1
PATCH v2 4/9 usb: host: ehci-st: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/host/ehci-st.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/usb/host/ehci-st.c +1 -6
@@ -54,7 +54,6 @@ static int st_ehci_platform_reset(struct usb_hcd *hcd)struct platform_device *pdev =to_platform_device (hcd->self.controller);struct usb_ehci_pdata *pdata =dev_get_platdata (&pdev->dev);struct ehci_hcd *ehci =hcd_to_ehci (hcd); -int retval;u32 threshold;/* Set EHCI packet buffer IN/OUT threshold to 128 bytes */
@@ -62,11 +61,7 @@ static int st_ehci_platform_reset(struct usb_hcd *hcd)writel (threshold, hcd->regs +AHB2STBUS_INSREG01 ); ehci->caps = hcd->regs + pdata->caps_offset; - retval =ehci_setup (hcd); -if (retval) -return retval; - -return 0 ; +return ehci_setup (hcd); }static int st_ehci_platform_power_on (struct platform_device *dev)
Signature · 1 line
1.9.1
Re: [PATCH v2 4/9] usb: host: ehci-st: Simplify return statement
Hi Saurabh,
Quoted 10 lines · Saurabh (S.)
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by Saurabh Karajgaonkar <[email protected]>--- drivers/usb/host/ehci-st.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
Thanks!
Maxime
PATCH v2 5/9 usb: host: oxu210hp-hcd: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/host/oxu210hp-hcd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/usb/host/oxu210hp-hcd.c +1 -6
@@ -2670,7 +2670,6 @@ static int oxu_hcd_init(struct usb_hcd *hcd)static int oxu_reset (struct usb_hcd *hcd) {struct oxu_hcd *oxu =hcd_to_oxu (hcd); -int ret;spin_lock_init (&oxu->mem_lock);INIT_LIST_HEAD (&oxu->urb_list);
@@ -2696,11 +2695,7 @@ static int oxu_reset(struct usb_hcd *hcd) oxu->hcs_params =readl (&oxu->caps->hcs_params); oxu->sbrn =0x20 ; - ret =oxu_hcd_init (hcd); -if (ret) -return ret; - -return 0 ; +return oxu_hcd_init (hcd); }static int oxu_run (struct usb_hcd *hcd)
Signature · 1 line
1.9.1
PATCH v2 6/9 usb: host: u132-hcd: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/host/u132-hcd.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-)
drivers/usb/host/u132-hcd.c +9 -26
@@ -1542,11 +1542,8 @@ static int u132_periodic_reinit(struct u132 *u132) (fit ^ FIT) | u132->hc_fminterval);if (retval)return retval; - retval =u132_write_pcimem (u132, periodicstart, - ((9 * fi) /10 ) &0x3fff ); -if (retval) -return retval; -return 0 ; +return u132_write_pcimem (u132, periodicstart, + ((9 * fi) /10 ) &0x3fff ); }static char *hcfs2string (int state)
@@ -2701,28 +2698,18 @@ static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue,if (wIndex ==0 || wIndex > u132->num_ports) {return -EINVAL ; }else { -int retval;int port_index = wIndex -1 ;struct u132_port *port = &u132->port[port_index]; port->Status &= ~(1 << wValue);switch (wValue) {case USB_PORT_FEAT_SUSPEND : - retval =u132_write_pcimem (u132, - roothub.portstatus[port_index],RH_PS_PSS ); -if (retval) -return retval; -return 0 ; +return u132_write_pcimem (u132, + roothub.portstatus[port_index],RH_PS_PSS );case USB_PORT_FEAT_POWER : - retval =u132_write_pcimem (u132, - roothub.portstatus[port_index],RH_PS_PPS ); -if (retval) -return retval; -return 0 ; +return u132_write_pcimem (u132, + roothub.portstatus[port_index],RH_PS_PPS );case USB_PORT_FEAT_RESET : - retval =u132_roothub_portreset (u132, port_index); -if (retval) -return retval; -return 0 ; +return u132_roothub_portreset (u132, port_index);default :return -EPIPE ; }
@@ -2737,7 +2724,6 @@ static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue, }else {int port_index = wIndex -1 ;u32 temp; -int retval;struct u132_port *port = &u132->port[port_index]; port->Status &= ~(1 << wValue);switch (wValue) {
@@ -2773,11 +2759,8 @@ static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue,default :return -EPIPE ; } - retval =u132_write_pcimem (u132, roothub.portstatus[port_index], - temp); -if (retval) -return retval; -return 0 ; +return u132_write_pcimem (u132, roothub.portstatus[port_index], + temp); } }
Signature · 1 line
1.9.1
PATCH v2 7/9 usb: host: xhci: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/host/xhci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/usb/host/xhci.c +1 -5
@@ -4678,7 +4678,6 @@ int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd, {struct xhci_hcd *xhci;u16 mel; -int ret; xhci =hcd_to_xhci (hcd); if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) ||
@@ -4686,10 +4685,7 @@ int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd,return 0 ; mel =calculate_max_exit_latency (udev, state,USB3_LPM_DISABLED ); - ret =xhci_change_max_exit_latency (xhci, udev, mel); -if (ret) -return ret; - return 0; + return xhci_change_max_exit_latency(xhci, udev, mel); }#else /* CONFIG_PM */
Signature · 1 line
1.9.1
PATCH v2 8/9 usb: serial: mxuport: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/serial/mxuport.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/usb/serial/mxuport.c +3 -7
@@ -1137,13 +1137,9 @@ static int mxuport_port_probe(struct usb_serial_port *port)return err;/* Set interface (RS-232) */ - err =mxuport_send_ctrl_urb (serial,RQ_VENDOR_SET_INTERFACE , -MX_INT_RS232 , - port->port_number); -if (err) -return err; - -return 0 ; +return mxuport_send_ctrl_urb (serial,RQ_VENDOR_SET_INTERFACE , +MX_INT_RS232 , + port->port_number); } static int mxuport_alloc_write_urb(struct usb_serial *serial,
Signature · 1 line
1.9.1
Johan Hovold
maintainerRe: [PATCH v2 8/9] usb: serial: mxuport: Simplify return statement
Quoted 17 lines · Saurabh (S.)
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by Saurabh Karajgaonkar <[email protected]>--- drivers/usb/serial/mxuport.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/usb/serial/mxuport.c +0
-0@@ -1137,13 +1137,9 @@ static int mxuport_port_probe(struct usb_serial_port *port)return err;/* Set interface (RS-232) */
drivers/usb/serial/mxuport.c static int mxuport_port_probe(struct usb_serial_port *port) · line 1142
Quoted 10 lines
drivers/usb/serial/mxuport.c +3
-7- err =mxuport_send_ctrl_urb (serial,RQ_VENDOR_SET_INTERFACE , -MX_INT_RS232 , - port->port_number); -if (err) -return err; - -return 0 ; +return mxuport_send_ctrl_urb (serial,RQ_VENDOR_SET_INTERFACE , +MX_INT_RS232 , + port->port_number);
I do not consider this an improvement as it makes the final ctrl-request call look different from the previous two without any real benefit.
I'll drop this one.
Johan
PATCH v2 9/9 usb: misc: ftdi-elan: Simplify return statement
In reply to Karajgaonkar, Saurabh (S.)From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
--- drivers/usb/misc/ftdi-elan.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/usb/misc/ftdi-elan.c +2 -10
@@ -2568,11 +2568,7 @@ static int ftdi_elan_close_controller(struct usb_ftdi *ftdi, int fn) 0x00);if (UxxxStatus)return UxxxStatus; - UxxxStatus =ftdi_elan_read_config (ftdi, activePCIfn | reg,0 , - &pcidata); -if (UxxxStatus) -return UxxxStatus; -return 0 ; +return ftdi_elan_read_config (ftdi, activePCIfn | reg,0 , &pcidata); }static int ftdi_elan_found_controller (struct usb_ftdi *ftdi,int fn,int quirk)
@@ -2695,11 +2691,7 @@ static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi) } }if (ftdi->function >0 ) { - UxxxStatus =ftdi_elan_setup_controller (ftdi, - ftdi->function -1 ); -if (UxxxStatus) -return UxxxStatus; -return 0 ; +return ftdi_elan_setup_controller (ftdi, ftdi->function -1 ); }else if (controllers >0 ) {return -ENXIO ; }else if (unrecognized >0 ) {
Signature · 1 line
1.9.1