mirror of https://gitee.com/openkylin/linux.git
phy: ti: am654: simplify return handling
Checking return value after each regfield write becomes hard to read quickly as number of writes increase. Simplify by checking for error only once. Signed-off-by: Sekhar Nori <nsekhar@ti.com> Link: https://lore.kernel.org/r/20200727194603.44636-3-nsekhar@ti.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
c3e60e5a9e
commit
b494bbb6c6
|
@ -161,34 +161,32 @@ static void serdes_am654_disable_pll(struct serdes_am654 *phy)
|
||||||
|
|
||||||
static int serdes_am654_enable_txrx(struct serdes_am654 *phy)
|
static int serdes_am654_enable_txrx(struct serdes_am654 *phy)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
/* Enable TX */
|
/* Enable TX */
|
||||||
ret = regmap_field_write(phy->fields[TX0_ENABLE], TX0_ENABLE_STATE);
|
ret |= regmap_field_write(phy->fields[TX0_ENABLE], TX0_ENABLE_STATE);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* Enable RX */
|
/* Enable RX */
|
||||||
ret = regmap_field_write(phy->fields[RX0_ENABLE], RX0_ENABLE_STATE);
|
ret |= regmap_field_write(phy->fields[RX0_ENABLE], RX0_ENABLE_STATE);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int serdes_am654_disable_txrx(struct serdes_am654 *phy)
|
static int serdes_am654_disable_txrx(struct serdes_am654 *phy)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
/* Disable TX */
|
/* Disable TX */
|
||||||
ret = regmap_field_write(phy->fields[TX0_ENABLE], TX0_DISABLE_STATE);
|
ret |= regmap_field_write(phy->fields[TX0_ENABLE], TX0_DISABLE_STATE);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* Disable RX */
|
/* Disable RX */
|
||||||
ret = regmap_field_write(phy->fields[RX0_ENABLE], RX0_DISABLE_STATE);
|
ret |= regmap_field_write(phy->fields[RX0_ENABLE], RX0_DISABLE_STATE);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -311,19 +309,14 @@ static int serdes_am654_usb3_init(struct serdes_am654 *phy)
|
||||||
|
|
||||||
static int serdes_am654_pcie_init(struct serdes_am654 *phy)
|
static int serdes_am654_pcie_init(struct serdes_am654 *phy)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
ret = regmap_field_write(phy->fields[CONFIG_VERSION], VERSION_VAL);
|
ret |= regmap_field_write(phy->fields[CONFIG_VERSION], VERSION_VAL);
|
||||||
if (ret)
|
ret |= regmap_field_write(phy->fields[CMU_MASTER_CDN], 0x1);
|
||||||
return ret;
|
ret |= regmap_field_write(phy->fields[L1_MASTER_CDN], 0x1);
|
||||||
|
|
||||||
ret = regmap_field_write(phy->fields[CMU_MASTER_CDN], 0x1);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return -EIO;
|
||||||
|
|
||||||
ret = regmap_field_write(phy->fields[L1_MASTER_CDN], 0x1);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -345,20 +338,19 @@ static int serdes_am654_init(struct phy *x)
|
||||||
static int serdes_am654_reset(struct phy *x)
|
static int serdes_am654_reset(struct phy *x)
|
||||||
{
|
{
|
||||||
struct serdes_am654 *phy = phy_get_drvdata(x);
|
struct serdes_am654 *phy = phy_get_drvdata(x);
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
serdes_am654_disable_pll(phy);
|
serdes_am654_disable_pll(phy);
|
||||||
serdes_am654_disable_txrx(phy);
|
serdes_am654_disable_txrx(phy);
|
||||||
|
|
||||||
ret = regmap_field_write(phy->fields[POR_EN], 0x1);
|
ret |= regmap_field_write(phy->fields[POR_EN], 0x1);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
mdelay(1);
|
mdelay(1);
|
||||||
|
|
||||||
ret = regmap_field_write(phy->fields[POR_EN], 0x0);
|
ret |= regmap_field_write(phy->fields[POR_EN], 0x0);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue