[PATCHv4 04/11] usb: gadget: tcm: simplify attribute store function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simplify function code.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
---
 drivers/usb/gadget/legacy/tcm_usb_gadget.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 98064bb..96b5d54 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -1503,27 +1503,19 @@ static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
 	if (ret)
 		return ret;
 
-	if (op && tpg->gadget_connect) {
-		ret = -EINVAL;
-		goto out;
-	}
-	if (!op && !tpg->gadget_connect) {
-		ret = -EINVAL;
-		goto out;
-	}
+	if ((op && tpg->gadget_connect) || (!op && !tpg->gadget_connect))
+		return -EINVAL;
 
-	if (op) {
+	if (op)
 		ret = usbg_attach(tpg);
-		if (ret)
-			goto out;
-	} else {
+	else
 		usbg_detach(tpg);
-	}
+	if (ret)
+		return ret;
+
 	tpg->gadget_connect = op;
 
 	return count;
-out:
-	return ret;
 }
 
 static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux