From patchwork Sun Dec 8 14:40:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3306921 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 702ACC0D4A for ; Sun, 8 Dec 2013 14:43:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D074A202F8 for ; Sun, 8 Dec 2013 14:43:49 +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 CC180202F2 for ; Sun, 8 Dec 2013 14:43:48 +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 1VpfYb-0006UH-EF; Sun, 08 Dec 2013 14:42:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VpfYF-0003NF-3M; Sun, 08 Dec 2013 14:41:43 +0000 Received: from mail-ee0-x22d.google.com ([2a00:1450:4013:c00::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VpfXY-0003HK-Gy for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2013 14:41:04 +0000 Received: by mail-ee0-f45.google.com with SMTP id d49so1088670eek.32 for ; Sun, 08 Dec 2013 06:40:38 -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=QNypULVmVfDgfuWDVwwfEfKIDvR+B3DwPCpFXxmYrjQ=; b=R1hil7Cn2DhedCjBJrlKXBM62GYuwdrCFtSkuHPhXEeGICkd/rGnhMs0ZaqHztXmHr s/WEvDGlD/yPRZ4Jt6dl/kEV4yOs8H8qU+iGMS2TSN/nOF8S0az4a8TeOueV0j4DRDp5 8kECcVi2K3uQ5ttb0tEYxp1YkocGvtTFZOkPqeQDwC/jPa8fF5FAmefJo717jVWMaUcS r7WrDVrUcbhcVok59St6ISY31MKWqdsnMdWwb2c1RCR5hq6ip9D4BwYx/BK+8RzKI2vX WDcxjT0SxUt7vngGziphakDsr5VVjU3G138gq1SXa0xxIDLOnC0RdOQVt65Z7MR3vuHR h4cg== X-Received: by 10.15.26.200 with SMTP id n48mr9424980eeu.46.1386513638347; Sun, 08 Dec 2013 06:40:38 -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 z42sm17871643eeo.17.2013.12.08.06.40.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 06:40:37 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v1 3/6] net: phy: provide phy_resume/phy_suspend helpers Date: Sun, 8 Dec 2013 15:40:28 +0100 Message-Id: <1386513631-11284-4-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_094100_701152_171E9BAE X-CRM114-Status: GOOD ( 12.67 ) 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 This adds helper functions to resume and suspend a given phy_device by calling the corresponding driver callbacks if available. Signed-off-by: Sebastian Hesselbarth Acked-by: Mugunthan V N Reviewed-by: Florian Fainelli --- 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_device.c | 24 ++++++++++++++++++++++++ include/linux/phy.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index d6447b3..6f0e9e4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -625,6 +625,30 @@ void phy_detach(struct phy_device *phydev) } EXPORT_SYMBOL(phy_detach); +int phy_suspend(struct phy_device *phydev) +{ + struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver); + struct ethtool_wolinfo wol; + + /* If the device has WOL enabled, we cannot suspend the PHY */ + wol.cmd = ETHTOOL_GWOL; + phy_ethtool_get_wol(phydev, &wol); + if (wol.wolopts) + return -EBUSY; + + if (phydrv->suspend) + return phydrv->suspend(phydev); + return 0; +} + +int phy_resume(struct phy_device *phydev) +{ + struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver); + + if (phydrv->resume) + return phydrv->resume(phydev); + return 0; +} /* Generic PHY support and helper functions */ diff --git a/include/linux/phy.h b/include/linux/phy.h index 48a4dc3..1070ee3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -538,6 +538,8 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); int phy_init_hw(struct phy_device *phydev); +int phy_suspend(struct phy_device *phydev); +int phy_resume(struct phy_device *phydev); struct phy_device * phy_attach(struct net_device *dev, const char *bus_id, phy_interface_t interface); struct phy_device *phy_find_first(struct mii_bus *bus);