mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] usb: gadget: fsl: Fix registering from chipidea driver
Date: Tue, 25 Jun 2013 16:00:51 +0200	[thread overview]
Message-ID: <1372168851-28501-1-git-send-email-s.hauer@pengutronix.de> (raw)

The fsl gadget driver wants to configure the portsc register
with information from platform_data. When registered from the
chipidea driver there is no platform_data. Fix the resulting
crash by not derefencing platform_data when NULL. In this
case the PORTSC register is not touched, it will have been
configured by the chipidea driver in this case.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/fsl_udc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 81715f9..993c7eb 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -625,10 +625,13 @@ static int dr_controller_setup(struct fsl_udc *udc)
 	case FSL_USB2_PHY_SERIAL:
 		portctrl |= PORTSCX_PTS_FSLS;
 		break;
+	case FSL_USB2_PHY_NONE:
+		break;
 	default:
 		return -EINVAL;
 	}
-	writel(portctrl, &dr_regs->portsc1);
+	if (udc->phy_mode != FSL_USB2_PHY_NONE)
+		writel(portctrl, &dr_regs->portsc1);
 
 	/* Stop and reset the usb controller */
 	tmp = readl(&dr_regs->usbcmd);
@@ -2077,7 +2080,10 @@ static int struct_udc_setup(struct fsl_udc *udc,
 	struct fsl_usb2_platform_data *pdata = dev->platform_data;
 	size_t size;
 
-	udc->phy_mode = pdata->phy_mode;
+	if (pdata)
+		udc->phy_mode = pdata->phy_mode;
+	else
+		udc->phy_mode = FSL_USB2_PHY_NONE;
 
 	udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL);
 	if (!udc->eps) {
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2013-06-25 14:01 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=1372168851-28501-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