From: Tim Harvey <tharvey@gateworks.com>
To: u-boot@lists.denx.de, "Joe Hershberger" <joe.hershberger@ni.com>,
"Ramon Fried" <rfried.dev@gmail.com>,
"Vladimir Oltean" <vladimir.oltean@nxp.com>,
"Stefano Babic" <sbabic@denx.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP i . MX U-Boot Team" <uboot-imx@nxp.com>,
"Marek Behún" <marek.behun@nic.cz>
Cc: Tim Harvey <tharvey@gateworks.com>, Fabio Estevam <festevam@denx.de>
Subject: [PATCH v9 3/8] net: dsa: ensure dsa driver has proper ops
Date: Wed, 30 Nov 2022 09:42:46 -0800 [thread overview]
Message-ID: <20221130174251.82087-4-tharvey@gateworks.com> (raw)
In-Reply-To: <20221130174251.82087-1-tharvey@gateworks.com>
Add a function to sanity check a dsa driver having proper ops.
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Fabio Estevam <festevam@denx.de>
---
v9:
- no changes
v8:
- no changes
v7:
- no changes
v6:
- no changes
v5:
- added Fabio's rb tag
v4:
- no changes
v3:
- added Vladimir's rb tag
v2: new patch
---
net/dsa-uclass.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index 5759cedcbec3..211a991cdd0d 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -342,6 +342,19 @@ U_BOOT_DRIVER(dsa_port) = {
.plat_auto = sizeof(struct eth_pdata),
};
+static int dsa_sanitize_ops(struct udevice *dev)
+{
+ struct dsa_ops *ops = dsa_get_ops(dev);
+
+ if ((!ops->xmit || !ops->rcv) &&
+ (!ops->port_enable && !ops->port_disable)) {
+ dev_err(dev, "Packets cannot be steered to ports\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/*
* This function mostly deals with pulling information out of the device tree
* into the pdata structure.
@@ -358,6 +371,10 @@ static int dsa_post_bind(struct udevice *dev)
if (!ofnode_valid(node))
return -ENODEV;
+ err = dsa_sanitize_ops(dev);
+ if (err)
+ return err;
+
pdata->master_node = ofnode_null();
node = ofnode_find_subnode(node, "ports");
--
2.25.1
next prev parent reply other threads:[~2022-11-30 17:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 17:42 [PATCH v9 0/8] Add MV88E6xxx DSA driver and use on gwventana Tim Harvey
2022-11-30 17:42 ` [PATCH v9 1/8] net: mdio-uclass: scan for dm mdio children on post-bind Tim Harvey
2023-02-03 18:20 ` Tom Rini
2022-11-30 17:42 ` [PATCH v9 2/8] net: dsa: move cpu port probe to dsa_post_probe Tim Harvey
2022-11-30 17:42 ` Tim Harvey [this message]
2022-11-30 17:42 ` [PATCH v9 4/8] net: dsa: allow rcv() and xmit() to be optional Tim Harvey
2022-11-30 17:42 ` [PATCH v9 5/8] net: ksz9477: remove unnecessary xmit and recv functions Tim Harvey
2022-11-30 17:42 ` [PATCH v9 6/8] net: fec: add support for DM_MDIO Tim Harvey
2022-11-30 17:42 ` [PATCH v9 7/8] net: add MV88E6xxx DSA driver Tim Harvey
2022-11-30 17:42 ` [PATCH v9 8/8] board: gw_ventana: enable MV88E61XX DSA support Tim Harvey
2022-11-30 22:30 ` [PATCH v9 0/8] Add MV88E6xxx DSA driver and use on gwventana Vladimir Oltean
2022-11-30 23:27 ` Tim Harvey
2022-12-01 0:26 ` Vladimir Oltean
2023-01-25 17:26 ` Tim Harvey
2023-01-31 23:14 ` Tim Harvey
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=20221130174251.82087-4-tharvey@gateworks.com \
--to=tharvey@gateworks.com \
--cc=festevam@denx.de \
--cc=festevam@gmail.com \
--cc=joe.hershberger@ni.com \
--cc=marek.behun@nic.cz \
--cc=rfried.dev@gmail.com \
--cc=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.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