linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Mark Brown <broonie@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Adrew Lunn <andrew@lunn.ch>,
	Sander Vanheule <sander@svanheule.net>
Subject: [PATCH 1/2] Revert "regmap: mdio: Add clause-45 support"
Date: Wed,  9 Jun 2021 13:46:05 +0200	[thread overview]
Message-ID: <deed937f8fd63285e95acdfa8ca327638057811f.1623238313.git.sander@svanheule.net> (raw)
In-Reply-To: <cover.1623238313.git.sander@svanheule.net>

This reverts commit f083be9db060fbac09123d80bdffb2c001ac0e2b.

There are currently no (planned) regmap users for C45 register access.
Remove support for now, to reduce dead code.

Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
 drivers/base/regmap/regmap-mdio.c | 70 +++++++------------------------
 1 file changed, 14 insertions(+), 56 deletions(-)

diff --git a/drivers/base/regmap/regmap-mdio.c b/drivers/base/regmap/regmap-mdio.c
index cfb23afb19eb..aee34bf2400e 100644
--- a/drivers/base/regmap/regmap-mdio.c
+++ b/drivers/base/regmap/regmap-mdio.c
@@ -7,14 +7,13 @@
 
 #define REGVAL_MASK		GENMASK(15, 0)
 #define REGNUM_C22_MASK		GENMASK(4, 0)
-/* Clause-45 mask includes the device type (5 bit) and actual register number (16 bit) */
-#define REGNUM_C45_MASK		GENMASK(20, 0)
 
-static int regmap_mdio_read(struct mdio_device *mdio_dev, u32 reg, unsigned int *val)
+static int regmap_mdio_read(void *context, unsigned int reg, unsigned int *val)
 {
+	struct mdio_device *mdio_dev = context;
 	int ret;
 
-	ret = mdiobus_read(mdio_dev->bus, mdio_dev->addr, reg);
+	ret = mdiobus_read(mdio_dev->bus, mdio_dev->addr, reg & REGNUM_C22_MASK);
 	if (ret < 0)
 		return ret;
 
@@ -22,63 +21,27 @@ static int regmap_mdio_read(struct mdio_device *mdio_dev, u32 reg, unsigned int
 	return 0;
 }
 
-static int regmap_mdio_write(struct mdio_device *mdio_dev, u32 reg, unsigned int val)
-{
-	return mdiobus_write(mdio_dev->bus, mdio_dev->addr, reg, val);
-}
-
-static int regmap_mdio_c22_read(void *context, unsigned int reg, unsigned int *val)
-{
-	struct mdio_device *mdio_dev = context;
-
-	return regmap_mdio_read(mdio_dev, reg & REGNUM_C22_MASK, val);
-}
-
-static int regmap_mdio_c22_write(void *context, unsigned int reg, unsigned int val)
+static int regmap_mdio_write(void *context, unsigned int reg, unsigned int val)
 {
 	struct mdio_device *mdio_dev = context;
 
-	return regmap_mdio_write(mdio_dev, reg & REGNUM_C22_MASK, val);
+	return mdiobus_write(mdio_dev->bus, mdio_dev->addr, reg & REGNUM_C22_MASK, val);
 }
 
-static const struct regmap_bus regmap_mdio_c22_bus = {
-	.reg_write = regmap_mdio_c22_write,
-	.reg_read = regmap_mdio_c22_read,
-};
-
-static int regmap_mdio_c45_read(void *context, unsigned int reg, unsigned int *val)
-{
-	struct mdio_device *mdio_dev = context;
-
-	return regmap_mdio_read(mdio_dev, MII_ADDR_C45 | (reg & REGNUM_C45_MASK), val);
-}
-
-static int regmap_mdio_c45_write(void *context, unsigned int reg, unsigned int val)
-{
-	struct mdio_device *mdio_dev = context;
-
-	return regmap_mdio_write(mdio_dev, MII_ADDR_C45 | (reg & REGNUM_C45_MASK), val);
-}
-
-static const struct regmap_bus regmap_mdio_c45_bus = {
-	.reg_write = regmap_mdio_c45_write,
-	.reg_read = regmap_mdio_c45_read,
+static const struct regmap_bus regmap_mdio_bus = {
+	.reg_write = regmap_mdio_write,
+	.reg_read = regmap_mdio_read,
 };
 
 struct regmap *__regmap_init_mdio(struct mdio_device *mdio_dev,
 	const struct regmap_config *config, struct lock_class_key *lock_key,
 	const char *lock_name)
 {
-	struct regmap_bus *bus;
-
-	if (config->reg_bits == 5 && config->val_bits == 16)
-		bus = &regmap_mdio_c22_bus;
-	else if (config->reg_bits == 21 && config->val_bits == 16)
-		bus = &regmap_mdio_c45_bus;
-	else
+	if (config->reg_bits != 5 || config->val_bits != 16)
 		return ERR_PTR(-EOPNOTSUPP);
 
-	return __regmap_init(&mdio_dev->dev, bus, mdio_dev, config, lock_key, lock_name);
+	return __regmap_init(&mdio_dev->dev, &regmap_mdio_bus, mdio_dev, config,
+		lock_key, lock_name);
 }
 EXPORT_SYMBOL_GPL(__regmap_init_mdio);
 
@@ -86,16 +49,11 @@ struct regmap *__devm_regmap_init_mdio(struct mdio_device *mdio_dev,
 	const struct regmap_config *config, struct lock_class_key *lock_key,
 	const char *lock_name)
 {
-	const struct regmap_bus *bus;
-
-	if (config->reg_bits == 5 && config->val_bits == 16)
-		bus = &regmap_mdio_c22_bus;
-	else if (config->reg_bits == 21 && config->val_bits == 16)
-		bus = &regmap_mdio_c45_bus;
-	else
+	if (config->reg_bits != 5 || config->val_bits != 16)
 		return ERR_PTR(-EOPNOTSUPP);
 
-	return __devm_regmap_init(&mdio_dev->dev, bus, mdio_dev, config, lock_key, lock_name);
+	return __devm_regmap_init(&mdio_dev->dev, &regmap_mdio_bus, mdio_dev,
+		config, lock_key, lock_name);
 }
 EXPORT_SYMBOL_GPL(__devm_regmap_init_mdio);
 
-- 
2.31.1


  reply	other threads:[~2021-06-09 11:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 11:46 [PATCH 0/2] Clause-22/Clause-45 MDIO regmap support fixups Sander Vanheule
2021-06-09 11:46 ` Sander Vanheule [this message]
2021-06-09 12:24   ` [PATCH 1/2] Revert "regmap: mdio: Add clause-45 support" Mark Brown
2021-06-09 12:42     ` Sander Vanheule
2021-06-09 13:23       ` Mark Brown
2021-06-09 11:46 ` [PATCH 2/2] regmap: mdio: Reject invalid clause-22 addresses Sander Vanheule

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=deed937f8fd63285e95acdfa8ca327638057811f.1623238313.git.sander@svanheule.net \
    --to=sander@svanheule.net \
    --cc=andrew@lunn.ch \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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;
as well as URLs for NNTP newsgroup(s).