Linux-LEDs Archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	Daniel Golle <daniel@makrotopia.org>,
	"David S. Miller" <davem@davemloft.net>,
	Li Zetao <lizetao1@huawei.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v4 1/2] leds: trigger: netdev: display only supported link speed attribute
Date: Wed, 20 Dec 2023 17:20:25 +0100	[thread overview]
Message-ID: <20231220172025.3b9c452b@dellmb> (raw)
In-Reply-To: <20231219165353.23233-1-ansuelsmth@gmail.com>

On Tue, 19 Dec 2023 17:53:52 +0100
Christian Marangi <ansuelsmth@gmail.com> wrote:

> +	for_each_set_bit(mode, supported_link_modes, __ETHTOOL_LINK_MODE_MASK_NBITS) {
> +		struct ethtool_link_ksettings link_ksettings;
> +
> +		ethtool_params_from_link_mode(&link_ksettings, mode);
> +
> +		if (attr == &dev_attr_link_10.attr &&
> +		    link_ksettings.base.speed == SPEED_10)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_100.attr &&
> +		    link_ksettings.base.speed == SPEED_100)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_1000.attr &&
> +		    link_ksettings.base.speed == SPEED_1000)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_2500.attr &&
> +		    link_ksettings.base.speed == SPEED_2500)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_5000.attr &&
> +		    link_ksettings.base.speed == SPEED_5000)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_10000.attr &&
> +		    link_ksettings.base.speed == SPEED_10000)
> +			return attr->mode;

Hi Christian,

ugly code repetition. Use a macro or a switch or something.

Marek

      parent reply	other threads:[~2023-12-20 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-19 16:53 [PATCH v4 1/2] leds: trigger: netdev: display only supported link speed attribute Christian Marangi
2023-12-19 16:53 ` [PATCH v4 2/2] docs: ABI: sysfs-class-led-trigger-netdev: Document now hidable link_* Christian Marangi
2023-12-20 16:20 ` Marek Behún [this message]

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=20231220172025.3b9c452b@dellmb \
    --to=kabel@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=lizetao1@huawei.com \
    --cc=pavel@ucw.cz \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).