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 6B81BCDB482 for ; Tue, 17 Oct 2023 06:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234533AbjJQGTd (ORCPT ); Tue, 17 Oct 2023 02:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234391AbjJQGTc (ORCPT ); Tue, 17 Oct 2023 02:19:32 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A765AB for ; Mon, 16 Oct 2023 23:19:30 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qsdQ6-0007Li-W2; Tue, 17 Oct 2023 08:19:11 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qsdQ5-002Fuq-N5; Tue, 17 Oct 2023 08:19:09 +0200 Received: from ore by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qsdQ5-00ErhU-Jz; Tue, 17 Oct 2023 08:19:09 +0200 Date: Tue, 17 Oct 2023 08:19:09 +0200 From: Oleksij Rempel To: Florian Fainelli Cc: "David S. Miller" , Andrew Lunn , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: Re: [PATCH net-next v4 4/9] net: dsa: microchip: ksz9477: add Wake on LAN support Message-ID: <20231017061909.GB3539182@pengutronix.de> References: <20231016141256.2011861-1-o.rempel@pengutronix.de> <20231016141256.2011861-5-o.rempel@pengutronix.de> <97df39dc-daae-4334-bb80-d690851e5269@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <97df39dc-daae-4334-bb80-d690851e5269@gmail.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 16, 2023 at 08:37:50AM -0700, Florian Fainelli wrote: > [snip] > > +void ksz9477_get_wol(struct ksz_device *dev, int port, > > + struct ethtool_wolinfo *wol) > > +{ > > + u8 pme_ctrl, pme_conf; > > + int ret; > > + > > + ret = ksz_read8(dev, REG_SW_PME_CTRL, &pme_conf); > > + if (ret) > > + return; > > + > > + if (!(pme_conf & PME_ENABLE)) > > + return; > > I suppose this works beause you have separate enable bits for WOL_LINKUP, > WOL_ENERGY and WOL_MAGICPKT, you could have also left the setting of the > PME_ENABLE bit to the set_wol() routine provided that wol->wolopts is > non-zero. Setting the PME_ENABLE bit in the set_wol() function might imply that it should also be cleared within set_wol(), necessitating refcounting due to its global bit nature. As an alternative, the reading of the REG_SW_PME_CTRL register could be replaced by checking the wakeup_source variable, which might result in some optimization. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |