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: 298833 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 200A82C00A7 for ; Mon, 9 Dec 2013 01:42:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759599Ab3LHOlx (ORCPT ); Sun, 8 Dec 2013 09:41:53 -0500 Received: from mail-ee0-f48.google.com ([74.125.83.48]:62703 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759154Ab3LHOkj (ORCPT ); Sun, 8 Dec 2013 09:40:39 -0500 Received: by mail-ee0-f48.google.com with SMTP id e49so1089835eek.7 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 Cc: David Miller , Florian Fainelli , Mugunthan V N , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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);