From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] usb: chipidea i.MX: Do not return unnecessary error
Date: Mon, 29 Aug 2016 17:37:46 +0200 [thread overview]
Message-ID: <1472485066-27702-1-git-send-email-s.hauer@pengutronix.de> (raw)
We only allow to setup the host/peripheral role once, when it's already
set then we return -EBUSY.
Return 0 instead when we set the same role again and only return -EBUSY
when we actually try to change the role.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/imx/chipidea-imx.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index a799abe..fb451f3 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -150,7 +150,7 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
static int ci_register_role(struct imx_chipidea *ci)
{
- if (ci->role_registered)
+ if (ci->role_registered != IMX_USB_MODE_OTG)
return -EBUSY;
if (ci->mode == IMX_USB_MODE_HOST) {
@@ -180,8 +180,12 @@ static int ci_set_mode(struct param_d *param, void *priv)
{
struct imx_chipidea *ci = priv;
- if (ci->role_registered)
- return -EBUSY;
+ if (ci->role_registered != IMX_USB_MODE_OTG) {
+ if (ci->role_registered == ci->mode)
+ return 0;
+ else
+ return -EBUSY;
+ }
return ci_register_role(ci);
}
@@ -225,6 +229,7 @@ static int imx_chipidea_probe(struct device_d *dev)
ci = xzalloc(sizeof(*ci));
ci->dev = dev;
+ ci->role_registered = IMX_USB_MODE_OTG;
if (IS_ENABLED(CONFIG_OFDEVICE) && dev->device_node) {
ret = imx_chipidea_probe_dt(ci);
--
2.8.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2016-08-29 15:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1472485066-27702-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox