Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1785535ybh; Fri, 17 Jul 2020 00:38:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5r1t7MYO4fyqD92okyxfpoRWLa1be7HpL3wFYLr66iTh8Ar3fNpRn6xTYtLzGiCHKAH33 X-Received: by 2002:a50:acc5:: with SMTP id x63mr7720295edc.99.1594971517449; Fri, 17 Jul 2020 00:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594971517; cv=none; d=google.com; s=arc-20160816; b=e3NThDRVUS5T+lbM/FzQA87x/mHGJcl1A/iDobZIlnwSYMDCN2Q/OWUCpwJp3sWwvY Gw3obJjLta9RmirpuTzEBFtwUFIVTdkH1fvLU6RCGmknT3WJRBizbF+YeRZiVrDBOvpr jylfQ8cbEkUsbpVUbKpotbSz8FvazrlNR91TCM4HkHLFzMZQMISX5maTc78odzrSQWuE JnFEEw/q5iWVMHQQ70qfctwTYFrofCgGc1de4WnVKhuORB3w5mjW8hTJqi3jMPXFr8R1 x0W4N/pd1zKLxoDpvlVs123R4FbzQnRM9ftd6gpG8RQuKHmZq7wKGrVqQRt1GIa1cctu kFOg== 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=DRaWMxjlA+y9G9x8PTReSZmOggDcJdYbq3Dmt0Z1Wlg=; b=Yf8ZAOlR0Olwslv324q5d8v02In7cXxaI5QHvPQfmMnWzu3w+WM1dhf3UFhd//7pBw 08AQ53T8J+XyqdIy1DUl/gYsjUR6ctQuoDJZ8nZKLNHC3RxGnRBpIO85OL2sJ2KDfxy8 D8jxBp4dNcpnr5yrJBDal7aYLuZfkP0ZNni70Jjvx/QehH95qw0DzcNVl++wBGV1XfZG jL+BIrTleojEhq7dXzfeRQNKgfVLQmW0+pMT2H3GqavO80BCZ46LSPL6O6EJmtSxlY5k G9t99w7QRqF6M4BaBmSBARsx/vLfI8MQ9pG/Phh6b3U1gLwSVv+rJSq9rSSKtXLDCvK0 6Dbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bVorRNjU; 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 y19si4510861ejw.454.2020.07.17.00.38.14; Fri, 17 Jul 2020 00:38:37 -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=bVorRNjU; 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 S1728235AbgGQHgj (ORCPT + 99 others); Fri, 17 Jul 2020 03:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbgGQHgi (ORCPT ); Fri, 17 Jul 2020 03:36:38 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11FFDC061755; Fri, 17 Jul 2020 00:36:38 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id b9so5100484plx.6; Fri, 17 Jul 2020 00:36:38 -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=DRaWMxjlA+y9G9x8PTReSZmOggDcJdYbq3Dmt0Z1Wlg=; b=bVorRNjURfPpm/ZSKqoTOVMR2C7tuSII04c0fZPgoqxiw+TqPgU/zea0VfdX0tY28p ePSlmNOrYHl/3msFvHYRzacBAnn11tqA5lVhGLjVv6mol7+1E/4VpY5rXHIQ0ZOx0WE4 2Q2RkzYpgg1DzaK/lHWk3cGOH5KI68m8hHaLc/YMx4LQH6CvEIgNLXsfjXmBp1s8nUaT ape+r6gbYCgo+UK5Yb9FxiRzfdE1G83JPO91er6wTnZvhrv0WEUN9OYyz8i+fv8HJTXz KJjifQgJYzpqLB6OJBPCOKcApR2jhUIyHZZqHs+NqMMXceyWaCV/youL4Yf0MTxXCx8S /wqA== 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=DRaWMxjlA+y9G9x8PTReSZmOggDcJdYbq3Dmt0Z1Wlg=; b=ejTz3E56hLgxQD8eVfLy5bQlu9taij3N8akI6gslafIDdCUSRDFhTY+HEy/E18xZ6v D9svgVH0g+pG3hEpvE0CDpzthY/gA5NJrBhIqueqTwLKhAfycunnAXzPMu/f2DSXOOx6 nVW9C6JGwn40Zyw6el9oYbPNf9s6oAZJyDmKVq6Yt4jFOQ6JJ8t7AryQV+yRQ4ed/BnH MRz+NzMRdwbLe+mEdjJoEeG4SrijBWG4Ae3Ukvq4GLsF2IQmYRmsl1b9j6K+z2vclv8o hdhzNN6lFtXhLupSV6hpV1AINhSbLMJBu5r09DH9XxTvEXC9TXuhKH02BcNopIu0E2+B bVvA== X-Gm-Message-State: AOAM530zNnoAYdP88UjtUF67ANvTr5kwsImNLRRJgIWYE80nyoFUv4n4 MgnuWMmKp5UJ+5AgSnd8Y9I= X-Received: by 2002:a17:902:8491:: with SMTP id c17mr6569011plo.262.1594971397589; Fri, 17 Jul 2020 00:36:37 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id z25sm6794704pfg.140.2020.07.17.00.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 00:36:37 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Mauro Carvalho Chehab Cc: Vaibhav Gupta , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v3 6/6] tw68: use generic power management Date: Fri, 17 Jul 2020 13:04:36 +0530 Message-Id: <20200717073436.249623-7-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717073436.249623-1-vaibhavgupta40@gmail.com> References: <20200717073436.249623-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 legacy PM, drivers themselves were responsible for managing the device's power states and takes care of register states. After upgrading to the generic structure, PCI core will take care of required tasks and drivers should do only device-specific operations. The driver was invoking PCI helper functions like pci_save/restore_state() which is not recommended. Compile-Tested only. Signed-off-by: Vaibhav Gupta --- drivers/media/pci/tw68/tw68-core.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c index b45f3ffa3de5..065420b09250 100644 --- a/drivers/media/pci/tw68/tw68-core.c +++ b/drivers/media/pci/tw68/tw68-core.c @@ -359,10 +359,9 @@ static void tw68_finidev(struct pci_dev *pci_dev) v4l2_device_unregister(&dev->v4l2_dev); } -#ifdef CONFIG_PM - -static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state) +static int __maybe_unused tw68_suspend(struct device *dev_d) { + struct pci_dev *pci_dev = to_pci_dev(dev_d); struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); struct tw68_dev *dev = container_of(v4l2_dev, struct tw68_dev, v4l2_dev); @@ -373,24 +372,19 @@ static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state) synchronize_irq(pci_dev->irq); - pci_save_state(pci_dev); - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); vb2_discard_done(&dev->vidq); return 0; } -static int tw68_resume(struct pci_dev *pci_dev) +static int __maybe_unused tw68_resume(struct device *dev_d) { - struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); + struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d); struct tw68_dev *dev = container_of(v4l2_dev, struct tw68_dev, v4l2_dev); struct tw68_buf *buf; unsigned long flags; - pci_set_power_state(pci_dev, PCI_D0); - pci_restore_state(pci_dev); - /* Do things that are done in tw68_initdev , except of initializing memory structures.*/ @@ -408,19 +402,17 @@ static int tw68_resume(struct pci_dev *pci_dev) return 0; } -#endif /* ----------------------------------------------------------- */ +static SIMPLE_DEV_PM_OPS(tw68_pm_ops, tw68_suspend, tw68_resume); + static struct pci_driver tw68_pci_driver = { - .name = "tw68", - .id_table = tw68_pci_tbl, - .probe = tw68_initdev, - .remove = tw68_finidev, -#ifdef CONFIG_PM - .suspend = tw68_suspend, - .resume = tw68_resume -#endif + .name = "tw68", + .id_table = tw68_pci_tbl, + .probe = tw68_initdev, + .remove = tw68_finidev, + .driver.pm = &tw68_pm_ops, }; module_pci_driver(tw68_pci_driver); -- 2.27.0