From patchwork Wed Jan 21 22:19:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 5680681 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FC229F358 for ; Wed, 21 Jan 2015 22:19:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B606720497 for ; Wed, 21 Jan 2015 22:19:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D978720480 for ; Wed, 21 Jan 2015 22:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615AbbAUWTx (ORCPT ); Wed, 21 Jan 2015 17:19:53 -0500 Received: from mail-la0-f41.google.com ([209.85.215.41]:37614 "EHLO mail-la0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbbAUWTw (ORCPT ); Wed, 21 Jan 2015 17:19:52 -0500 Received: by mail-la0-f41.google.com with SMTP id gm9so16793796lab.0 for ; Wed, 21 Jan 2015 14:19:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=hvbThZxTxRUwGEjDTFl6MkCpXSPIOt9VRTRHSZzaVVY=; b=KpKgXGLW9CfuHuRQOfyG3h0jVlHHxMuDKO5AkZIr04dCSE3/jWfzFzA/VHYLEq/yCs EXl6vwzrU26T986uhqpTWltiNfFKzxutMwksuayHjdi75hgSGZvawiogjWh7gOxrXQbD /Pia3GJanRVLi1yPxPFQhzeREAkOdyOyPe3Y2qKPEtiB19fLSKBQKX7ieMGZw4jMqxa3 0v4lFdvUOp5vlmuNmBN7gl8Ru0hv1D9NrJDn0Yd62xBIn8Q9d1GthlYavPfJem5PoMNe Rt/6lon8Ps0nqliY5xkmEZcrUDzH09qwLVAOddyRdBxbjyDOkjuNz2KGtC9dkOrhvXBb lVAA== X-Gm-Message-State: ALoCoQnFEgZSiAR833x00Rk2VxNJ3nxbXCE+4408G7tO7KM9G9DUb2GrFIDDxLZELunI3QjcwJtP X-Received: by 10.112.72.197 with SMTP id f5mr46032972lbv.21.1421878791188; Wed, 21 Jan 2015 14:19:51 -0800 (PST) Received: from wasted.cogentembedded.com (ppp25-138.pppoe.mtu-net.ru. [81.195.25.138]) by mx.google.com with ESMTPSA id aq4sm5236444lbc.46.2015.01.21.14.19.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jan 2015 14:19:50 -0800 (PST) From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org, mikhail.ulyanov@cogentembedded.com Subject: [PATCH 2/2] sh_eth: add more PM methods Date: Thu, 22 Jan 2015 01:19:48 +0300 Message-ID: <2238953.qWhbSccAbj@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.3 (Linux/3.17.8-200.fc20.x86_64; KDE/4.14.3; x86_64; ; ) In-Reply-To: <5608250.lrFkJTjgSf@wasted.cogentembedded.com> References: <5608250.lrFkJTjgSf@wasted.cogentembedded.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Mikhail Ulyanov Add sh_eth_{suspend|resume}() implementing {suspend|resume|freeze|thaw|poweroff| restore}() PM methods to make it possible to restore from hibernation not only in Linux but also in e.g. U-Boot and to have more determined state on resume/ restore. Signed-off-by: Mikhail Ulyanov [Sergei: moved sh_eth_{suspend|resume}() before sh_eth_runtime_nop(), enclosed them with #ifdef CONFIG_PM_SLEEP, reordered the local variables, got rid of *goto* and label, reordered macro invocations, renamed, modified the changelog.] Signed-off-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/sh_eth.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -2947,6 +2947,36 @@ static int sh_eth_drv_remove(struct plat } #ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP +static int sh_eth_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + int ret = 0; + + if (netif_running(ndev)) { + netif_device_detach(ndev); + ret = sh_eth_close(ndev); + } + + return ret; +} + +static int sh_eth_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + int ret = 0; + + if (netif_running(ndev)) { + ret = sh_eth_open(ndev); + if (ret < 0) + return ret; + netif_device_attach(ndev); + } + + return ret; +} +#endif + static int sh_eth_runtime_nop(struct device *dev) { /* Runtime PM callback shared between ->runtime_suspend() @@ -2960,6 +2990,7 @@ static int sh_eth_runtime_nop(struct dev } static const struct dev_pm_ops sh_eth_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(sh_eth_suspend, sh_eth_resume) SET_RUNTIME_PM_OPS(sh_eth_runtime_nop, sh_eth_runtime_nop, NULL) }; #define SH_ETH_PM_OPS (&sh_eth_dev_pm_ops)