Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1375173ybt; Thu, 2 Jul 2020 03:59:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpVw6TSW8P4x3o64i+zfDso+2GPlDqDP3OUKqZ57lxH8dTQYgcFmQA1iM39ZWcLTXOV5DI X-Received: by 2002:aa7:c4d1:: with SMTP id p17mr6934214edr.268.1593687573365; Thu, 02 Jul 2020 03:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593687573; cv=none; d=google.com; s=arc-20160816; b=deW+9QTt4w7s+yiWd4VvPb790yyhKKvxRTzgqCaiRxuTFUz9cQLNC3pv3AfrA47tua gO3f9tuhQ9oLkkuGSO8Y68U7Oud7BCf36ct9zPO1VyttINvWNZkUl3ASPV14lCDHsd+a 3Dv1RbmNJ+7WLNynAlcwa16hi+CljFuRds/a4AS0gIyP6Hdf3ZMfSG8Ktz43MbbegjHY eO7Y9fVdLzCFHIhgFJtGyUpKg9Fors8A7gqOVw/QhlFqIn+bpqzqNY+X8E5wE0NWz4s0 NrJWJVm40G6KZUwB2eGLz56kpidDjdMDkpfTTLWTkmIQ1V0rtfMI1sAruY9ebauMFtqY DrOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mG3Gr9JnbGvredrz4X7c4VX5RS6QFdJXmMVG61A0nk4=; b=MTQNASPxaX9Ipt/Cfu8V4Z13XlbjUYta1a24ys3Dyx/e5wcfcOL+8mBTTu0VLNDMK1 mjtZh585ETTOMTc0dm6HjVYvuTu647StG5D3KCpiaxhacUXn5prKXKs+VPBEiId/kF6p Z5IqGhR0/QDexIm6yxju7wzZdKPHBiPMcqWrJZZobAFDC0sDPXiEu3yLzJr6eQ2KBhVm 6Kj0lu05ftjYOqpjLswj7dZwJ3t36woh/JjDLWu6mLy0i7KQyzacH+RJhZ6BgpQ4fTJN Bv5fMf4KvATI+nbDALBr8rqIlAsYLkBg6z7X50Q6VFEnDx14ZhyNkNC+7tzBPK1r0Btb 7ELw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kjd7ViS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si5808252edv.217.2020.07.02.03.59.11; Thu, 02 Jul 2020 03:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kjd7ViS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728583AbgGBKz1 (ORCPT + 99 others); Thu, 2 Jul 2020 06:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728477AbgGBKzX (ORCPT ); Thu, 2 Jul 2020 06:55:23 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DEFBC08C5C1; Thu, 2 Jul 2020 03:55:23 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id s14so11169004plq.6; Thu, 02 Jul 2020 03:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mG3Gr9JnbGvredrz4X7c4VX5RS6QFdJXmMVG61A0nk4=; b=Kjd7ViS0eLyzMOE0iq6o8MHYcgUsIh2OfMZ+Iq9vu7Hr06kAaHWDMR+R2ch+kg2Ec2 yWUuKDiJr2IagoMcMG7UpU/uANUf54hW9+B32kXPWPeaOVPM5x8SDvkxHXQRpfy3zG3I UpzTpIZ25phMceJ+PiNR6u64bX8agFO+Ezypi9riGxz5XQXlG39HWMCLSVtbIpBMMhbs EcT1MRdO90Ye8KrceWqE/Gn90Tf+wVtoRihRKyzBJ2Bo6TsD0WEmVmfq053SKf2ajsJ1 j+NCMdpmqoPYyq7uBTbnggpZ2gso71kS3i5ZBuisd553mOPbHWs2c/iK12O7kZ3t1721 c44A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mG3Gr9JnbGvredrz4X7c4VX5RS6QFdJXmMVG61A0nk4=; b=fiGC+ZQ3arVpwQRNbH76GqWTCZ7Hzl8vefaJN+FvP7xiZtVNEdhW8OqSq+x3M/GLgD UG2+uOQeMH6yNEuQ8dQcNOr4svkTkyuM2gvo/tPt+PoSMZtCWR9u54zKpRyuHBlRLUop m//IIWH5a5EDSai4D6nCJLg2rBOAw7WlLOtrYvuA9ffMe3TX50355Wo0/3gq4VNpuz16 +uv2w6OrjrkhHkwiP7yTApQVxYMRKeA8QtuIvPG6H0T76jkkJ8Ym03tuUtUfZfzWxpha SjkaTytg9lzq5F+rG2CgSNNYTUmZnZc34fJ0H6PcFKlYzFsLeSWbAErHfztH9ZzcvN6o Uj3Q== X-Gm-Message-State: AOAM532Pnm/BfjXbeAjdfwqVzPyuvx9VYehuJzeIzd5oClRFYX7hFqp6 pD9UiSkbrJJyWfwaWrWCn1w= X-Received: by 2002:a17:902:c40c:: with SMTP id k12mr26647870plk.105.1593687322799; Thu, 02 Jul 2020 03:55:22 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.57]) by smtp.gmail.com with ESMTPSA id z13sm8702393pfq.220.2020.07.02.03.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 03:55:22 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "David S. Miller" , Jakub Kicinski , Steve Glendinning Cc: Vaibhav Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v1 2/2] smsc9420: use generic power management Date: Thu, 2 Jul 2020 16:23:51 +0530 Message-Id: <20200702105351.363880-3-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200702105351.363880-1-vaibhavgupta40@gmail.com> References: <20200702105351.363880-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/net/ethernet/smsc/smsc9420.c | 39 +++++++--------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index 7312e522c022..d07f509cb4c7 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -1422,11 +1422,9 @@ static int smsc9420_open(struct net_device *dev) return result; } -#ifdef CONFIG_PM - -static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused smsc9420_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct net_device *dev = dev_get_drvdata(dev_d); struct smsc9420_pdata *pd = netdev_priv(dev); u32 int_cfg; ulong flags; @@ -1451,33 +1449,19 @@ static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state) netif_device_detach(dev); } - pci_save_state(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + device_wakeup_disable(dev_d); return 0; } -static int smsc9420_resume(struct pci_dev *pdev) +static int __maybe_unused smsc9420_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); - struct smsc9420_pdata *pd = netdev_priv(dev); + struct net_device *dev = dev_get_drvdata(dev_d); int err; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - err = pci_enable_device(pdev); - if (err) - return err; + pci_set_master(to_pci_dev(dev_d)); - pci_set_master(pdev); - - err = pci_enable_wake(pdev, PCI_D0, 0); - if (err) - netif_warn(pd, ifup, pd->dev, "pci_enable_wake failed: %d\n", - err); + device_wakeup_disable(dev_d); if (netif_running(dev)) { /* FIXME: gross. It looks like ancient PM relic.*/ @@ -1487,8 +1471,6 @@ static int smsc9420_resume(struct pci_dev *pdev) return err; } -#endif /* CONFIG_PM */ - static const struct net_device_ops smsc9420_netdev_ops = { .ndo_open = smsc9420_open, .ndo_stop = smsc9420_stop, @@ -1658,15 +1640,14 @@ static void smsc9420_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static SIMPLE_DEV_PM_OPS(smsc9420_pm_ops, smsc9420_suspend, smsc9420_resume); + static struct pci_driver smsc9420_driver = { .name = DRV_NAME, .id_table = smsc9420_id_table, .probe = smsc9420_probe, .remove = smsc9420_remove, -#ifdef CONFIG_PM - .suspend = smsc9420_suspend, - .resume = smsc9420_resume, -#endif /* CONFIG_PM */ + .driver.pm = &smsc9420_pm_ops, }; static int __init smsc9420_init_module(void) -- 2.27.0