From patchwork Sun Dec 8 14:40:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3306951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B7F19F37A for ; Sun, 8 Dec 2013 14:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99ABA202F8 for ; Sun, 8 Dec 2013 14:55:10 +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 DFA3120221 for ; Sun, 8 Dec 2013 14:55:05 +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 1VpfZF-0006nA-HX; Sun, 08 Dec 2013 14:42:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VpfYY-0003P5-JQ; Sun, 08 Dec 2013 14:42:02 +0000 Received: from mail-ea0-x231.google.com ([2a00:1450:4013:c01::231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VpfXZ-0003HN-Rk for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2013 14:41:05 +0000 Received: by mail-ea0-f177.google.com with SMTP id n15so1099275ead.36 for ; Sun, 08 Dec 2013 06:40:40 -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=FOiZsn972SO+7ZVee5gacRBbcaq4fSCspeRO53dhT8E=; b=RN8mF/3rs+EBcEy6zDYY+4BeN63PcE4QESzcTYKkSsbf9D3jNq29Hdy2OfSGKdPvZ5 P17RkWr9cUP2T7r9p9xI74D7AqHPWPOq0Rf6A2LDLJa1LaDLfgPr4oj88PzvOIvH/B5i nT4HWEt5kYS9ZQLOmuDvFSZME6ykswqILG+s9y38IHkzZQ4TxEYb1WTyCbt95LZx4SYE UTdruwmSeqCkc8UmqgCB8NtYbJrYYEC9Gs31xE7uQleAbeIVMdDcOuKZzne5Shhx5Jp3 gk00Hj1vlBEu8oZHt9okkEOCsyO6mWAKGUUxz0Pd9rurUJNtEpKeHQuXfA/OHGTBsVPA tJ+A== X-Received: by 10.14.251.68 with SMTP id a44mr9507302ees.64.1386513640188; Sun, 08 Dec 2013 06:40:40 -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 o47sm17852662eem.21.2013.12.08.06.40.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 06:40:39 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v1 5/6] net: phy: suspend unused PHYs on mdio_bus in late_initcall Date: Sun, 8 Dec 2013 15:40:30 +0100 Message-Id: <1386513631-11284-6-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1386513631-11284-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1386171888-28190-1-git-send-email-sebastian.hesselbarth@gmail.com> <1386513631-11284-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131208_094102_062394_5CCA9E99 X-CRM114-Status: GOOD ( 12.39 ) 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 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.2 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=unavailable 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 Since phy_attach ensures PHYs are resumed, we can now suspend all PHYs that have no attached netdev after initcalls. Signed-off-by: Sebastian Hesselbarth Acked-by: Mugunthan V N Reviewed-by: Florian Fainelli --- Changelog: RFCv2->v1: - simplify phydev reference (Suggested by Sergei Shtylyov) 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/mdio_bus.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 5617876..9ccf9c6 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -320,6 +320,29 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv) (phydev->phy_id & phydrv->phy_id_mask)); } +static int mdio_bus_suspend_unused(struct device *busdev, void *data) +{ + struct mii_bus *bus = to_mii_bus(busdev); + int i; + + for (i = 0; i < PHY_MAX_ADDR; i++) { + if (!bus->phy_map[i]) + continue; + + if (!bus->phy_map[i]->attached_dev) + phy_suspend(bus->phy_map[i]); + } + + return 0; +} + +static int mdio_bus_class_suspend_unused(void) +{ + return class_for_each_device(&mdio_bus_class, NULL, NULL, + mdio_bus_suspend_unused); +} +late_initcall_sync(mdio_bus_class_suspend_unused); + #ifdef CONFIG_PM static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)