From patchwork Fri Dec 13 09:20:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 300952 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 BFBEE2C00A4 for ; Fri, 13 Dec 2013 20:22:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752514Ab3LMJWG (ORCPT ); Fri, 13 Dec 2013 04:22:06 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:49044 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943Ab3LMJUl (ORCPT ); Fri, 13 Dec 2013 04:20:41 -0500 Received: by mail-ea0-f180.google.com with SMTP id f15so744384eak.39 for ; Fri, 13 Dec 2013 01:20:39 -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=1yV1NRe6T9gLACY9hSGQI/IoszhLO8FHZk+cEaUnS6A=; b=z3slC3oazokp8Sai4bu7rFXfTTgLMseKhoNoF2pC16QraDIxic57GAWGIWdtbYnb6V RORwHz5WXOgRkNLyBddtPtBW0+Q0gfDIvjIfCqoydvbo0JgtxSiArbJIYpDMd8APPf+i vPK+8S04bi6mdrwEpRJyuHYoMScrEGryb8wJZwTqBBsUpW7GnE0kwNiYZ3oRFzZW3NoH DjjZHpUXkS4KDUAPSjyrQjcWNKZyYPxHl6lkzBSBsTTVuU8jyIQRHvvus8L3ob8cu2NZ 4zHg6f1Es8Rd72oHBQpTfbmjYH/owglmpzWvm3qHl2/zKyfTcp04HS0Ryk7jGbn7O8uR xy+g== X-Received: by 10.14.194.1 with SMTP id l1mr1583328een.103.1386926439854; Fri, 13 Dec 2013 01:20:39 -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 e43sm4552186eep.7.2013.12.13.01.20.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 01:20:38 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Cc: Sebastian Hesselbarth , David Miller , Florian Fainelli , Mugunthan V N , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] net: phy: provide phy_resume/phy_suspend helpers Date: Fri, 13 Dec 2013 10:20:27 +0100 Message-Id: <1386926429-28818-4-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1386513631-11284-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <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(+), 0 deletions(-) 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);