From patchwork Wed Nov 20 20:21:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3215271 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 94CC49F26C for ; Wed, 20 Nov 2013 20:23:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCDBB20225 for ; Wed, 20 Nov 2013 20:23:13 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 830A02020E for ; Wed, 20 Nov 2013 20:23:12 +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 1VjEIL-0001kd-NO; Wed, 20 Nov 2013 20:22:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjEIB-0005NB-0Z; Wed, 20 Nov 2013 20:22:31 +0000 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjEI3-0005Jy-Df for linux-arm-kernel@lists.infradead.org; Wed, 20 Nov 2013 20:22:24 +0000 Received: by mail-ea0-f180.google.com with SMTP id f15so2407500eak.39 for ; Wed, 20 Nov 2013 12:22:02 -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=LUTWI5jSgnwjU50t++cp6lpnLISKz5NgF5OWOGXyP2I=; b=qr815iBCXOp3g8o0lDxkRBQfrnglmXwHGBoKSCeFeXKihR5URSGQ9HVkqCcbqQiGWa PL9lIg+dpEyBe/RkdnXvZlvMPrsM8RFqld0VPFMgzEiAJWFknNLv5+qQgduaUj317ryh Hk+E7+qydbh+26PjtIfazwE8mkDS7mcmDYV5tMw1N5n1ihm+Qbr9FwGHboYUbb+UIcwV VgIlxmxOjxlvVqieg/2RSqFDOPFGnKAf1huV5OHHJWAhAr/DNGI5Ow1Smi1A6ZBtg/o1 9sd8aRX4Q8ZRLV41Ek7n+znUIJI4RFkrkPZctgKLF9XyD9O1P5/+R+koCFnVL68i0Bop fJCQ== X-Received: by 10.14.106.197 with SMTP id m45mr3278449eeg.45.1384978922184; Wed, 20 Nov 2013 12:22:02 -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 j46sm63391584eew.18.2013.11.20.12.22.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Nov 2013 12:22:01 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH RFC v1 4/7] net: phy: suspend unused PHYs on mdio_bus in late_initcall Date: Wed, 20 Nov 2013 21:21:50 +0100 Message-Id: <1384978913-8052-5-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-20131120_152223_675303_821BD851 X-CRM114-Status: GOOD ( 13.61 ) X-Spam-Score: -2.0 (--) Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. 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.6 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 --- Cc: David S. Miller Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/net/phy/mdio_bus.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 5617876..10eba58 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -320,6 +320,33 @@ 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); + struct phy_device *phydev; + struct phy_driver *phydrv; + int i; + + for (i = 0; i < PHY_MAX_ADDR; i++) { + if (!bus->phy_map[i]) + continue; + + phydev = to_phy_device(&bus->phy_map[i]->dev); + phydrv = to_phy_driver(phydev->dev.driver); + if (!phydev->attached_dev && phydrv && phydrv->suspend) + phy_suspend(phydev); + } + + 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)