From patchwork Wed Dec 4 15:44:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3283321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B4EDC0D4A for ; Wed, 4 Dec 2013 15:49:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E67220212 for ; Wed, 4 Dec 2013 15:49:09 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A145201F5 for ; Wed, 4 Dec 2013 15:49:08 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoEf1-0004nc-Rk; Wed, 04 Dec 2013 15:46:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoEeQ-0008SH-2B; Wed, 04 Dec 2013 15:46:10 +0000 Received: from mail-ea0-x232.google.com ([2a00:1450:4013:c01::232]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VoEde-0008Lk-L1 for linux-arm-kernel@lists.infradead.org; Wed, 04 Dec 2013 15:45:24 +0000 Received: by mail-ea0-f178.google.com with SMTP id d10so10670080eaj.23 for ; Wed, 04 Dec 2013 07:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CbG9OKKoPj2D0d+d4qFFbD74Snx0YylBW5vjjQ73uX0=; b=AODGeR8oME/GxAkS8/pp3TzfYYTggtl2pMxcpk4XMeXp5JL0CNZolVgv8kKCHroUKe +f/vvM7IkxrDFX2stw51/AvFWg20nS04g3hDAvUuw9+7eBvVDx6ntIZi6l/Z25sMvcam 7iZHFZwtdtmhbQ/tW9I0eMrmun/hAlRDWmd5rvk8xWX+oEsOFysSRK3YScFr2yfB0t1P qq1fMZko5Ru6g4IukIWxwQaeCdrerkpY3Q7B0B6IP1nHJfrhblHclnAbY0+MWK/w/f3F g3h6avR9XG6oqVoz4jxbsv+o2ukFQFjmoHuEoR9WhB+yXko3CjW7Q6Xp0xiSmdSCPlnl vWtQ== X-Received: by 10.15.26.200 with SMTP id n48mr2398882eeu.46.1386171900748; Wed, 04 Dec 2013 07:45:00 -0800 (PST) Received: from topkick.lan (dslc-082-083-251-183.pools.arcor-ip.net. [82.83.251.183]) by mx.google.com with ESMTPSA id 1sm95492120eeg.4.2013.12.04.07.44.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2013 07:44:59 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH RFCv2 6/6] net: phy: suspend phydev when going to HALTED Date: Wed, 4 Dec 2013 16:44:48 +0100 Message-Id: <1386171888-28190-7-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1384978913-8052-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1384978913-8052-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131204_104522_879313_A965F359 X-CRM114-Status: GOOD ( 13.64 ) X-Spam-Score: -2.0 (--) Cc: Mugunthan V N , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Miller , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When phydev is going to HALTED state, we can try to suspend it to safe more power. phy_suspend helper will check if PHY can be suspended, so just call it when entering HALTED state. Signed-off-by: Sebastian Hesselbarth --- Changelog: RFCv1->RFCv2: - initial, integrate phy_suspend to phy state machine (Suggested by Mugunthan and Florian) Cc: David Miller Cc: Florian Fainelli Cc: Mugunthan V N Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/net/phy/phy.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 36c6994..6429942 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -740,7 +740,7 @@ void phy_state_machine(struct work_struct *work) struct delayed_work *dwork = to_delayed_work(work); struct phy_device *phydev = container_of(dwork, struct phy_device, state_queue); - int needs_aneg = 0; + int needs_aneg = 0, do_suspend = 0; int err = 0; mutex_lock(&phydev->lock); @@ -855,6 +855,7 @@ void phy_state_machine(struct work_struct *work) phydev->link = 0; netif_carrier_off(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev); + do_suspend = 1; } break; case PHY_RESUMING: @@ -913,6 +914,9 @@ void phy_state_machine(struct work_struct *work) if (needs_aneg) err = phy_start_aneg(phydev); + if (do_suspend) + phy_suspend(phydev); + if (err < 0) phy_error(phydev);