Re: [PATCH v4 1/2] leds: trigger: netdev: display only supported link speed attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 19 Dec 2023 17:53:52 +0100
Christian Marangi <ansuelsmth@xxxxxxxxx> 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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux