From: Sekhar Nori <nsekhar@ti.com>
To: Kishon Vijay Abraham I <kishon@ti.com>, Vinod Koul <vkoul@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Sekhar Nori <nsekhar@ti.com>
Subject: [PATCH 2/3] phy: ti: am654: simplify return handling
Date: Sun, 26 Jul 2020 00:34:54 +0530 [thread overview]
Message-ID: <20200725190455.43500-3-nsekhar@ti.com> (raw)
In-Reply-To: <20200725190455.43500-1-nsekhar@ti.com>
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>
---
drivers/phy/ti/phy-am654-serdes.c | 48 +++++++++++++------------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/phy/ti/phy-am654-serdes.c b/drivers/phy/ti/phy-am654-serdes.c
index ed7669c6a7a0..f3d58853553d 100644
--- a/drivers/phy/ti/phy-am654-serdes.c
+++ b/drivers/phy/ti/phy-am654-serdes.c
@@ -163,34 +163,32 @@ static void serdes_am654_disable_pll(struct serdes_am654 *phy)
static int serdes_am654_enable_txrx(struct serdes_am654 *phy)
{
- int ret;
+ int ret = 0;
/* Enable TX */
- ret = regmap_field_write(phy->fields[TX0_ENABLE], TX0_ENABLE_STATE);
- if (ret)
- return ret;
+ ret |= regmap_field_write(phy->fields[TX0_ENABLE], TX0_ENABLE_STATE);
/* 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)
- return ret;
+ return -EIO;
return 0;
}
static int serdes_am654_disable_txrx(struct serdes_am654 *phy)
{
- int ret;
+ int ret = 0;
/* Disable TX */
- ret = regmap_field_write(phy->fields[TX0_ENABLE], TX0_DISABLE_STATE);
- if (ret)
- return ret;
+ ret |= regmap_field_write(phy->fields[TX0_ENABLE], TX0_DISABLE_STATE);
/* 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)
- return ret;
+ return -EIO;
return 0;
}
@@ -313,19 +311,14 @@ static int serdes_am654_usb3_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);
- if (ret)
- return ret;
+ ret |= regmap_field_write(phy->fields[CONFIG_VERSION], VERSION_VAL);
+ ret |= regmap_field_write(phy->fields[CMU_MASTER_CDN], 0x1);
+ ret |= regmap_field_write(phy->fields[L1_MASTER_CDN], 0x1);
- ret = regmap_field_write(phy->fields[CMU_MASTER_CDN], 0x1);
if (ret)
- return ret;
-
- ret = regmap_field_write(phy->fields[L1_MASTER_CDN], 0x1);
- if (ret)
- return ret;
+ return -EIO;
return 0;
}
@@ -347,20 +340,19 @@ static int serdes_am654_init(struct phy *x)
static int serdes_am654_reset(struct phy *x)
{
struct serdes_am654 *phy = phy_get_drvdata(x);
- int ret;
+ int ret = 0;
serdes_am654_disable_pll(phy);
serdes_am654_disable_txrx(phy);
- ret = regmap_field_write(phy->fields[POR_EN], 0x1);
- if (ret)
- return ret;
+ ret |= regmap_field_write(phy->fields[POR_EN], 0x1);
mdelay(1);
- ret = regmap_field_write(phy->fields[POR_EN], 0x0);
+ ret |= regmap_field_write(phy->fields[POR_EN], 0x0);
+
if (ret)
- return ret;
+ return -EIO;
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2020-07-25 19:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-25 19:04 [PATCH 0/3] phy: ti: am654: improve PCIe enumeration performance Sekhar Nori
2020-07-25 19:04 ` [PATCH 1/3] phy: ti: am654: simplify regfield handling Sekhar Nori
2020-07-26 15:24 ` kernel test robot
2020-07-25 19:04 ` Sekhar Nori [this message]
2020-07-25 19:04 ` [PATCH 3/3] phy: ti: am654: update PCIe serdes config Sekhar Nori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200725190455.43500-3-nsekhar@ti.com \
--to=nsekhar@ti.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®