From patchwork Thu Nov 29 08:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 152368 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2086781ljp; Thu, 29 Nov 2018 00:06:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/VD1yYr810yfV64IJ0gxKKQe/xHnYDZ5huLX0vgaciwWvlJmw+pPzLByNPr1K00Fwr3b6Jy X-Received: by 2002:a63:e001:: with SMTP id e1mr402790pgh.39.1543478809453; Thu, 29 Nov 2018 00:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543478809; cv=none; d=google.com; s=arc-20160816; b=UylPwkvFLudfrogxGyji718YmDAam9GtetVA5EqFlXK8+uYk9OJfG3wSZhz5reZ5Nv je5a+5KdY/ye+SMmCps6qk1pYjuJ/oHm84adKJFPnZneiyx5tXkvtC60oqWO8l7vjUEr qqjBdcd8nYH/T40GcKfIly25ZV6fqYSGSvqqjxMkJ1a65H26VTKoDykcWc+1+3CLYikp hxvUfhlfszzc5myfksDp9w14yBFuzCDaC6RraVHCKjoH30U+KhmFdffM31BFENF7rFJd Bnu00pg/mwsttMyY0lxKKDcu0caGdl9lY8jYRIcwgeLXnaExxnlsDPjdVYe9+7G1SSTP D/5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ob9D1j/+EVh7pN+Qds04yIdvTZNgJ08hRzgpvbm5vLU=; b=vmskbEY6kmJQ3/nFyPQ+w4H8m9ZML4CIR59EcIB0hmf2uwB2G3oQAGIEFT/lzMnVN4 z8Gv/RfUxrSXVlMykCX64GRhm/6zjL9ok2lHtRFZZK3o5+aMAng/Y3MVKYnVJ8Xx13fR vNoRw0MXEF73qqCKx7AM6dKozCQxtxI/UfAtUWJjaHfCaWvBhEB+58zAkvFVhwhqPLZi CAYROCntMXb5yFU5wFTSQYtu4sTzJ3bPAzT3pSNQJGJoZlku9De+wnR8i1+JAEfSva2G xoupirCF1zTNGmiiShWPkQ4KGrvZrcwj0kZlN73VSqWdtahKFq+6plWxe7dRha+2SKsr /jiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65si1573192pfb.194.2018.11.29.00.06.49; Thu, 29 Nov 2018 00:06:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbeK2TLR (ORCPT + 32 others); Thu, 29 Nov 2018 14:11:17 -0500 Received: from mx.socionext.com ([202.248.49.38]:4095 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeK2TLQ (ORCPT ); Thu, 29 Nov 2018 14:11:16 -0500 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 29 Nov 2018 17:06:45 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 23488180BCB; Thu, 29 Nov 2018 17:06:45 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Thu, 29 Nov 2018 17:06:45 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id DCB0F1A03A2; Thu, 29 Nov 2018 17:06:44 +0900 (JST) From: Kunihiko Hayashi To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH net-next 1/3] net: ethernet: ave: Add suspend/resume support Date: Thu, 29 Nov 2018 17:06:31 +0900 Message-Id: <1543478793-13719-2-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1543478793-13719-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces suspend and resume functions to ave driver. Signed-off-by: Kunihiko Hayashi --- drivers/net/ethernet/socionext/sni_ave.c | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index 6732f5c..64115b1 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1734,6 +1734,49 @@ static int ave_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int ave_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ave_private *priv = netdev_priv(ndev); + int ret = 0; + + if (netif_running(ndev)) { + ret = ave_stop(ndev); + netif_device_detach(ndev); + } + + return ret; +} + +static int ave_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ave_private *priv = netdev_priv(ndev); + int ret = 0; + + ave_global_reset(ndev); + + if (ndev->phydev) { + ret = phy_resume(ndev->phydev); + if (ret) + return ret; + } + + if (netif_running(ndev)) { + ret = ave_open(ndev); + netif_device_attach(ndev); + } + + return ret; +} + +static SIMPLE_DEV_PM_OPS(ave_pm_ops, ave_suspend, ave_resume); +#define AVE_PM_OPS (&ave_pm_ops) +#else +#define AVE_PM_OPS NULL +#endif + static int ave_pro4_get_pinmode(struct ave_private *priv, phy_interface_t phy_mode, u32 arg) { @@ -1908,6 +1951,7 @@ static struct platform_driver ave_driver = { .remove = ave_remove, .driver = { .name = "ave", + .pm = AVE_PM_OPS, .of_match_table = of_ave_match, }, };