@@ -1279,9 +1279,13 @@ static int isp1301_otg_enable(struct isp1301 *isp)
static int
isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp;
- if (!otg || isp != the_transceiver)
+ if (!otg)
+ return -ENODEV;
+
+ isp = container_of(otg->phy, struct isp1301, phy);
+ if (isp != the_transceiver)
return -ENODEV;
if (!host) {
@@ -1335,9 +1339,13 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host)
static int
isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp;
+
+ if (!otg)
+ return -ENODEV;
- if (!otg || isp != the_transceiver)
+ isp = container_of(otg->phy, struct isp1301, phy);
+ if (isp != the_transceiver)
return -ENODEV;
if (!gadget) {
@@ -1415,11 +1423,14 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA)
static int
isp1301_start_srp(struct usb_otg *otg)
{
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp;
u32 otg_ctrl;
- if (!otg || isp != the_transceiver
- || isp->phy.state != OTG_STATE_B_IDLE)
+ if (!otg)
+ return -ENODEV;
+
+ isp = container_of(otg->phy, struct isp1301, phy);
+ if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE)
return -ENODEV;
otg_ctrl = omap_readl(OTG_CTRL);
@@ -1443,10 +1454,13 @@ static int
isp1301_start_hnp(struct usb_otg *otg)
{
#ifdef CONFIG_USB_OTG
- struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
+ struct isp1301 *isp;
u32 l;
- if (!otg || isp != the_transceiver)
+ if (!otg)
+ return -ENODEV;
+ isp = container_of(otg->phy, struct isp1301, phy);
+ if (isp != the_transceiver)
return -ENODEV;
if (otg->default_a && (otg->host == NULL || !otg->host->b_hnp_enable))
return -ENOTCONN;