netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: jakub.kicinski@netronome.com, davem@davemloft.net,
	alexandre.belloni@bootlin.com
Cc: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com,
	joergen.andreasen@microchip.com, allan.nielsen@microchip.com,
	horatiu.vultur@microchip.com, claudiu.manoil@nxp.com,
	netdev@vger.kernel.org, Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [PATCH net-next 01/12] net: mscc: ocelot: move resource ioremap and regmap init to common code
Date: Tue, 12 Nov 2019 14:44:09 +0200	[thread overview]
Message-ID: <20191112124420.6225-2-olteanv@gmail.com> (raw)
In-Reply-To: <20191112124420.6225-1-olteanv@gmail.com>

From: Claudiu Manoil <claudiu.manoil@nxp.com>

Let's make this ioremap and regmap init code common.  It should not
be platform dependent as it should be usable by PCI devices too.
Use better names where necessary to avoid clashes.

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot.h       |  4 +---
 drivers/net/ethernet/mscc/ocelot_board.c | 17 ++++++++++-------
 drivers/net/ethernet/mscc/ocelot_io.c    | 14 +++++---------
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h
index 4d8e769ccad9..b5802cea7cc4 100644
--- a/drivers/net/ethernet/mscc/ocelot.h
+++ b/drivers/net/ethernet/mscc/ocelot.h
@@ -546,9 +546,7 @@ void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
 
 int ocelot_regfields_init(struct ocelot *ocelot,
 			  const struct reg_field *const regfields);
-struct regmap *ocelot_io_platform_init(struct ocelot *ocelot,
-				       struct platform_device *pdev,
-				       const char *name);
+struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
 
 #define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
 #define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 811599f32910..ddb34f17fa52 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -268,7 +268,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		enum ocelot_target id;
 		char *name;
 		u8 optional:1;
-	} res[] = {
+	} io_target[] = {
 		{ SYS, "sys" },
 		{ REW, "rew" },
 		{ QSYS, "qsys" },
@@ -288,20 +288,23 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ocelot);
 	ocelot->dev = &pdev->dev;
 
-	for (i = 0; i < ARRAY_SIZE(res); i++) {
+	for (i = 0; i < ARRAY_SIZE(io_target); i++) {
 		struct regmap *target;
+		struct resource *res;
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						   io_target[i].name);
 
-		target = ocelot_io_platform_init(ocelot, pdev, res[i].name);
+		target = ocelot_regmap_init(ocelot, res);
 		if (IS_ERR(target)) {
-			if (res[i].optional) {
-				ocelot->targets[res[i].id] = NULL;
+			if (io_target[i].optional) {
+				ocelot->targets[io_target[i].id] = NULL;
 				continue;
 			}
-
 			return PTR_ERR(target);
 		}
 
-		ocelot->targets[res[i].id] = target;
+		ocelot->targets[io_target[i].id] = target;
 	}
 
 	hsio = syscon_regmap_lookup_by_compatible("mscc,ocelot-hsio");
diff --git a/drivers/net/ethernet/mscc/ocelot_io.c b/drivers/net/ethernet/mscc/ocelot_io.c
index c6db8ad31fdf..b229b1cb68ef 100644
--- a/drivers/net/ethernet/mscc/ocelot_io.c
+++ b/drivers/net/ethernet/mscc/ocelot_io.c
@@ -97,20 +97,16 @@ static struct regmap_config ocelot_regmap_config = {
 	.reg_stride	= 4,
 };
 
-struct regmap *ocelot_io_platform_init(struct ocelot *ocelot,
-				       struct platform_device *pdev,
-				       const char *name)
+struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res)
 {
-	struct resource *res;
 	void __iomem *regs;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
 	regs = devm_ioremap_resource(ocelot->dev, res);
 	if (IS_ERR(regs))
 		return ERR_CAST(regs);
 
-	ocelot_regmap_config.name = name;
-	return devm_regmap_init_mmio(ocelot->dev, regs,
-				     &ocelot_regmap_config);
+	ocelot_regmap_config.name = res->name;
+
+	return devm_regmap_init_mmio(ocelot->dev, regs, &ocelot_regmap_config);
 }
