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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0597CC433EF for ; Fri, 14 Jan 2022 15:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242195AbiANPZp (ORCPT ); Fri, 14 Jan 2022 10:25:45 -0500 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]:40338 "EHLO smtp-relay-internal-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243498AbiANPZc (ORCPT ); Fri, 14 Jan 2022 10:25:32 -0500 Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id EFDA83F1E4 for ; Fri, 14 Jan 2022 15:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1642173930; bh=1r53LGbRrCdIDFkdFatBJl+cYRNX8emZDBqZeKrVhA0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WF6xMjWZ8ZBKCWeqPYriEsqqlXaD86sZgG2N67dKGDFAUgpOLSirTy0YOCFFbmsGZ Ym3Q5to0NGs+xPjASooHN3MYHYvtXa0TUJnigDJWd+4ckkLoeWupU0mPBWK7Q+hheD 2s1EuGEdb5sl6DesBuhzRuqTy5xh3hJ3Q+Pk06PKk8Lt/BQrrOeqbtCZXm5n6bC13p 3sqnkQowhifIsHslyWD88lOWScswL/QM9s56PRv58RGu+7zHYxcjaUv0j5QklluvqX YJeZMpNN5JW23A8PGNL4a+znkSfVE1qoOt1Fex5DxVyGa2NfW0e5jawDpIqwaTUBM8 S6spDvXhC9rXw== Received: by mail-oi1-f197.google.com with SMTP id v72-20020acaac4b000000b002c8dd559f44so6202412oie.8 for ; Fri, 14 Jan 2022 07:25:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1r53LGbRrCdIDFkdFatBJl+cYRNX8emZDBqZeKrVhA0=; b=qQKrI3xAas0l9MR3N79sSPnYyBXT7yZV3r7RZiMlDHIgGiC85o84Lam66vwUZw2/r8 xNPWgiSrVg7zPGA5ZayyYjYuztaPCh1tdBCrYEr0T84yi/rTVoiQXTNm1O0MFtrCwuj7 ngS4Tnx467d7dCT58e8gmgM3h9aISF30Glj913+2HtGfxeYa4+AhOnz0tHbbSAyvmwc8 x1oeUhBtiV3ZanSut3LZTC9+IPTjVCIhiLzZimru8Q/ZR4sa4LW91LcUiWD11DUOOpXD 0zkRtHuIKUWIltH/3dMHURBeobT/x2aD6IzU/ZXbW7dGiPLEB90x/tM12MTXHP5OOIiw r7SA== X-Gm-Message-State: AOAM533Sc0O4mah3ivtLziRc46AidHVZOsNMw5sEPLtZRGNGB+V4olSf raOdq58ffdaf21KT6LeQXOPpAfBbQmQCjX3SHhowm9AcJaMexyE2L1Nt2c5HCLErP6RU8vcD2D6 iEOVUahOESjqvGazNmGcceXtWVeBsusRTdmhIZNi6tppA5hKQiJ3L7GpCww== X-Received: by 2002:a05:6808:199a:: with SMTP id bj26mr13097381oib.98.1642173929766; Fri, 14 Jan 2022 07:25:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjc8OhFrl0+4UKcBWR0AvxTCF+lZaB9wkXprPPao3yjX3bM54hzP09Hoph4ybKCG+Gsz+cmAnQZkDe5pkkoW8= X-Received: by 2002:a05:6808:199a:: with SMTP id bj26mr13097353oib.98.1642173929496; Fri, 14 Jan 2022 07:25:29 -0800 (PST) MIME-Version: 1.0 References: <20220114040755.1314349-1-kai.heng.feng@canonical.com> <20220114040755.1314349-2-kai.heng.feng@canonical.com> In-Reply-To: From: Kai-Heng Feng Date: Fri, 14 Jan 2022 23:25:17 +0800 Message-ID: Subject: Re: [PATCH 2/2] stmmac: intel: Honor phy LED set by system firmware on a Dell hardware To: Andrew Lunn Cc: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, "David S. Miller" , Jakub Kicinski , Maxime Coquelin , Heiner Kallweit , Russell King , =?UTF-8?B?TWFyZWsgQmVow7pu?= , Ivan Bornyakov , =?UTF-8?Q?Pali_Roh=C3=A1r?= , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 14, 2022 at 9:20 PM Andrew Lunn 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CE74C433F5 for ; Fri, 14 Jan 2022 15:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w78COl6qIkC5owSizq5GveFe4VwuSgAejLqxuV71x0g=; b=Ze/nt3B8jre+V+ 9+xt3G5DKrr6xaDEYwAK/cnA2tHN9BJH1HZRkDLb8n4UMnE2z9M05fxJcWpAN4dG0xUWDLnWJWjwz +hHk3i9GHQOCyFbwkiVdEIf7iGpt//6KCwNKTavzlwqE4uPeS4dSAur+l3IGlHEZke5DCdZpvX9lo 9BjNfoo9YZV6Xi3UWTXqhrBXAC8wZAv+Cw2XrR2yLIL0Qt21hp4SDzk6v4wh1kRA6r4omvRxJ81eV jJDUbPrHwWpUKH0hJJ0QB1VTsI+YJx1m3xKY2wHaslrwgLSpHJ4ThrPKlpNcjJofUOymmYHWH+9zC EDjUHQDt5oMs2H6TmRqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8OSP-009bLD-Po; Fri, 14 Jan 2022 15:25:38 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8OSL-009bK8-JC for linux-arm-kernel@lists.infradead.org; Fri, 14 Jan 2022 15:25:35 +0000 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id D8E7C3F17B for ; Fri, 14 Jan 2022 15:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1642173930; bh=1r53LGbRrCdIDFkdFatBJl+cYRNX8emZDBqZeKrVhA0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WF6xMjWZ8ZBKCWeqPYriEsqqlXaD86sZgG2N67dKGDFAUgpOLSirTy0YOCFFbmsGZ Ym3Q5to0NGs+xPjASooHN3MYHYvtXa0TUJnigDJWd+4ckkLoeWupU0mPBWK7Q+hheD 2s1EuGEdb5sl6DesBuhzRuqTy5xh3hJ3Q+Pk06PKk8Lt/BQrrOeqbtCZXm5n6bC13p 3sqnkQowhifIsHslyWD88lOWScswL/QM9s56PRv58RGu+7zHYxcjaUv0j5QklluvqX YJeZMpNN5JW23A8PGNL4a+znkSfVE1qoOt1Fex5DxVyGa2NfW0e5jawDpIqwaTUBM8 S6spDvXhC9rXw== Received: by mail-oi1-f198.google.com with SMTP id r11-20020acaa80b000000b002c909592028so6208565oie.9 for ; Fri, 14 Jan 2022 07:25:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1r53LGbRrCdIDFkdFatBJl+cYRNX8emZDBqZeKrVhA0=; b=cO9eNC7yAwiBqLeDGmOx4T9EvBEzluUJ4d/YoPKU4WO2uQm/O39V6I7YZ9zbP2N17w BtmYOWCEMFXAQcxcXd5LdhMJEnrOhMmJvZD5hBg9ZFJ9h3eRCDKub8NtKWWRQSzOvhHO MD2BT35fxUs6uVkeNq4OF7BGsTEIi6UT5o7HQBhI91kz5Y4JK+JhnEgh/KpNZbof17Cz IkGa6y0MAt8iJFjhl2D/fa1VSxMWZETfkVE08dC9R9eiDKM2D9b4djTwvNS+icvMhi4m kG6CEIlygSQe7apwSM8GhSvdTBLBiVj7OpTXuJZ+4Lyx1FsskYhmIOUbD3ZcVJzfhbnX A1PQ== X-Gm-Message-State: AOAM5308YAB97yiXZx4cVRZKvFYko31QLMPzRkpYHYfHM9rAsmdWVtdc 0sGbl3pozDd+FMk9eRbM1GuFRLwFDeQKxnJFL4hJYfY8xHq5q9zTWFYdTT6ndPz5kc2xeWazdmJ ALsitBGumJ34rFM0pKB76JUmcmxMgVI89IqgLNZC6e0IfSXSDYaKBULnu0odKFak7uTU9 X-Received: by 2002:a05:6808:199a:: with SMTP id bj26mr13097377oib.98.1642173929764; Fri, 14 Jan 2022 07:25:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjc8OhFrl0+4UKcBWR0AvxTCF+lZaB9wkXprPPao3yjX3bM54hzP09Hoph4ybKCG+Gsz+cmAnQZkDe5pkkoW8= X-Received: by 2002:a05:6808:199a:: with SMTP id bj26mr13097353oib.98.1642173929496; Fri, 14 Jan 2022 07:25:29 -0800 (PST) MIME-Version: 1.0 References: <20220114040755.1314349-1-kai.heng.feng@canonical.com> <20220114040755.1314349-2-kai.heng.feng@canonical.com> In-Reply-To: From: Kai-Heng Feng Date: Fri, 14 Jan 2022 23:25:17 +0800 Message-ID: Subject: Re: [PATCH 2/2] stmmac: intel: Honor phy LED set by system firmware on a Dell hardware To: Andrew Lunn Cc: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, "David S. Miller" , Jakub Kicinski , Maxime Coquelin , Heiner Kallweit , Russell King , =?UTF-8?B?TWFyZWsgQmVow7pu?= , Ivan Bornyakov , =?UTF-8?Q?Pali_Roh=C3=A1r?= , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220114_072533_787480_1F031965 X-CRM114-Status: GOOD ( 20.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 14, 2022 at 9:20 PM Andrew Lunn 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel