Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Yang <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v6 3/3] net: dsa: motorcomm: Add LED support
Date: Tue, 21 Jul 2026 10:32:28 -0700	[thread overview]
Message-ID: <20260721103228.0a90ace6@kernel.org> (raw)
In-Reply-To: <20260709014812.1158178-4-mmyangfl@gmail.com>

On Thu,  9 Jul 2026 09:47:47 +0800 David Yang wrote:
> LEDs can be described in the device tree using the same format as qca8k.
> Each port can configure up to 3 LEDs.
> 
> Currently, only parallel mode and strict 1:1 mapping are supported.

> +config NET_DSA_YT921X_LEDS
> +	bool "LED support for Motorcomm YT9215"
> +	default y
> +	depends on NET_DSA_YT921X
> +	depends on LEDS_CLASS=y || LEDS_CLASS=NET_DSA_YT921X

is it really useful to prompt the user with this option?
Shouldn't this be a hidden option which gets auto-enabled
when dependencies are met?

> +static bool
> +yt921x_led_trigger_is_supported(const struct yt921x_priv *priv, int port,
> +				int group, unsigned long flags)
> +{
> +	if (!flags)
> +		return true;
> +
> +	for (unsigned int i = 0; i < ARRAY_SIZE(yt921x_led_trigger_maps); i++) {
> +		const struct yt921x_led_trigger_map *map = &yt921x_led_trigger_maps[i];
> +
> +		if ((flags & map->flags) == map->flags) {
> +			flags &= ~map->flags;
> +			if (!flags)
> +				return true;
> +		}

Isn't this conditions simply:

		if (flags == map->flags)
			return true;

?

> +	}
> +
> +	return false;


> +#if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
> +
> +void yt921x_leds_remove(struct yt921x_priv *priv);
> +int yt921x_leds_setup(struct yt921x_priv *priv);
> +
> +#else
> +
> +static inline void yt921x_leds_remove(struct yt921x_priv *priv) {}
> +
> +static inline int yt921x_leds_setup(struct yt921x_priv *priv)
> +{
> +	return 0;
> +}

There are static inlines but I think you still protect the calls to
these functions with itdef?

+#if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
+	res = yt921x_leds_setup(priv);
+	if (res)
+		dev_warn(dev, "Failed to setup LEDs: %d\n", res);
+#endif

> +#endif
> +
> +#endif


  reply	other threads:[~2026-07-21 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  1:47 [PATCH net-next v6 0/3] net: dsa: motorcomm: Add LED support David Yang
2026-07-09  1:47 ` [PATCH net-next v6 1/3] net: dsa: motorcomm: Move to subdirectory David Yang
2026-07-09  1:47 ` [PATCH net-next v6 2/3] net: dsa: motorcomm: Split SMI module David Yang
2026-07-09  1:47 ` [PATCH net-next v6 3/3] net: dsa: motorcomm: Add LED support David Yang
2026-07-21 17:32   ` Jakub Kicinski [this message]
2026-07-22  3:11     ` David Yang
2026-07-21 17:32   ` Jakub Kicinski

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=20260721103228.0a90ace6@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --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