Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp156263rdb; Wed, 20 Dec 2023 08:40:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUOMajlVmI5P607YfRvzIQXoUKzJ+3FXpv9hJHvBRl+iQNnkDpiIEbB4APfnMQ6hdXOJyz X-Received: by 2002:a17:903:451:b0:1d3:ee66:6a93 with SMTP id iw17-20020a170903045100b001d3ee666a93mr807245plb.91.1703090423662; Wed, 20 Dec 2023 08:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703090423; cv=none; d=google.com; s=arc-20160816; b=nZlSLiE3GGC4eCbLOnfXpmiZi08IAW6/8cpZD6o6ByBiTAgjcqO2VJwS3150rNG3YO JRbtpG4mHIn1IXXZBsN5FvGX/+y2VTzURxJwuhyYYOgEaIRm6gQ8GfUG7ghxxb21Qpkf j37ny/cfTtlfm+yd2bbrVCndkVBMn/E7ANegv6DbDvtSdHXUElN4HG+CyAFr+GIHdUeK +XhHw1bDX2frf5yPHD333/HI8U6MVCiQvc8dwNcLIFp88sn7iIbHqjjFQ4RSBcipkfGh /x0G4p9a08uQ6OlfP3Da0iAGcFrMvaFXqsXJLHPslIV1xXkcn7Pjmvai9CACNR2eLFsZ AkjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=7tpoHabMDXHaD9Fh2h8YSajjkC2O8IZrbx6D5tFsy4g=; fh=9MntKrF4XOokBA69GqF+Flah4tGU03whyNMNxmYzl60=; b=yS+LX96+38//0kzhXJjeFLqqH7UPqAsG/5arTGFvzyZfiAPNFxae7OjtikeUasIVEs c6E2mPbJFDkjeZcvZ8pe5o2iuOaanHPkcsji+HMHHNq2xywO5LJs8BQMbXVBaujlM9cx oy0sRyiRt4GV8ZdWfah+6noiGxJh4XcsdrI9q4Qo7yT+0/O5KWtoFkXLvRxLeWO3H0kB B7Ou1hoCCmXvhrKTIrR+AK7+wL6UNEOW/4+r2/AqwKw8R6Pdg+eHM1pKb4aqMooxXf1m vhucuQo8LqyuwJmfjPSWMQ9Wcx1CebDv7lwDGaX0FWPTgat0KHjWbCqtc+wbQteWhZ31 ZN0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NlffhOCJ; spf=pass (google.com: domain of linux-kernel+bounces-7283-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k10-20020a170902c40a00b001d37bc66954si11123373plk.24.2023.12.20.08.40.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7283-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NlffhOCJ; spf=pass (google.com: domain of linux-kernel+bounces-7283-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E222EB249FB for ; Wed, 20 Dec 2023 16:24:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAACF4B15F; Wed, 20 Dec 2023 16:20:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NlffhOCJ" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C264482F7; Wed, 20 Dec 2023 16:20:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DBC9C433C8; Wed, 20 Dec 2023 16:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703089232; bh=XVgd7pqYNT+knJLpFJ5VDLSw1dPBnwpebcm4HpkJ8yQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NlffhOCJ1UyfI+WZlEScRu+W0FpBZpCOJutilYVtmDMnQM1SUCDQWrom7mdcLTN2C xzavSclOmhmxZGL4IWQ8ZF9qjqBsAsJBj7Y6fdMEBqFF7HH7ITrhwei88JIFCIf4X5 vWzFZ6NJm8blBrsml3RNc6tpZfCqhk0wa0Jhhac//IgP7apWRYSVJ1Bpk6BXpVQUiL eY2i9NXO494PrP21ejfBr7KYvLeCuQRenGVx2zr4IByU/k9Fx5Oo42PUOhmkgHMkQH XGuorGu0QbKOuaJTAJAATGEVDqNUuAl85YwL27w1Vs9OxDPP5oIDAt4ytA796XcyNP 2v3e/q9WJ0epQ== Date: Wed, 20 Dec 2023 17:20:25 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Christian Marangi Cc: Pavel Machek , Lee Jones , Andrew Lunn , Jakub Kicinski , Daniel Golle , "David S. Miller" , Li Zetao , 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 Message-ID: <20231220172025.3b9c452b@dellmb> In-Reply-To: <20231219165353.23233-1-ansuelsmth@gmail.com> References: <20231219165353.23233-1-ansuelsmth@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 19 Dec 2023 17:53:52 +0100 Christian Marangi 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