Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3391758ybt; Tue, 30 Jun 2020 01:20:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdOfsm9Vc+RSk+Gw5rE7bgF6lYdWcifskAWlPxMYgukyXgjpXmkJhCmYri+JN7ln5Qa0eN X-Received: by 2002:a50:bb48:: with SMTP id y66mr18590064ede.147.1593505242435; Tue, 30 Jun 2020 01:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593505242; cv=none; d=google.com; s=arc-20160816; b=t/jbh5mxH1qFxWrT5aB+F0UlRx4a+EugjccstVUopRJV40CDAc+tpHAOO4aejTudic Coxp65vKIKg7hgdzF13y7Qq4YgRgBhVU8sBvrWxAPkgjSOGl5p5+Yw67vWjLiVnIVmkP QfFWVyEmwiR3icw5VPwDeHcGo543xRMsidTYdyOwZ2HUvTV7u31RKfMQ/Vd0WofJWJZu IuiZ3RhZIgGFC3e9dpcEBu6RyKPPKt03wNzpCELCTzYou6iIfl65td+0fj9Yn2vCOTOL r5RuzP0kKCXp8ko8Xi3GfbcNcFQ5DxwnCFtTi10LF1kkltviL1jTVQFxnBip88G8Lxcf bSfA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=hvNDb619PND9BSnOO/FTgYwwF+7N75fMEl+ZD4EKqsM=; b=y03m/SGFdTKB54BgnufvRgy/N1VV2o6t/zSvy0HlJ74wttKFJPNA+1R4JIfmJ0lOrl PIuUFhXYjKpiAI0e7Xa0CewxfPc087ayokDGySjHkNI3dz+x9VmLJHSeVBOqzuaqY9jY P4moa4tpIHx0sLGnR9FCXh0TKn8Wogj8bwFdrbZeMt+fU6UOvzR2tIfpDhnq0H2Jc99E oQXxh2PHZqhOh9tf1KymgJEQ3LjPdlKliAjuI5A2dYer8cb2MaiYhb8+KBbtk61NnLo+ TgOeZGwvFdKMIJYNLYes3/p7dVjGdXwS93COa220G9euh4Xa4dn0wnOktdcNiM4M7f2T 4wBg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr12si1591486ejc.352.2020.06.30.01.20.19; Tue, 30 Jun 2020 01:20:42 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731345AbgF3ITr (ORCPT + 99 others); Tue, 30 Jun 2020 04:19:47 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:32814 "EHLO mail-ej1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730861AbgF3ITp (ORCPT ); Tue, 30 Jun 2020 04:19:45 -0400 Received: by mail-ej1-f67.google.com with SMTP id n26so5645280ejx.0 for ; Tue, 30 Jun 2020 01:19:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hvNDb619PND9BSnOO/FTgYwwF+7N75fMEl+ZD4EKqsM=; b=eMWO5dMpyuuKoC1e3H/9ut0wE3rsfuQc1TdA6U+47Ka3S1BXmH0febTyfL7ODEZ9U6 /PvdRkUcK28YmLGj1STJsT510Ys3Ld4MXYbrtFDmEVMnA4jVuDLde//gehcXTVZQ5c/j AB2MY7zkzMXZjlcWZ7mQ0SQtJNM2nSQr2yBVSpdT2HwUdvGWcrXak+NMyOUDam9jcCBQ iBRve8SFn6OQz+SBQCcEb0UCv2Jhy+lwKi0ufnBAwg4RrnQouYHgcQCJg6MYYShpqlc9 5NKzEG+BhfTGtQKqcaA16XNdmYtFlUemfO8E8XtzqoX3/BGC7fhRYpjnUK+bwXBAA6DV GboQ== X-Gm-Message-State: AOAM533/prxHtrU/ZdIeczcvefDckW95KxTnRxTR8vTHF7UQZ/toZBe6 l2uXjDt08JML+TR/xKpVsxI= X-Received: by 2002:a17:907:7283:: with SMTP id dt3mr17835137ejc.195.1593505183733; Tue, 30 Jun 2020 01:19:43 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id w8sm1999763eds.41.2020.06.30.01.19.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jun 2020 01:19:43 -0700 (PDT) Subject: Re: [PATCH v1 4/5] misc/phantom.c: use generic power management To: Vaibhav Gupta , Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , Arnd Bergmann , Greg Kroah-Hartman , Alex Dubov Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org References: <20200629081531.214734-1-vaibhavgupta40@gmail.com> <20200629081531.214734-5-vaibhavgupta40@gmail.com> From: Jiri Slaby Message-ID: <164d7366-27f5-c764-3122-5c4a0239e66f@kernel.org> Date: Tue, 30 Jun 2020 10:19:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200629081531.214734-5-vaibhavgupta40@gmail.com> Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29. 06. 20, 10:15, Vaibhav Gupta wrote: > 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 From the driver's POV: Reviewed-by: Jiri Slaby > --- > 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); > -- js