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(-)
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/phy/phy-mxs-usb.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 3fcc048..4d863eb 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -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)
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/phy/phy-keystone.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/usb/phy/phy-keystone.c b/drivers/usb/phy/phy-keystone.c
index e0556f7..01d4e4c 100644
--- a/drivers/usb/phy/phy-keystone.c
+++ b/drivers/usb/phy/phy-keystone.c
@@ -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)
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/musb/musb_dsps.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 1334a3d..a0cfead 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -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)
--
1.9.1
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(-)
diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index 7e4bd39..b7c5cfa 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -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)
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/host/oxu210hp-hcd.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 6352f54..fe3bd1c 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -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)
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/host/u132-hcd.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index d516877..a67bd50 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -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);
}
}
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/host/xhci.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 526ebc0..19076fa 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -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 */
--
1.9.1
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(-)
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index 460a406..31a8b47 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -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,
--
1.9.1
From: Saurabh Karajgaonkar <[email protected]>
Replace redundant variable use in return statement.
Signed-off-by: Saurabh Karajgaonkar <[email protected]>
---
drivers/usb/misc/ftdi-elan.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 8ab1f8f..52c27ca 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -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) {
--
1.9.1
Hi Saurabh,
On 08/04/2015 04:02 PM, Karajgaonkar, Saurabh (S.) wrote:
> 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(-)
>
>
Acked-by: Maxime Coquelin <[email protected]>
Thanks!
Maxime
On Tue, Aug 04, 2015 at 02:04:35PM +0000, Karajgaonkar, Saurabh (S.) wrote:
> 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(-)
>
> diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
> index 460a406..31a8b47 100644
> --- a/drivers/usb/serial/mxuport.c
> +++ b/drivers/usb/serial/mxuport.c
> @@ -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);
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