From fbc06a377b20cbb3c4aa1f1d18cc6935ff378a12 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 10 Sep 2012 12:42:31 +0800 Subject: [PATCH] --- yaml --- r: 325947 b: refs/heads/master c: 58add6ca84c4815feef45008c41274b6df41ede8 h: refs/heads/master i: 325945: 606b30e217c5e439265cee16aff501474ecc6dad 325943: 68bbf0b8e62502599d3c03192baf19a8a6395586 v: v3 --- [refs] | 2 +- trunk/drivers/usb/otg/fsl_otg.c | 34 +++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 5f7cbf93372e..97a602efde13 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c9e4412ab8eb8ef82d645d8749c4ce96ad490007 +refs/heads/master: 58add6ca84c4815feef45008c41274b6df41ede8 diff --git a/trunk/drivers/usb/otg/fsl_otg.c b/trunk/drivers/usb/otg/fsl_otg.c index 23c798cb2d7f..c19d1d7173a9 100644 --- a/trunk/drivers/usb/otg/fsl_otg.c +++ b/trunk/drivers/usb/otg/fsl_otg.c @@ -544,9 +544,13 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) */ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) { - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); + struct fsl_otg *otg_dev; + + if (!otg) + return -ENODEV; - if (!otg || otg_dev != fsl_otg_dev) + otg_dev = container_of(otg->phy, struct fsl_otg, phy); + if (otg_dev != fsl_otg_dev) return -ENODEV; otg->host = host; @@ -590,12 +594,15 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) static int fsl_otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) { - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); + struct fsl_otg *otg_dev; + if (!otg) + return -ENODEV; + + otg_dev = container_of(otg->phy, struct fsl_otg, phy); VDBG("otg_dev 0x%x\n", (int)otg_dev); VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); - - if (!otg || otg_dev != fsl_otg_dev) + if (otg_dev != fsl_otg_dev) return -ENODEV; if (!gadget) { @@ -660,10 +667,13 @@ static void fsl_otg_event(struct work_struct *work) /* B-device start SRP */ static int fsl_otg_start_srp(struct usb_otg *otg) { - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); + struct fsl_otg *otg_dev; + + if (!otg || otg->phy->state != OTG_STATE_B_IDLE) + return -ENODEV; - if (!otg || otg_dev != fsl_otg_dev - || otg->phy->state != OTG_STATE_B_IDLE) + otg_dev = container_of(otg->phy, struct fsl_otg, phy); + if (otg_dev != fsl_otg_dev) return -ENODEV; otg_dev->fsm.b_bus_req = 1; @@ -675,9 +685,13 @@ static int fsl_otg_start_srp(struct usb_otg *otg) /* A_host suspend will call this function to start hnp */ static int fsl_otg_start_hnp(struct usb_otg *otg) { - struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); + struct fsl_otg *otg_dev; + + if (!otg) + return -ENODEV; - if (!otg || otg_dev != fsl_otg_dev) + otg_dev = container_of(otg->phy, struct fsl_otg, phy); + if (otg_dev != fsl_otg_dev) return -ENODEV; DBG("start_hnp...n");