From: Maxime Chevallier <maxime.chevallier@bootlin.com> To: Andrew Lunn <andrew@lunn.ch> Cc: davem@davemloft.net, Rob Herring <robh+dt@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Florian Fainelli <f.fainelli@gmail.com>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, linux-arm-kernel@lists.infradead.org, Horatiu.Vultur@microchip.com, Allan.Nielsen@microchip.com, UNGLinuxDriver@microchip.com Subject: Re: [PATCH net-next 3/4] net: phy: Add helper to derive the number of ports from a phy mode Date: Fri, 29 Jul 2022 09:32:52 +0200 [thread overview] Message-ID: <20220729093252.50977d5c@pc-10.home> (raw) In-Reply-To: <YuMAdACnRKsL8/xD@lunn.ch> On Thu, 28 Jul 2022 23:32:36 +0200 Andrew Lunn <andrew@lunn.ch> wrote: > > +int phy_interface_num_ports(phy_interface_t interface) > > +{ > > + switch (interface) { > > + case PHY_INTERFACE_MODE_NA: > > + case PHY_INTERFACE_MODE_INTERNAL: > > + return 0; > > I've not yet looked at how this is used. Returning 0 could have > interesting effects i guess? INTERNAL clearly does have some sort of > path between the MAC and the PHY, so i think 1 would be a better > value. NA is less clear, it generally means Don't touch. But again, > there still needs to be a path between the MAC and PHY, otherwise > there would not be any to touch. > > Why did you pick 0? > > > + > > + case PHY_INTERFACE_MODE_MII: > > + case PHY_INTERFACE_MODE_GMII: > > + case PHY_INTERFACE_MODE_TBI: > > + case PHY_INTERFACE_MODE_REVMII: > > + case PHY_INTERFACE_MODE_RMII: > > + case PHY_INTERFACE_MODE_REVRMII: > > + case PHY_INTERFACE_MODE_RGMII: > > + case PHY_INTERFACE_MODE_RGMII_ID: > > + case PHY_INTERFACE_MODE_RGMII_RXID: > > + case PHY_INTERFACE_MODE_RGMII_TXID: > > + case PHY_INTERFACE_MODE_RTBI: > > + case PHY_INTERFACE_MODE_XGMII: > > + case PHY_INTERFACE_MODE_XLGMII: > > + case PHY_INTERFACE_MODE_MOCA: > > + case PHY_INTERFACE_MODE_TRGMII: > > + case PHY_INTERFACE_MODE_USXGMII: > > + case PHY_INTERFACE_MODE_SGMII: > > + case PHY_INTERFACE_MODE_SMII: > > + case PHY_INTERFACE_MODE_1000BASEX: > > + case PHY_INTERFACE_MODE_2500BASEX: > > + case PHY_INTERFACE_MODE_5GBASER: > > + case PHY_INTERFACE_MODE_10GBASER: > > + case PHY_INTERFACE_MODE_25GBASER: > > + case PHY_INTERFACE_MODE_10GKR: > > + case PHY_INTERFACE_MODE_100BASEX: > > + case PHY_INTERFACE_MODE_RXAUI: > > + case PHY_INTERFACE_MODE_XAUI: > > + return 1; > > + case PHY_INTERFACE_MODE_QSGMII: > > + case PHY_INTERFACE_MODE_QUSGMII: > > + return 4; > > + > > + default: > > + return 0; > > + } > > +} > > Have you tried without a default: ? I _think_ gcc will then warn about > missing enum values, which will help future developers when they add > further values to the enum. Without the default clause, I get an error about the missing PHY_INTERFACE_MODE_MAX case, which I don't think belongs here... Too bad :/ > Andrew
WARNING: multiple messages have this Message-ID (diff)
From: Maxime Chevallier <maxime.chevallier@bootlin.com> To: Andrew Lunn <andrew@lunn.ch> Cc: davem@davemloft.net, Rob Herring <robh+dt@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Florian Fainelli <f.fainelli@gmail.com>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, linux-arm-kernel@lists.infradead.org, Horatiu.Vultur@microchip.com, Allan.Nielsen@microchip.com, UNGLinuxDriver@microchip.com Subject: Re: [PATCH net-next 3/4] net: phy: Add helper to derive the number of ports from a phy mode Date: Fri, 29 Jul 2022 09:32:52 +0200 [thread overview] Message-ID: <20220729093252.50977d5c@pc-10.home> (raw) In-Reply-To: <YuMAdACnRKsL8/xD@lunn.ch> On Thu, 28 Jul 2022 23:32:36 +0200 Andrew Lunn <andrew@lunn.ch> wrote: > > +int phy_interface_num_ports(phy_interface_t interface) > > +{ > > + switch (interface) { > > + case PHY_INTERFACE_MODE_NA: > > + case PHY_INTERFACE_MODE_INTERNAL: > > + return 0; > > I've not yet looked at how this is used. Returning 0 could have > interesting effects i guess? INTERNAL clearly does have some sort of > path between the MAC and the PHY, so i think 1 would be a better > value. NA is less clear, it generally means Don't touch. But again, > there still needs to be a path between the MAC and PHY, otherwise > there would not be any to touch. > > Why did you pick 0? > > > + > > + case PHY_INTERFACE_MODE_MII: > > + case PHY_INTERFACE_MODE_GMII: > > + case PHY_INTERFACE_MODE_TBI: > > + case PHY_INTERFACE_MODE_REVMII: > > + case PHY_INTERFACE_MODE_RMII: > > + case PHY_INTERFACE_MODE_REVRMII: > > + case PHY_INTERFACE_MODE_RGMII: > > + case PHY_INTERFACE_MODE_RGMII_ID: > > + case PHY_INTERFACE_MODE_RGMII_RXID: > > + case PHY_INTERFACE_MODE_RGMII_TXID: > > + case PHY_INTERFACE_MODE_RTBI: > > + case PHY_INTERFACE_MODE_XGMII: > > + case PHY_INTERFACE_MODE_XLGMII: > > + case PHY_INTERFACE_MODE_MOCA: > > + case PHY_INTERFACE_MODE_TRGMII: > > + case PHY_INTERFACE_MODE_USXGMII: > > + case PHY_INTERFACE_MODE_SGMII: > > + case PHY_INTERFACE_MODE_SMII: > > + case PHY_INTERFACE_MODE_1000BASEX: > > + case PHY_INTERFACE_MODE_2500BASEX: > > + case PHY_INTERFACE_MODE_5GBASER: > > + case PHY_INTERFACE_MODE_10GBASER: > > + case PHY_INTERFACE_MODE_25GBASER: > > + case PHY_INTERFACE_MODE_10GKR: > > + case PHY_INTERFACE_MODE_100BASEX: > > + case PHY_INTERFACE_MODE_RXAUI: > > + case PHY_INTERFACE_MODE_XAUI: > > + return 1; > > + case PHY_INTERFACE_MODE_QSGMII: > > + case PHY_INTERFACE_MODE_QUSGMII: > > + return 4; > > + > > + default: > > + return 0; > > + } > > +} > > Have you tried without a default: ? I _think_ gcc will then warn about > missing enum values, which will help future developers when they add > further values to the enum. Without the default clause, I get an error about the missing PHY_INTERFACE_MODE_MAX case, which I don't think belongs here... Too bad :/ > Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-07-29 7:33 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-28 14:52 [PATCH net-next 0/4] net: Introduce QUSGMII phy mode Maxime Chevallier 2022-07-28 14:52 ` Maxime Chevallier 2022-07-28 14:52 ` [PATCH net-next 1/4] net: phy: Introduce QUSGMII PHY mode Maxime Chevallier 2022-07-28 14:52 ` Maxime Chevallier 2022-07-28 21:23 ` Andrew Lunn 2022-07-28 21:23 ` Andrew Lunn 2022-07-28 14:52 ` [PATCH net-next 2/4] dt-bindings: net: ethernet-controller: add QUSGMII mode Maxime Chevallier 2022-07-28 14:52 ` Maxime Chevallier 2022-07-28 14:52 ` [PATCH net-next 3/4] net: phy: Add helper to derive the number of ports from a phy mode Maxime Chevallier 2022-07-28 14:52 ` Maxime Chevallier 2022-07-28 21:32 ` Andrew Lunn 2022-07-28 21:32 ` Andrew Lunn 2022-07-28 21:44 ` Florian Fainelli 2022-07-28 21:44 ` Florian Fainelli 2022-07-29 6:50 ` Maxime Chevallier 2022-07-29 6:50 ` Maxime Chevallier 2022-07-29 7:32 ` Maxime Chevallier [this message] 2022-07-29 7:32 ` Maxime Chevallier 2022-07-29 13:00 ` Andrew Lunn 2022-07-29 13:00 ` Andrew Lunn 2022-07-28 14:52 ` [PATCH net-next 4/4] net: lan966x: Add QUSGMII support for lan966x Maxime Chevallier 2022-07-28 14:52 ` Maxime Chevallier
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=20220729093252.50977d5c@pc-10.home \ --to=maxime.chevallier@bootlin.com \ --cc=Allan.Nielsen@microchip.com \ --cc=Horatiu.Vultur@microchip.com \ --cc=UNGLinuxDriver@microchip.com \ --cc=andrew@lunn.ch \ --cc=davem@davemloft.net \ --cc=devicetree@vger.kernel.org \ --cc=f.fainelli@gmail.com \ --cc=hkallweit1@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=netdev@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=thomas.petazzoni@bootlin.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.