[PATCH 4/4] usb: phy: add phy-hi6220
From: zhangfei.gao@linaro.org (Zhangfei Gao)
Date: 2015-02-09 03:31:55
Also in:
linux-devicetree
On 9 February 2015 at 09:57, Peter Chen [off-list ref] wrote:
quoted
quoted
quoted
+static int hi6220_phy_probe(struct platform_device *pdev) +{ + struct hi6220_priv *priv; + struct usb_otg *otg; + struct device_node *np = pdev->dev.of_node; + int ret, irq; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); + if (!otg) + return -ENOMEM; + + priv->phy.dev = &pdev->dev; + priv->phy.otg = otg; + priv->phy.label = "hi6220"; + platform_set_drvdata(pdev, priv); + otg->set_peripheral = mv_otg_set_peripheral; + + priv->gpio_vbus_det = of_get_named_gpio(np, "hisilicon,gpio_vbus_det", 0); + if (priv->gpio_vbus_det == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!gpio_is_valid(priv->gpio_vbus_det)) { + dev_err(&pdev->dev, "invalid gpio %d\n", priv->gpio_vbus_det); + return -ENODEV; + } + + priv->gpio_id_det = of_get_named_gpio(np, "hisilicon,gpio_id_det", 0); + if (priv->gpio_id_det == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!gpio_is_valid(priv->gpio_id_det)) { + dev_err(&pdev->dev, "invalid gpio %d\n", priv->gpio_id_det); + return -ENODEV; + } + + priv->reg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, + "hisilicon,peripheral-syscon"); + if (IS_ERR(priv->reg)) + priv->reg = NULL;You may differentiate -ENODEV and other errors, for other errors, you can show an error, and return directly.Here I want to set this property as optional, in case other platform do not need this property. So phy_setup also add protection if (priv->reg == NULL) return;If syscon_regmap_lookup_by_phandle returns -EPROBE_DEFER, you may want to try later.
It should not. syscon is postcore_initcall(syscon_init); Thanks