Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754364AbbKQR2c (ORCPT ); Tue, 17 Nov 2015 12:28:32 -0500 Received: from ns.gsystem.sk ([62.176.172.50]:56228 "EHLO gsystem.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752901AbbKQR2a (ORCPT ); Tue, 17 Nov 2015 12:28:30 -0500 From: Ondrej Zary To: netdev@vger.kernel.org Cc: Francois Romieu , David Miller , Kernel development list Subject: [PATCH 3/3] dl2k: Implement suspend Date: Tue, 17 Nov 2015 18:28:18 +0100 Message-Id: <1447781298-19785-3-git-send-email-linux@rainbow-software.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1447781298-19785-1-git-send-email-linux@rainbow-software.org> References: <1447781298-19785-1-git-send-email-linux@rainbow-software.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1931 Lines: 78 Add suspend/resume support to dl2k driver. Tested on Asus NX1101 (IP1000A) and D-Link DGE-550T (DL-2000). Signed-off-by: Ondrej Zary --- drivers/net/ethernet/dlink/dl2k.c | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c index 9e9baa0..b53dfa7 100644 --- a/drivers/net/ethernet/dlink/dl2k.c +++ b/drivers/net/ethernet/dlink/dl2k.c @@ -1824,11 +1824,57 @@ rio_remove1 (struct pci_dev *pdev) } } +#ifdef CONFIG_PM +static int rio_suspend(struct pci_dev *pdev, pm_message_t state) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct netdev_private *np = netdev_priv(dev); + + pci_save_state(pdev); + + if (netif_running(dev)) { + netif_device_detach(dev); + del_timer_sync(&np->timer); + rio_hw_stop(dev); + free_list(dev); + } + + pci_set_power_state(pdev, PCI_D3hot); + + return 0; +} + +static int rio_resume(struct pci_dev *pdev) +{ + struct net_device *dev = pci_get_drvdata(pdev); + struct netdev_private *np = netdev_priv(dev); + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + if (netif_running(dev)) { + alloc_list(dev); + rio_hw_init(dev); + np->timer.expires = jiffies + 1 * HZ; + add_timer(&np->timer); + netif_device_attach(dev); + dl2k_enable_int(np); + } + + return 0; +} + +#endif /* CONFIG_PM */ + static struct pci_driver rio_driver = { .name = "dl2k", .id_table = rio_pci_tbl, .probe = rio_probe1, .remove = rio_remove1, +#ifdef CONFIG_PM + .suspend = rio_suspend, + .resume = rio_resume, +#endif /* CONFIG_PM */ }; module_pci_driver(rio_driver); -- Ondrej Zary -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/