mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers
@ 2023-01-25  7:53 Ahmad Fatoum
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-25  7:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master 2/2] net: dsa: ksz8873: fix mismatched return value
  2023-01-25  7:53 [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers Ahmad Fatoum
@ 2023-01-25  7:53 ` Ahmad Fatoum
  2023-01-25  8:33 ` [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-25  7:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Both read and write operations for the regmap are supposed to return an
int, not a ssize_t and build warns about this. Fix it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/ksz8873.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ksz8873.c b/drivers/net/ksz8873.c
index 3e3ad2413e9a..1df8d6dd924a 100644
--- a/drivers/net/ksz8873.c
+++ b/drivers/net/ksz8873.c
@@ -96,7 +96,7 @@ static int ksz8873_mdio_read(void *ctx, unsigned int reg, unsigned int *val)
 	return 0;
 }
 
-static ssize_t ksz8873_mdio_write(void *ctx, unsigned int reg, unsigned int val)
+static int ksz8873_mdio_write(void *ctx, unsigned int reg, unsigned int val)
 {
 	struct ksz8873_switch *priv = ctx;
 	struct phy_device *mdiodev = priv->mdiodev;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers
  2023-01-25  7:53 [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers Ahmad Fatoum
  2023-01-25  7:53 ` [PATCH master 2/2] net: dsa: ksz8873: fix mismatched return value Ahmad Fatoum
@ 2023-01-25  8:33 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-01-25  8:33 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Jan 25, 2023 at 08:53:53AM +0100, Ahmad Fatoum wrote:
> 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(-)

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-25  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25  7:53 [PATCH master 1/2] net: dsa: realtek: support enabling only one of the drivers Ahmad Fatoum
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox