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 3A805D0EE19 for ; Fri, 11 Oct 2024 19:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id: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-Owner; bh=CKRjPJi2XSEAxMt2w0V/iIYrcg1mxhKMNF93ETgIVZQ=; b=M9VbRuRE1Kyuypokut+PXMzdhj Qj28Q1cckvMdDWqeJDSE25hI3rm/8zBdF3QidCtd5pULA22St7f1Nd1xftY6fjXYV/S/9jw9++GTY TJNaxnocF47zi8sx0/qLLrmtm5WeTkirYpOjoKHuaNoHnq6ceOvMJPaELEdw+gGIW7qbsqTIR0WlK D1qk5eXsEyKWSMbYP2pGOfqCJuSQ9m+GaIxr1JxoIxdPcdOTNi/ExGeX4kU29FVWbkigoE0XSnZ2F LIyDJTaaRXX63Axs1SoJnrVUIBvt5xpN/aJ27KwdOCx8/+uSbWTnVBshEcDAviLiw9dhKq7xnLFAy eAXUOoDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szKuh-0000000HMET-16jE; Fri, 11 Oct 2024 19:02:59 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szKrv-0000000HKwe-0oLt for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2024 19:00:09 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E26225C5535; Fri, 11 Oct 2024 19:00:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8944AC4CEC3; Fri, 11 Oct 2024 19:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728673205; bh=a84u9nTZ3sCDcURG6NNOgGWd1sDBA3xGdpK8P8jUnag=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ahY7ztNvTTetEplHcaY8bCL4JU7+eKJkpcwiGJvQZaC4cMapaXfQuxagwMLLJxHha xFjwj5ikLuNRcLJ1pNrhpQnsSEkP5vtKx7JYcTJ4M5MIjmGBg0lTSfqL5l39Qkeik8 L4pjhKvmt+LcIpUsGysVpSOKc2LDX3aQmg+ZleHnz/qY4VQ7w5rhmFmzYrHE970D1N WJiIi43l5zjrUe5CjN3uz0vw7JfExbvfGxCXVeQ/L6tU7K97WawMsMSeU+yetPaeeg ivMmF7eM08D+Jk88NwhxzhkxPAgh8iT8k+RavqfWFA5zF5h043w4gZ3x3bm61/3jui Fecn1nuqgCTBw== Date: Fri, 11 Oct 2024 19:59:29 +0100 From: Simon Horman To: Markus Schneider-Pargmann Cc: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Matthias Schiffer , Vishal Mahaveer , Kevin Hilman , Dhruva Gole , Andrew Lunn Subject: Re: [PATCH v3 3/9] can: m_can: Map WoL to device_set_wakeup_enable Message-ID: <20241011185929.GA53629@kernel.org> References: <20241011-topic-mcan-wakeup-source-v6-12-v3-0-9752c714ad12@baylibre.com> <20241011-topic-mcan-wakeup-source-v6-12-v3-3-9752c714ad12@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241011-topic-mcan-wakeup-source-v6-12-v3-3-9752c714ad12@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_120007_389479_C3788435 X-CRM114-Status: GOOD ( 24.38 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 11, 2024 at 03:16:40PM +0200, Markus Schneider-Pargmann wrote: > In some devices the pins of the m_can module can act as a wakeup source. > This patch helps do that by connecting the PHY_WAKE WoL option to > device_set_wakeup_enable. By marking this device as being wakeup > enabled, this setting can be used by platform code to decide which > sleep or poweroff mode to use. > > Also this prepares the driver for the next patch in which the pinctrl > settings are changed depending on the desired wakeup source. > > Signed-off-by: Markus Schneider-Pargmann > Reviewed-by: Andrew Lunn > --- > drivers/net/can/m_can/m_can.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c > index a978b960f1f1e1e8273216ff330ab789d0fd6d51..29accadc20de7e9efa509f14209cc62e599f03bb 100644 > --- a/drivers/net/can/m_can/m_can.c > +++ b/drivers/net/can/m_can/m_can.c > @@ -2185,6 +2185,36 @@ static int m_can_set_coalesce(struct net_device *dev, > return 0; > } > > +static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) > +{ > + struct m_can_classdev *cdev = netdev_priv(dev); > + > + wol->supported = device_can_wakeup(cdev->dev) ? WAKE_PHY : 0; > + wol->wolopts = device_may_wakeup(cdev->dev) ? WAKE_PHY : 0; > +} > + > +static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) > +{ > + struct m_can_classdev *cdev = netdev_priv(dev); > + bool wol_enable = !!wol->wolopts & WAKE_PHY; Hi Markus, I suspect there is an order of operations issue here. Should the line above be like this? bool wol_enable = !!(wol->wolopts & WAKE_PHY); > + int ret; > + > + if ((wol->wolopts & WAKE_PHY) != wol->wolopts) > + return -EINVAL; > + > + if (wol_enable == device_may_wakeup(cdev->dev)) > + return 0; > + > + ret = device_set_wakeup_enable(cdev->dev, wol_enable); > + if (ret) { > + netdev_err(cdev->net, "Failed to set wakeup enable %pE\n", > + ERR_PTR(ret)); > + return ret; > + } > + > + return 0; > +} > + ...