From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sander Vanheule <sander@svanheule.net>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH v1 1/1] regmap: mdio: Don't modify output if error happened
Date: Thu, 20 May 2021 15:05:18 +0300 [thread overview]
Message-ID: <20210520120518.30490-1-andriy.shevchenko@linux.intel.com> (raw)
regmap_mdio_read() breaks the principle of "no touch output till it's known
that the operation succeeds". Refactor it accordingly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap-mdio.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap-mdio.c b/drivers/base/regmap/regmap-mdio.c
index 5f18fe409f56..5ec208279913 100644
--- a/drivers/base/regmap/regmap-mdio.c
+++ b/drivers/base/regmap/regmap-mdio.c
@@ -11,9 +11,11 @@ static int regmap_mdio_read(void *context, unsigned int reg, unsigned int *val)
int ret;
ret = mdiobus_read(mdio_dev->bus, mdio_dev->addr, reg);
- *val = ret & 0xffff;
+ if (ret < 0)
+ return ret;
- return ret < 0 ? ret : 0;
+ *val = ret & 0xffff;
+ return 0;
}
static int regmap_mdio_write(void *context, unsigned int reg, unsigned int val)
--
2.30.2
next reply other threads:[~2021-05-20 12:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 12:05 Andy Shevchenko [this message]
2021-05-20 21:08 ` Mark Brown
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=20210520120518.30490-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sander@svanheule.net \
/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
Powered by JetHome