-EXPORT_SYMBOL(ocelot_io_platform_init);
+EXPORT_SYMBOL(ocelot_regmap_init);
-- 
2.17.1


  reply	other threads:[~2019-11-12 12:44 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 12:44 [PATCH net-next 00/12] DSA driver for Vitesse Felix switch Vladimir Oltean
2019-11-12 12:44 ` Vladimir Oltean [this message]
2019-11-12 12:44 ` [PATCH net-next 02/12] net: mscc: ocelot: filter out ocelot SoC specific PCS config from common path Vladimir Oltean
2019-11-12 13:31   ` Andrew Lunn
2019-11-12 21:28   ` Florian Fainelli
2019-11-13  9:40   ` kbuild test robot
2019-11-12 12:44 ` [PATCH net-next 03/12] net: mscc: ocelot: move invariant configs out of adjust_link Vladimir Oltean
2019-11-12 13:35   ` Andrew Lunn
2019-11-12 13:38     ` Vladimir Oltean
2019-11-12 21:30   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 04/12] net: mscc: ocelot: create a helper for changing the port MTU Vladimir Oltean
2019-11-12 13:39   ` Andrew Lunn
2019-11-12 13:41     ` Vladimir Oltean
2019-11-12 21:31   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 05/12] net: mscc: ocelot: export a constant for the tag length in bytes Vladimir Oltean
2019-11-12 13:44   ` Andrew Lunn
2019-11-12 21:32   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 06/12] net: mscc: ocelot: adjust MTU on the CPU port in NPI mode Vladimir Oltean
2019-11-12 13:51   ` Andrew Lunn
2019-11-12 13:52     ` Vladimir Oltean
2019-11-12 13:57       ` Andrew Lunn
2019-11-12 21:32   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 07/12] net: mscc: ocelot: separate the implementation of switch reset Vladimir Oltean
2019-11-12 13:55   ` Andrew Lunn
2019-11-12 13:59     ` Vladimir Oltean
2019-11-13  8:57       ` Alexandre Belloni
2019-11-12 21:34   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 08/12] net: mscc: ocelot: publish structure definitions to include/soc/mscc/ocelot.h Vladimir Oltean
2019-11-12 14:42   ` Andrew Lunn
2019-11-12 16:18     ` Vladimir Oltean
2019-11-12 21:36   ` Florian Fainelli
2019-11-13 12:48   ` kbuild test robot
2019-11-12 12:44 ` [PATCH net-next 09/12] net: mscc: ocelot: publish ocelot_sys.h to include/soc/mscc Vladimir Oltean
2019-11-12 21:38   ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 10/12] net: dsa: vitesse: move vsc73xx driver to a separate folder Vladimir Oltean
2019-11-12 13:09   ` Alexandre Belloni
2019-11-12 13:40     ` Vladimir Oltean
2019-11-12 14:33       ` Allan W. Nielsen
2019-11-12 14:50         ` Andrew Lunn
2019-11-12 14:57           ` Allan W. Nielsen
2019-11-12 15:26             ` Vladimir Oltean
2019-11-12 19:09               ` Allan W. Nielsen
2019-11-12 19:26                 ` Vladimir Oltean
2019-11-12 19:48                   ` Allan W. Nielsen
2019-11-12 20:01                     ` Vladimir Oltean
2019-11-13  7:38                       ` Allan W. Nielsen
2019-11-13  8:47                         ` Alexandre Belloni
2019-11-12 21:49           ` Florian Fainelli
2019-11-12 12:44 ` [PATCH net-next 11/12] net: dsa: vitesse: add basic Felix switch driver Vladimir Oltean
2019-11-12 12:44 ` [PATCH net-next 12/12] net: dsa: vitesse: add tagger for Ocelot/Felix switches Vladimir Oltean
2019-11-12 21:48   ` Florian Fainelli
2019-11-13  2:14   ` Andrew Lunn

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=20191112124420.6225-2-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=joergen.andreasen@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    /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).