From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14D13C433FE for ; Thu, 14 Oct 2021 16:34:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2701610CF for ; Thu, 14 Oct 2021 16:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232467AbhJNQgm (ORCPT ); Thu, 14 Oct 2021 12:36:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbhJNQgk (ORCPT ); Thu, 14 Oct 2021 12:36:40 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC1CAC061753 for ; Thu, 14 Oct 2021 09:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rWTtBHHhXY4jnsCdKVmXHpUzMRVuyqvgG9+JMQ2KHXI=; b=VIsmsJE503g+ZslNEnRbRHWt5V IvxC5Ql1q0KVPJEU+AKSf0E3whquTBkqZWC66QFa600VeEhUpvs8K47mns5yZnSOzDDlJcozXKmw6 CtvEU3uO3+FQSxQooIVoLfyY7lr7zIpDZq/gSLGxRkIc16xFHhL+2TNsDWrnsY+BjJ4iwS30x7dMx LFF6dR8Pz2AYiTXO1gxXsBGVrVek6jU5uMrXD9Y91N9LaQb18BMKIHi4Zy51xJC05vBTh1X+TdGbL Gwp4BafDdD8vMaidUH85a52AW+icfZVIey5OiVNkd24PrJzY4J0uE3dDvEOSqXyCvrCgkBfiMztEL A4fk4xyg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55112) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mb3ga-0001Xl-NR; Thu, 14 Oct 2021 17:34:28 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mb3gZ-0002IY-5e; Thu, 14 Oct 2021 17:34:27 +0100 Date: Thu, 14 Oct 2021 17:34:27 +0100 From: "Russell King (Oracle)" To: Antoine Tenart Cc: "David S . Miller" , Jakub Kicinski , Sean Anderson , netdev@vger.kernel.org, Nicolas Ferre , Claudiu Beznea Subject: Re: [PATCH v2 1/2] net: macb: Clean up macb_validate Message-ID: References: <20211011165517.2857893-1-sean.anderson@seco.com> <163402758460.4280.9175185858026827934@kwain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <163402758460.4280.9175185858026827934@kwain> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Oct 12, 2021 at 10:33:04AM +0200, Antoine Tenart wrote: > Hello Sean, > > Quoting Sean Anderson (2021-10-11 18:55:16) > > As the number of interfaces grows, the number of if statements grows > > ever more unweildy. Clean everything up a bit by using a switch > > statement. No functional change intended. > > I'm not 100% convinced this makes macb_validate more readable: there are > lots of conditions, and jumps, in the switch. > > Maybe you could try a mixed approach; keeping the invalid modes checks > (bitmap_zero) at the beginning and once we know the mode is valid using > a switch statement. That might make it easier to read as this should > remove lots of conditionals. (We'll still have the one/_NA checks > though). Some of this could be improved if we add the ability for a MAC to specify the phy_interface_t modes that it supports as a bitmap before calling phylink_create() - then we can have phylink check that the mode is supported itself prior to calling the validate handler. You can find some patches that add the "supported_interfaces" masks in git.armlinux.org.uk/linux-arm.git net-queue and we could add to phylink_validate(): if (!phy_interface_empty(pl->config->supported_interfaces) && !test_bit(state->interface, pl->config->supported_interfaces)) return -EINVAL; which should go a long way to simplifying a lot of these validation implementations. Any thoughts on that? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!