From: Aleksander Jan Bajkowski <olek2@wp.pl>
To: hauke@hauke-m.de, andrew@lunn.ch, vivien.didelot@gmail.com,
f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net,
kuba@kernel.org, linux@armlinux.org.uk, robh+dt@kernel.org,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Aleksander Jan Bajkowski <olek2@wp.pl>
Subject: [PATCH v4 2/3] net: dsa: lantiq: verify compatible strings against hardware
Date: Mon, 22 Mar 2021 21:37:16 +0100 [thread overview]
Message-ID: <20210322203717.20616-3-olek2@wp.pl> (raw)
In-Reply-To: <20210322203717.20616-1-olek2@wp.pl>
Verify compatible string against hardware.
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/net/dsa/lantiq_gswip.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 4cab5cd26928..26d0e3bb5dea 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1907,7 +1907,7 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
static int gswip_probe(struct platform_device *pdev)
{
struct gswip_priv *priv;
- struct device_node *mdio_np, *gphy_fw_np;
+ struct device_node *np, *mdio_np, *gphy_fw_np;
struct device *dev = &pdev->dev;
int err;
int i;
@@ -1944,6 +1944,24 @@ static int gswip_probe(struct platform_device *pdev)
priv->dev = dev;
version = gswip_switch_r(priv, GSWIP_VERSION);
+ np = dev->of_node;
+ switch (version) {
+ case GSWIP_VERSION_2_0:
+ case GSWIP_VERSION_2_1:
+ if (!of_device_is_compatible(np, "lantiq,xrx200-gswip"))
+ return -EINVAL;
+ break;
+ case GSWIP_VERSION_2_2:
+ case GSWIP_VERSION_2_2_ETC:
+ if (!of_device_is_compatible(np, "lantiq,xrx300-gswip") &&
+ !of_device_is_compatible(np, "lantiq,xrx330-gswip"))
+ return -EINVAL;
+ break;
+ default:
+ dev_err(dev, "unknown GSWIP version: 0x%x", version);
+ return -ENOENT;
+ }
+
/* bring up the mdio bus */
gphy_fw_np = of_get_compatible_child(dev->of_node, "lantiq,gphy-fw");
if (gphy_fw_np) {
--
2.20.1
next prev parent reply other threads:[~2021-03-22 20:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 20:37 [PATCH v4 0/3] net: dsa: lantiq: add support for xRX300 and xRX330 Aleksander Jan Bajkowski
2021-03-22 20:37 ` [PATCH v4 1/3] net: dsa: lantiq: allow to use all GPHYs on " Aleksander Jan Bajkowski
2021-03-22 20:37 ` Aleksander Jan Bajkowski [this message]
2021-03-22 20:37 ` [PATCH v4 3/3] dt-bindings: net: dsa: lantiq: add xRx300 and xRX330 switch bindings Aleksander Jan Bajkowski
2021-03-22 23:40 ` [PATCH v4 0/3] net: dsa: lantiq: add support for xRX300 and xRX330 patchwork-bot+netdevbpf
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=20210322203717.20616-3-olek2@wp.pl \
--to=olek2@wp.pl \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hauke@hauke-m.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=robh+dt@kernel.org \
--cc=vivien.didelot@gmail.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).