提交 ead87637 编写于 作者: S Stephen Boyd 提交者: David S. Miller

stmmac: ipq806x: Return error values instead of pointers

Typically we return error pointers when we want to use those
pointers in the non-error case, but this function is just
returning error pointers or NULL for success. Change the style to
plain int to follow normal kernel coding styles.

Cc: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 dc8d1eb3
...@@ -198,19 +198,19 @@ static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed) ...@@ -198,19 +198,19 @@ static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed)
return 0; return 0;
} }
static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
{ {
struct device *dev = &gmac->pdev->dev; struct device *dev = &gmac->pdev->dev;
gmac->phy_mode = of_get_phy_mode(dev->of_node); gmac->phy_mode = of_get_phy_mode(dev->of_node);
if (gmac->phy_mode < 0) { if (gmac->phy_mode < 0) {
dev_err(dev, "missing phy mode property\n"); dev_err(dev, "missing phy mode property\n");
return ERR_PTR(-EINVAL); return -EINVAL;
} }
if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) { if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) {
dev_err(dev, "missing qcom id property\n"); dev_err(dev, "missing qcom id property\n");
return ERR_PTR(-EINVAL); return -EINVAL;
} }
/* The GMACs are called 1 to 4 in the documentation, but to simplify the /* The GMACs are called 1 to 4 in the documentation, but to simplify the
...@@ -219,13 +219,13 @@ static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) ...@@ -219,13 +219,13 @@ static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
*/ */
if (gmac->id < 0 || gmac->id > 3) { if (gmac->id < 0 || gmac->id > 3) {
dev_err(dev, "invalid gmac id\n"); dev_err(dev, "invalid gmac id\n");
return ERR_PTR(-EINVAL); return -EINVAL;
} }
gmac->core_clk = devm_clk_get(dev, "stmmaceth"); gmac->core_clk = devm_clk_get(dev, "stmmaceth");
if (IS_ERR(gmac->core_clk)) { if (IS_ERR(gmac->core_clk)) {
dev_err(dev, "missing stmmaceth clk property\n"); dev_err(dev, "missing stmmaceth clk property\n");
return gmac->core_clk; return PTR_ERR(gmac->core_clk);
} }
clk_set_rate(gmac->core_clk, 266000000); clk_set_rate(gmac->core_clk, 266000000);
...@@ -234,18 +234,16 @@ static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) ...@@ -234,18 +234,16 @@ static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
"qcom,nss-common"); "qcom,nss-common");
if (IS_ERR(gmac->nss_common)) { if (IS_ERR(gmac->nss_common)) {
dev_err(dev, "missing nss-common node\n"); dev_err(dev, "missing nss-common node\n");
return gmac->nss_common; return PTR_ERR(gmac->nss_common);
} }
/* Setup the register map for the qsgmii csr registers */ /* Setup the register map for the qsgmii csr registers */
gmac->qsgmii_csr = syscon_regmap_lookup_by_phandle(dev->of_node, gmac->qsgmii_csr = syscon_regmap_lookup_by_phandle(dev->of_node,
"qcom,qsgmii-csr"); "qcom,qsgmii-csr");
if (IS_ERR(gmac->qsgmii_csr)) { if (IS_ERR(gmac->qsgmii_csr))
dev_err(dev, "missing qsgmii-csr node\n"); dev_err(dev, "missing qsgmii-csr node\n");
return gmac->qsgmii_csr;
}
return NULL; return PTR_ERR_OR_ZERO(gmac->qsgmii_csr);
} }
static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed) static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed)
...@@ -262,7 +260,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) ...@@ -262,7 +260,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ipq806x_gmac *gmac; struct ipq806x_gmac *gmac;
int val; int val;
void *err; int err;
val = stmmac_get_platform_resources(pdev, &stmmac_res); val = stmmac_get_platform_resources(pdev, &stmmac_res);
if (val) if (val)
...@@ -279,9 +277,9 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) ...@@ -279,9 +277,9 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
gmac->pdev = pdev; gmac->pdev = pdev;
err = ipq806x_gmac_of_parse(gmac); err = ipq806x_gmac_of_parse(gmac);
if (IS_ERR(err)) { if (err) {
dev_err(dev, "device tree parsing error\n"); dev_err(dev, "device tree parsing error\n");
return PTR_ERR(err); return err;
} }
regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL, regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册