From: Andrzej Pietrasiewicz Date: Fri, 11 Dec 2015 15:06:19 +0000 (+0100) Subject: usb: gadget: tcm: simplify attribute store function X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e2ffb77a14dbf6a8b47cfec750629ffc2b423e6e;p=linux-beck.git usb: gadget: tcm: simplify attribute store function Simplify function code. Signed-off-by: Andrzej Pietrasiewicz Acked-by: Sebastian Andrzej Siewior Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c index 98064bbfc2a7..96b5d54b2a98 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)