linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Subject: [PATCH v5 net-next v5 12/14] net: dsa: mv88e6xxx: pass compatible info
Date: Mon, 20 Jun 2016 13:14:09 -0400	[thread overview]
Message-ID: <20160620171411.13746-13-vivien.didelot@savoirfairelinux.com> (raw)
In-Reply-To: <20160620171411.13746-1-vivien.didelot@savoirfairelinux.com>

After allocating the chip structure, pass it a compatible info pointer.

The compatible info structure will be used later to describe how to
access the switch registers and where to read the switch ID.

For the standard MDIO probe, get it from the device node data. For the
legacy DSA driver probing, pass it the 88E6085 info.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index de92add..cadd1e3 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/mdio.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/of_mdio.h>
 #include <linux/netdevice.h>
 #include <linux/gpio/consumer.h>
@@ -3617,6 +3618,7 @@ static int mv88e6xxx_detect(struct mv88e6xxx_priv_state *ps)
 	if (!info)
 		return -ENODEV;
 
+	/* Update the compatible info with the probed one */
 	ps->info = info;
 
 	dev_info(ps->dev, "switch 0x%x detected: %s, revision %u\n",
@@ -3669,6 +3671,9 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
 	if (!ps)
 		return NULL;
 
+	/* Legacy SMI probing will only support chips similar to 88E6085 */
+	ps->info = &mv88e6xxx_table[MV88E6085];
+
 	err = mv88e6xxx_smi_init(ps, bus, sw_addr);
 	if (err)
 		goto free;
@@ -3754,14 +3759,21 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 {
 	struct device *dev = &mdiodev->dev;
 	struct device_node *np = dev->of_node;
+	const struct mv88e6xxx_info *compat_info;
 	struct mv88e6xxx_priv_state *ps;
 	u32 eeprom_len;
 	int err;
 
+	compat_info = of_device_get_match_data(dev);
+	if (!compat_info)
+		return -EINVAL;
+
 	ps = mv88e6xxx_alloc_chip(dev);
 	if (!ps)
 		return -ENOMEM;
 
+	ps->info = compat_info;
+
 	err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr);
 	if (err)
 		return err;
@@ -3801,7 +3813,10 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
 }
 
 static const struct of_device_id mv88e6xxx_of_match[] = {
-	{ .compatible = "marvell,mv88e6085" },
+	{
+		.compatible = "marvell,mv88e6085",
+		.data = &mv88e6xxx_table[MV88E6085],
+	},
 	{ /* sentinel */ },
 };
 
-- 
2.9.0

  parent reply	other threads:[~2016-06-20 17:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 17:13 [PATCH v5 net-next v5 00/14] net: dsa: mv88e6xxx: probe compatible Vivien Didelot
2016-06-20 17:13 ` [PATCH v5 net-next v5 01/14] net: dsa: mv88e6xxx: fix style issues Vivien Didelot
2016-06-20 17:13 ` [PATCH v5 net-next v5 02/14] net: dsa: mv88e6xxx: remove redundant assignments Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 03/14] net: dsa: mv88e6xxx: use already declared variables Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 04/14] net: dsa: mv88e6xxx: do not increment bus refcount Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 05/14] net: dsa: mv88e6xxx: add switch register helpers Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 06/14] net: dsa: mv88e6xxx: use gpio get optional variant Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 07/14] net: dsa: mv88e6xxx: remove table args in info lookup Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 08/14] net: dsa: mv88e6xxx: rename smi_mutex to reg_lock Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 09/14] net: dsa: mv88e6xxx: add chip allocation helper Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 10/14] net: dsa: mv88e6xxx: add SMI init helper Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 11/14] net: dsa: mv88e6xxx: add detection helper Vivien Didelot
2016-06-20 17:14 ` Vivien Didelot [this message]
2016-06-20 17:14 ` [PATCH v5 net-next v5 13/14] net: dsa: mv88e6xxx: add port base address to info Vivien Didelot
2016-06-20 17:14 ` [PATCH v5 net-next v5 14/14] net: dsa: mv88e6xxx: abstract switch registers accesses Vivien Didelot
2016-06-21  8:05 ` [PATCH v5 net-next v5 00/14] net: dsa: mv88e6xxx: probe compatible David Miller

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=20160620171411.13746-13-vivien.didelot@savoirfairelinux.com \
    --to=vivien.didelot@savoirfairelinux.com \
    --cc=andrew@lunn.ch \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.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).