浏览代码

net: phy: micrel: refactor led-mode error handling

Refactor led-mode error handling.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Johan Hovold 10 年之前
父节点
当前提交
b7035860a1
共有 1 个文件被更改,包括 10 次插入9 次删除
  1. 10 9
      drivers/net/phy/micrel.c

+ 10 - 9
drivers/net/phy/micrel.c

@@ -179,14 +179,19 @@ static int kszphy_setup_led(struct phy_device *phydev,
 	}
 	}
 
 
 	temp = phy_read(phydev, reg);
 	temp = phy_read(phydev, reg);
-	if (temp < 0)
-		return temp;
+	if (temp < 0) {
+		rc = temp;
+		goto out;
+	}
 
 
 	temp &= ~(3 << shift);
 	temp &= ~(3 << shift);
 	temp |= val << shift;
 	temp |= val << shift;
 	rc = phy_write(phydev, reg, temp);
 	rc = phy_write(phydev, reg, temp);
+out:
+	if (rc < 0)
+		dev_err(&phydev->dev, "failed to set led mode\n");
 
 
-	return rc < 0 ? rc : 0;
+	return rc;
 }
 }
 
 
 /* Disable PHY address 0 as the broadcast address, so that it can be used as a
 /* Disable PHY address 0 as the broadcast address, so that it can be used as a
@@ -223,9 +228,7 @@ static int ksz8021_config_init(struct phy_device *phydev)
 {
 {
 	int rc;
 	int rc;
 
 
-	rc = kszphy_setup_led(phydev, 0x1f, 4);
-	if (rc)
-		dev_err(&phydev->dev, "failed to set led mode\n");
+	kszphy_setup_led(phydev, 0x1f, 4);
 
 
 	rc = ksz_config_flags(phydev);
 	rc = ksz_config_flags(phydev);
 	if (rc < 0)
 	if (rc < 0)
@@ -240,9 +243,7 @@ static int ks8051_config_init(struct phy_device *phydev)
 {
 {
 	int rc;
 	int rc;
 
 
-	rc = kszphy_setup_led(phydev, 0x1f, 4);
-	if (rc)
-		dev_err(&phydev->dev, "failed to set led mode\n");
+	kszphy_setup_led(phydev, 0x1f, 4);
 
 
 	rc = ksz_config_flags(phydev);
 	rc = ksz_config_flags(phydev);
 	return rc < 0 ? rc : 0;
 	return rc < 0 ? rc : 0;