From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com,
joabreu@synopsys.com, "David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Marek Behún" <kabel@kernel.org>,
"Ivan Bornyakov" <i.bornyakov@metrotek.ru>,
"Pali Rohár" <pali@kernel.org>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] stmmac: intel: Honor phy LED set by system firmware on a Dell hardware
Date: Fri, 14 Jan 2022 23:25:17 +0800 [thread overview]
Message-ID: <CAAd53p4P9STxTUsZ2fXNqOnmwLMfOBXpYR5hvcJHk5-0V7MPgA@mail.gmail.com> (raw)
In-Reply-To: <YeF4kbsqag+kZ7ji@lunn.ch>
On Fri, Jan 14, 2022 at 9:20 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > static void marvell_config_led(struct phy_device *phydev)
> > {
> > - u16 def_config;
> > + struct marvell_priv *priv = phydev->priv;
> > int err;
> >
> > - switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) {
> > - /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
> > - case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R):
> > - case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S):
> > - def_config = MII_88E1121_PHY_LED_DEF;
> > - break;
> > - /* Default PHY LED config:
> > - * LED[0] .. 1000Mbps Link
> > - * LED[1] .. 100Mbps Link
> > - * LED[2] .. Blink, Activity
> > - */
> > - case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
> > - if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE)
> > - def_config = MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE;
> > - else
> > - def_config = MII_88E1510_PHY_LED_DEF;
> > - break;
> > - default:
> > + if (priv->led_def_config == -1)
> > return;
> > +
> > + if (priv->led_def_config)
> > + goto write;
>
> Really?
>
> Please restructure this code. Take it apart into helpers. You need:
>
> A function to set the actual LED configuration.
> A function to decide what, if any, configuration to set
> A function to store the current configuration on suspend.
> A function to restore the current configuration on resume.
>
> Lots of little functions will make it much easier to understand, and
> avoid 1980s BASIC style.
Sure, will turn these into helper functions.
>
> I'm also surprised you need to deal with suspend/resume. Why does the
> BIOS not set the LED mode on resume, same as it does on power up?
I was told this is a BIOS limitation. I'll ask vendor _why_ the LED
can't be restored by BIOS.
Kai-Heng
>
> Andrew
prev parent reply other threads:[~2022-01-14 15:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220114040755.1314349-1-kai.heng.feng@canonical.com>
2022-01-14 4:07 ` [PATCH 2/2] stmmac: intel: Honor phy LED set by system firmware on a Dell hardware Kai-Heng Feng
2022-01-14 4:35 ` Jakub Kicinski
2022-01-14 6:47 ` Kai-Heng Feng
2022-01-14 16:23 ` Jakub Kicinski
2022-01-14 13:09 ` Andrew Lunn
2022-01-14 15:22 ` Kai-Heng Feng
2022-01-14 17:25 ` Andrew Lunn
2022-01-14 13:20 ` Andrew Lunn
2022-01-14 15:25 ` Kai-Heng Feng [this message]
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=CAAd53p4P9STxTUsZ2fXNqOnmwLMfOBXpYR5hvcJHk5-0V7MPgA@mail.gmail.com \
--to=kai.heng.feng@canonical.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=i.bornyakov@metrotek.ru \
--cc=joabreu@synopsys.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pali@kernel.org \
--cc=peppe.cavallaro@st.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).