public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Russell King <linux@armlinux.org.uk>,
	Gregory Clement <gregory.clement@bootlin.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 6/7] dsa: mv88e6xxx: Create port/netdev LEDs
Date: Tue, 2 Apr 2024 14:03:55 +0300	[thread overview]
Message-ID: <20240402110355.oruwspikc2u56qzh@skbuf> (raw)
In-Reply-To: <20240401-v6-8-0-net-next-mv88e6xxx-leds-v4-v3-6-221b3fa55f78@lunn.ch> <20240401-v6-8-0-net-next-mv88e6xxx-leds-v4-v3-6-221b3fa55f78@lunn.ch>

On Mon, Apr 01, 2024 at 08:35:51AM -0500, Andrew Lunn wrote:
> @@ -4006,6 +4106,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
>  
>  static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
>  {
> +	struct dsa_port *dp = dsa_to_port(ds, port);
>  	struct mv88e6xxx_chip *chip = ds->priv;
>  	int err;
>  
> @@ -4016,13 +4117,26 @@ static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
>  			return err;
>  	}
>  
> -	return mv88e6xxx_setup_devlink_regions_port(ds, port);
> +	err  = mv88e6xxx_setup_devlink_regions_port(ds, port);
> +	if (err)
> +		return err;
> +
> +	if (dp->dn) {
> +		err = netdev_leds_setup(dp->user, dp->dn, &chip->leds,
> +					&mv88e6xxx_netdev_leds_ops, 2);

This (dereferencing dp->user regardless of dp->type) is a dangerous
thing to do. Let alone the fact that dp->user is NULL for DSA ports. It
is actually in a union with struct net_device *conduit, for CPU ports.
So you're also setting up LEDs for the conduit interface here...

Please make it conditional on dsa_port_is_user(), and same for teardown.

> +		if (err)
> +			mv88e6xxx_teardown_devlink_regions_port(ds, port);
> +	}
> +	return err;
>  }
>  
>  static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
>  {
> +	struct dsa_port *dp = dsa_to_port(ds, port);
>  	struct mv88e6xxx_chip *chip = ds->priv;
>  
> +	netdev_leds_teardown(&chip->leds, dp->user);
> +
>  	mv88e6xxx_teardown_devlink_regions_port(ds, port);
>  
>  	if (chip->info->ops->pcs_ops &&
> @@ -6397,6 +6511,7 @@ static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
>  	INIT_LIST_HEAD(&chip->mdios);
>  	idr_init(&chip->policies);
>  	INIT_LIST_HEAD(&chip->msts);
> +	INIT_LIST_HEAD(&chip->leds);
>  
>  	return chip;
>  }
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
> index 64f8bde68ccf..b70e74203b31 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.h
> +++ b/drivers/net/dsa/mv88e6xxx/chip.h
> @@ -432,6 +432,9 @@ struct mv88e6xxx_chip {
>  
>  	/* Bridge MST to SID mappings */
>  	struct list_head msts;
> +
> +	/* LEDs associated to the ports */
> +	struct list_head leds;
>  };
>  
>  struct mv88e6xxx_bus_ops {
> @@ -668,6 +671,15 @@ struct mv88e6xxx_ops {
>  	int (*led_blink_set)(struct mv88e6xxx_chip *chip, int port, u8 led,
>  			     unsigned long *delay_on,
>  			     unsigned long *delay_off);
> +	int (*led_hw_control_is_supported)(struct mv88e6xxx_chip *chip,
> +					   int port, u8 led,
> +					   unsigned long flags);
> +	int (*led_hw_control_set)(struct mv88e6xxx_chip *chip,
> +				  int port, u8 led,
> +				  unsigned long flags);
> +	int (*led_hw_control_get)(struct mv88e6xxx_chip *chip,
> +				  int port, u8 led,
> +				  unsigned long *flags);
>  };
>  
>  struct mv88e6xxx_irq_ops {
> 
> -- 
> 2.43.0
> 


  reply	other threads:[~2024-04-02 11:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 13:35 [PATCH net-next v3 0/7] net: Add generic support for netdev LEDs Andrew Lunn
2024-04-01 13:35 ` [PATCH net-next v3 1/7] dsa: move call to driver port_setup after creation of netdev Andrew Lunn
2024-04-01 15:53   ` Vladimir Oltean
2024-04-01 13:35 ` [PATCH net-next v3 2/7] net: Add helpers for netdev LEDs Andrew Lunn
2024-04-02  9:53   ` Vladimir Oltean
2024-04-03 23:43     ` Andrew Lunn
2024-04-01 13:35 ` [PATCH net-next v3 3/7] net: dsa: mv88e6xxx: Add helpers for 6352 LED blink and brightness Andrew Lunn
2024-04-01 13:35 ` [PATCH net-next v3 4/7] net: dsa: mv88e6xxx: Tie the low level LED functions to device ops Andrew Lunn
2024-04-01 13:35 ` [PATCH net-next v3 5/7] net: dsa: Add helpers to convert netdev to ds or port index Andrew Lunn
2024-04-02 10:56   ` Vladimir Oltean
2024-04-02 13:31     ` Russell King (Oracle)
2024-04-02 20:51       ` Vladimir Oltean
2024-04-01 13:35 ` [PATCH net-next v3 6/7] dsa: mv88e6xxx: Create port/netdev LEDs Andrew Lunn
2024-04-02 11:03   ` Vladimir Oltean [this message]
2024-04-01 13:35 ` [PATCH net-next v3 7/7] arm: boot: dts: mvebu: linksys-mamba: Add Ethernet LEDs Andrew Lunn

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=20240402110355.oruwspikc2u56qzh@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.clement@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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