Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5640121rdb; Wed, 13 Dec 2023 15:06:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7QMN0lT8yc2d5nxjFOm51knfcOW+37chkpkzWmBD02IPWPujg+KLnyEnKy2TD4Vut1Eoe X-Received: by 2002:a05:6a00:4643:b0:6ce:2731:47b5 with SMTP id kp3-20020a056a00464300b006ce273147b5mr11213438pfb.21.1702508780168; Wed, 13 Dec 2023 15:06:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702508780; cv=none; d=google.com; s=arc-20160816; b=En0LOr0oZbTvmV4iXmn3+h1IbSK4CPmZMCDG67BKLjIDALoY7E7X/T5RMrIC8gAEor xPJvpubVfn/E7IPwlMS2zj5HGCJTXd/kJQLms+xc59XNQ8oZcTQEnUIua5ZgrKxkTeih QE8EhZYUdePCVZWn+2smXVXj4ICqDwRtW3uN6uVV6iFIjlAQdGL/WOIfpfSQZZ5wNj9R JOzabGh+wY4Ztlfovn7uejrhpn0ZShp3ZX2Vo2mMaPaT96okkej/FIFIniskXGWEQl6M pzVuA6y13VrzvcVNvtvAhA6R/BOGftEMxCIEkTrHyjCF0fnD710RlVU+0X7XWItNAGJt d3uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iLIaYmnFeaSAt+oehqvXb0rJqmTP/GxPnscvrauls0A=; fh=Mq4NJJ1o/t7kh2zmm/LE/y/+F4JxlZg0VXw0JBJHV2c=; b=gKWbc9RwT9I5zcmLpG4pHcj0wuSxXmLm3rpXjNJYyLacoPGqMojoQp4u+TDWMGwlkR 0OxOnzerREhdZJe4Rgv/qQKAyESIpoCwSpQyQDv/cySi46ygs/JawJNSrxUN62mw5Re8 n/hLVSK4qj5f9csf5J/5kE0qIvH7yZTHUMtsHSTHXqTe9pG3L45ZtlnhqZ2CddoRbKdk ZLcE1+CkRcrpNDh25jpyLc/y+Tv5wjzEunM46Ef4eJbyZmRBbWh7O//JLPpUxlm2JzMw SDncPTNIjzELvUnLwcedy8nWtRSBXl4/KYu851ntmvNRz98PtwNF6emnl6GT9HPvUNYK fAkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=dEpAotxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ka41-20020a056a0093a900b006cd8db94631si9923031pfb.365.2023.12.13.15.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:06:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=dEpAotxw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 812788032359; Wed, 13 Dec 2023 15:06:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbjLMXGE (ORCPT + 99 others); Wed, 13 Dec 2023 18:06:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjLMXGD (ORCPT ); Wed, 13 Dec 2023 18:06:03 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6504DD5; Wed, 13 Dec 2023 15:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=iLIaYmnFeaSAt+oehqvXb0rJqmTP/GxPnscvrauls0A=; b=dEpAotxwRFL6VfcTsV3BjfNlLf R0HwFimi0CGQoG+T+QMCJqeMVxxum72Y7ayvcMqp9wFztVnBEbraZ7CX4pZKtGafV+S1CpHPTjRab 2Iy36dvYn+qgBEsQnwwKZnuJT+oN3GqHHblTCVuqkVLL+HiC4AvY0RGP5nRGrb8jcz38=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rDYIa-002rrh-MX; Thu, 14 Dec 2023 00:05:52 +0100 Date: Thu, 14 Dec 2023 00:05:52 +0100 From: Andrew Lunn To: Christian Marangi Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Vincent Mailhol , Kees Cook , Piergiorgio Beruto , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next PATCH 0/2] net: add define to describe link speed modes Message-ID: References: <20231213181554.4741-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231213181554.4741-1-ansuelsmth@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 15:06:17 -0800 (PST) On Wed, Dec 13, 2023 at 07:15:52PM +0100, Christian Marangi wrote: > This is a simple series to add define to describe link speed modes. > > Hope the proposed way is acceptable with the enum and define. > > This is also needed in the upcoming changes in the netdev trigger for LEDs > where phy_speeds functions is used to declare a more compact array instead > of using a "big enough" approach. I'm trying to figure out the 'big picture' here. The LED trigger will call ksetting_get to get a list of supported link modes. You can then use the table struct phy_setting settings[] in phy-core.c to translate the link mode to a speed. You are likely to get a lot of duplicate speeds, but you can remove them. For each speed you need to create a sysfs file. Why not just create a linked list, rather than an array? Or just walk the table and find out how many different speeds there are and allocate an array of that size. Its currently 15, which is not that big. And then just use the is_visible method to hide the ones which are not relevant. I don't see any need for new enums or tables here, just a function to look up a link mode in that table and return the speed. Andrew