Skip to contentSkip to conversation

phy: rockchip-inno-usb2: support otg-port for rk3399

bug report New Dan Carpenter 3 participants 3 messages Nov 17, 2016 – Nov 25, 2016 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello William Wu,

The patch 0c42fe48fd23: "phy: rockchip-inno-usb2: support otg-port for rk3399" from Nov 7, 2016, leads to the following static checker warning:

	drivers/phy/phy-rockchip-inno-usb2.c:998 rockchip_usb2phy_otg_port_init()
	warn: 'rphy->edev' isn't an ERR_PTR

drivers/phy/phy-rockchip-inno-usb2.c
989 ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq, NULL,

   990                                          rockchip_usb2phy_bvalid_irq,
   991                                          IRQF_ONESHOT,
   992                                          "rockchip_usb2phy_bvalid", rport);

993 if (ret) {
994 dev_err(rphy->dev, "failed to request otg-bvalid irq handle\n");
995 goto out;
996 }
997
998 if (!IS_ERR(rphy->edev)) {

I think the static checker is correct that this check should be removed. The rest of the code assumes ->edev is a valid pointer.

   999                  rport->event_nb.notifier_call = rockchip_otg_event;
  1000  
  1001                  ret = extcon_register_notifier(rphy->edev, EXTCON_USB_HOST,
  1002                                                 &rport->event_nb);
  1003                  if (ret)
  1004                          dev_err(rphy->dev, "register USB HOST notifier failed\n");
  1005          }
  1006  
  1007  out:
  1008          return ret;
  1009  }

regards,
dan carpenter

#1 lore raw

Dear Dan,

Quoted 21 lines · Dan Carpenter

Hello William Wu,

The patch 0c42fe48fd23: "phy: rockchip-inno-usb2: support otg-port for rk3399" from Nov 7, 2016, leads to the following static checker warning:

	drivers/phy/phy-rockchip-inno-usb2.c:998 rockchip_usb2phy_otg_port_init()
	warn: 'rphy->edev' isn't an ERR_PTR

drivers/phy/phy-rockchip-inno-usb2.c

    989          ret = devm_request_threaded_irq(rphy->dev, rport->bvalid_irq, NULL,
    990                                          rockchip_usb2phy_bvalid_irq,
    991                                          IRQF_ONESHOT,
    992                                          "rockchip_usb2phy_bvalid", rport);
    993          if (ret) {
    994                  dev_err(rphy->dev, "failed to request otg-bvalid irq handle\n");
    995                  goto out;
    996          }
    997
    998          if (!IS_ERR(rphy->edev)) {
Quoted 2 lines

I think the static checker is correct that this check should be removed. The rest of the code assumes ->edev is a valid pointer.

Yes, you are right. This static checker can be removed safely. Thanks very much for your help.

Best regards,
wulf

Quoted 13 lines
    999                  rport->event_nb.notifier_call = rockchip_otg_event;
   1000
   1001                  ret = extcon_register_notifier(rphy->edev, EXTCON_USB_HOST,
   1002                                                 &rport->event_nb);
   1003                  if (ret)
   1004                          dev_err(rphy->dev, "register USB HOST notifier failed\n");
   1005          }
   1006
   1007  out:
   1008          return ret;
   1009  }
Quoted 5 lines

regards,
dan carpenter

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

A message that is not in the archive (sent off-list or not yet received): 81fc5933-7bee-2d83-f8ef-a951355c4248-TNX95d0MmH7DzftRWevZcw@public.gmane.org

#3 lore raw

PATCH 1/1 phy: rockchip-inno-usb2: remove an unneeded check

"rphy->edev" can't be an error pointer so we can remove the check and pull the code in an indent level.

drivers/phy/phy-rockchip-inno-usb2.c +5 -8
index 2f99ec9..7494210 100644
@@ -995,14 +995,11 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
 		goto out;
 	}
 
-	if (!IS_ERR(rphy->edev)) {
-		rport->event_nb.notifier_call = rockchip_otg_event;
-
-		ret = extcon_register_notifier(rphy->edev, EXTCON_USB_HOST,
-					       &rport->event_nb);
-		if (ret)
-			dev_err(rphy->dev, "register USB HOST notifier failed\n");
-	}
+	rport->event_nb.notifier_call = rockchip_otg_event;
+	ret = extcon_register_notifier(rphy->edev, EXTCON_USB_HOST,
+				       &rport->event_nb);
+	if (ret)
+		dev_err(rphy->dev, "register USB HOST notifier failed\n");
 
 out:
 	return ret;