Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3054089ybt; Mon, 29 Jun 2020 14:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwslXBLd259uRoprb6Xrc6dNJU12HCIw0YIKN/UXzzTmLXk58e6fuiCwHj+ZbXEiOhy5nNB X-Received: by 2002:a17:906:71d4:: with SMTP id i20mr16394934ejk.533.1593464650707; Mon, 29 Jun 2020 14:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593464650; cv=none; d=google.com; s=arc-20160816; b=TUzbPR84Yqy/Qbrtdk1XB+J67r+jDmVScFDfeB+P59c1bbjQUkQI2FP3EKisgoJiyn pevLg2ngWiVCnoUYDlWMAgvZNNUef/Sv8u5f+8se/1H5ffNnCpvS71+5rs1U655PJaFv sGyzMQsNrFxQMHPf2QWIbnMyVTa2O9rEv/Df1QWXH0gi7+f3TgSHNO+msLpLUCCOO7vR f/qP9bF01LJExwyoO7U+MiQxwxqWVnt1iidKV8iyE2NIXnSqF7+6OF2WA1/yR5/Xrlpt hlTpmyDPOHrkiMr3Ri1jO2VYyPhYhpvgdWeOfnc1GsXVaaVbkdybrV2Bzc6RCHRs7Wn2 lShw== 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=Rqvwsn3zKVSYtQI3W9Dp3plnfUTHaA+z2ZGTb8aVlbU=; b=J3JT6yfafjT0z31W67on0ffEGYOxObnr8btQPwi3JPFG8UtigcsBTvTP1Z/Dzmo7G2 WJEfZb7gEii7nhnkXogRxvc+SzSXLHWGDSO1IqH+l6Ti3LpKYLPbP3sSoSslBM/ZooJm aR2yvLYR8QN/RG2YxmV+L3Iz1gWq7c2+MFN4B/ZHpc0NNjI2GkkUPiZppGFQj0lhn8fX KQ0NmZ0cVKSMApFREvcqQbSl9aI13ZSKf0rBLTdX0WsZTJrgb9Qgs+b1+0s4vUFt6DTq nh8QXzNQfwygigSi/jNRTi9OBs2FN4+OIuA4Ydap3MWwRliFg+23Um9YhNmMxO3c0T6u HCUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dlx0UwC3; 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 kt13si365579ejb.297.2020.06.29.14.03.47; Mon, 29 Jun 2020 14:04:10 -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=Dlx0UwC3; 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 S2389955AbgF2VAe (ORCPT + 99 others); Mon, 29 Jun 2020 17:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731216AbgF2TM7 (ORCPT ); Mon, 29 Jun 2020 15:12:59 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 201CAC014A73 for ; Mon, 29 Jun 2020 01:17:42 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id b92so7702562pjc.4 for ; Mon, 29 Jun 2020 01:17:42 -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=Rqvwsn3zKVSYtQI3W9Dp3plnfUTHaA+z2ZGTb8aVlbU=; b=Dlx0UwC3kYeJgxeEwQAj3b/6RGb5GbiAsuc7KMAmV2cD4pYManJXgnL7YtesPkh36B Kqp5iQI1OSR8AJ0hTIi0NOr5wTSYaEJwR0j+7BeklgBn5zBDCzXqA+2pwiJfPARqVRVh Nn8xqTdsGwWAwJ5lhIkvdDREPxW1VWlXbHBrtYj6N2LRGzs26tYOVD/xULhRjClRV0lF OxbXgKuqP8RnfSy26NLfYj/dVj2PrdaTIxIMpxO4aMT4kktpPpA/mqBV/B5MUIiKEXeQ jbgb2X8r19TOoiPVRoCRalAAu03ETaiqW77lghO3OkJxxJPeq1+W419gtSdyQLXtih1b T5gA== 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=Rqvwsn3zKVSYtQI3W9Dp3plnfUTHaA+z2ZGTb8aVlbU=; b=hx2P5mv28a3O6VRjXgy/jOJsXO4fDIsCQwF6qFNozXhZX/frfPEoOS5ICmZKgwcz97 4CcXZBAZNB09J5dkbC59jEytBQ7x5WOIr4dTT4PrZZ65HPPLxFMp7hUrBO8MtqM0PmeW aWFelpwllO5ijtC6W5enb+kLIjUQzHCy9o8NfQYMrJek2XjwKMRUGTJzE6TenjXwT+pf 62P2OqOlFnF2iaXIH6V6iP1LbHbu8JaScWsxV2d4YU/EHA1vgvSSbsI1XWw2fXwMRV/b V0Fz+O9ZNhji7oVgBPfwfHhUJJbOEyegPO0g48StQwfUXCVyLkOWB/6TpsTm/zFuoC0Q JAXA== X-Gm-Message-State: AOAM531aURV09kEQYW1ZSBR+SZaMrQJdGMlPNv4UmFZbUjTHvHtBSblm tARGHLPXJUYnZSSgBUfUyj4= X-Received: by 2002:a17:90a:982:: with SMTP id 2mr823366pjo.34.1593418661628; Mon, 29 Jun 2020 01:17:41 -0700 (PDT) Received: from varodek.localdomain ([106.210.40.90]) by smtp.gmail.com with ESMTPSA id co1sm3345154pjb.34.2020.06.29.01.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 01:17:41 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , Arnd Bergmann , Greg Kroah-Hartman , Jiri Slaby , Alex Dubov Cc: Vaibhav Gupta , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v1 4/5] misc/phantom.c: use generic power management Date: Mon, 29 Jun 2020 13:45:30 +0530 Message-Id: <20200629081531.214734-5-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629081531.214734-1-vaibhavgupta40@gmail.com> References: <20200629081531.214734-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 With the support of generic PM callbacks, drivers no longer need to use legacy .suspend() and .resume() in which they had to maintain PCI states changes and device's power state themselves. All required operations are done by PCI core. Driver needs to do only device-specific operations. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/misc/phantom.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 6a5ed0e25ff1..ce72e46a2e73 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c @@ -457,31 +457,26 @@ static void phantom_remove(struct pci_dev *pdev) pci_disable_device(pdev); } -#ifdef CONFIG_PM -static int phantom_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused phantom_suspend(struct device *dev_d) { - struct phantom_device *dev = pci_get_drvdata(pdev); + struct phantom_device *dev = dev_get_drvdata(dev_d); iowrite32(0, dev->caddr + PHN_IRQCTL); ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */ - synchronize_irq(pdev->irq); + synchronize_irq(to_pci_dev(dev_d)->irq); return 0; } -static int phantom_resume(struct pci_dev *pdev) +static int __maybe_unused phantom_resume(struct device *dev_d) { - struct phantom_device *dev = pci_get_drvdata(pdev); + struct phantom_device *dev = dev_get_drvdata(dev_d); iowrite32(0, dev->caddr + PHN_IRQCTL); return 0; } -#else -#define phantom_suspend NULL -#define phantom_resume NULL -#endif static struct pci_device_id phantom_pci_tbl[] = { { .vendor = PCI_VENDOR_ID_PLX, .device = PCI_DEVICE_ID_PLX_9050, @@ -491,13 +486,14 @@ static struct pci_device_id phantom_pci_tbl[] = { }; MODULE_DEVICE_TABLE(pci, phantom_pci_tbl); +static SIMPLE_DEV_PM_OPS(phantom_pm_ops, phantom_suspend, phantom_resume); + static struct pci_driver phantom_pci_driver = { .name = "phantom", .id_table = phantom_pci_tbl, .probe = phantom_probe, .remove = phantom_remove, - .suspend = phantom_suspend, - .resume = phantom_resume + .driver.pm = &phantom_pm_ops, }; static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION); -- 2.27.0