From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers
Date: Wed, 25 Jan 2023 08:53:53 +0100 [thread overview]
Message-ID: <20230125075354.1760273-1-a.fatoum@pengutronix.de> (raw)
We have drivers for both rtl8365mb and rtl8366rb and each uses a
different tagger. realtek-dsa didn't know that and caused a reference to
an unavailable symbol when one of them was disabled. Add IS_ENABLED()
guards to fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/net/realtek-dsa/tagger.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/net/realtek-dsa/tagger.c b/drivers/net/realtek-dsa/tagger.c
index 1d4461aebcb8..3a41f3b3c1b4 100644
--- a/drivers/net/realtek-dsa/tagger.c
+++ b/drivers/net/realtek-dsa/tagger.c
@@ -4,7 +4,7 @@
int realtek_dsa_init_tagger(struct realtek_priv *priv)
{
- const struct dsa_device_ops *tagger_ops;
+ const struct dsa_device_ops *tagger_ops = NULL;
struct dsa_switch_ops *ops;
/* TODO: Tagging can be configured per port in Linux. barebox DSA core
@@ -14,18 +14,24 @@ int realtek_dsa_init_tagger(struct realtek_priv *priv)
*/
switch (priv->ops->get_tag_protocol(priv)) {
case DSA_TAG_PROTO_RTL4_A:
- tagger_ops = &rtl4a_netdev_ops;
+ if (IS_ENABLED(CONFIG_NET_DSA_TAG_RTL4_A))
+ tagger_ops = &rtl4a_netdev_ops;
break;
case DSA_TAG_PROTO_RTL8_4:
- tagger_ops = &rtl8_4_netdev_ops;
+ if (IS_ENABLED(CONFIG_NET_DSA_TAG_RTL8_4))
+ tagger_ops = &rtl8_4_netdev_ops;
break;
case DSA_TAG_PROTO_RTL8_4T:
- tagger_ops = &rtl8_4t_netdev_ops;
+ if (IS_ENABLED(CONFIG_NET_DSA_TAG_RTL8_4))
+ tagger_ops = &rtl8_4t_netdev_ops;
break;
default:
- return -EINVAL;
+ break;
}
+ if (!tagger_ops)
+ return -EINVAL;
+
ops = memdup(priv->ds->ops, sizeof(*priv->ds->ops));
ops->xmit = tagger_ops->xmit;
ops->rcv = tagger_ops->rcv;
--
2.30.2
next reply other threads:[~2023-01-25 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 7:53 Ahmad Fatoum [this message]
2023-01-25 7:53 ` [PATCH master 2/2] net: dsa: ksz8873: fix mismatched return value Ahmad Fatoum
2023-01-25 8:33 ` [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers Sascha Hauer
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=20230125075354.1760273-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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