Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2706363ybt; Mon, 22 Jun 2020 05:11:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytJ1+KcvqKIuy4J/2u+QjP38Wo4/M49QVa0YEBaWzScHOmFcNWyVhW+Qy5dQAr4wq5WOGE X-Received: by 2002:a05:6402:1c87:: with SMTP id cy7mr16985624edb.354.1592827872317; Mon, 22 Jun 2020 05:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592827872; cv=none; d=google.com; s=arc-20160816; b=tQYvG1EiLxd3azcZJsNmzj6cLJyUHVC8+iBS1eFvbZ+e9qUpAC64Oro+rIFmju46lf eChN+8jahbHv1Mtd7QNgesE6ad4ksQXMdU1IMxoPrhELZ4tM2JsIt0ktG087sOqbM5f3 Q99s1fi+EizKzIuB50ux69RT8I5h288clISsFtVe+0k9SprJpB7KFjb5SOZSEXFOG8Ct v8BggfXv4dCTVbf5tLYkMjXcN71fY1Cl4ZpPAskjxUyeVsBA/XuH9BeqqduZsIzY426h WpCkG5c4TR/uIrIUEScfLQTP459j9Vgv4SateA7M29p0TdNtBDcy0WpWW8BtTq0hSwTM 7qTA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Ou9Z/Ox/FwTNRKwSYB37fOjhliFS4VQZs0FMTQAQC5I=; b=xaB/i9DCnCPhwz89YELM+Z0iQCoWnEBHBpNYEOVyT4bu3n3F0ovvt2Ks+gVqIICBCv NuEbwTclzKjKtN7adjSvJDwhox6+5UScUST4v+i6ab4VaHawhzP3KnhbrOT9XZDMy1Rr 9j7nHAj21baDhMIiIfQ6m8220NmVpEEpNmQuOfvyc+V3SE+tKu8xLmrbuhXRl9hbtV8l wzK56L8zcx0RHL4c0E1/qKd4SKveFAT6kBpl9IA2mGTVQrUaw+OCarXnIby0/D3r8Nhf R9J4rRSMX/13r4uGCPwPpaYKuPVjSbamc2mt9gbAdjTw4ORPv2TDEi4Ry41Hn3h5BoZ8 kEBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PSqV8oLC; 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 y16si8964307ejb.177.2020.06.22.05.10.49; Mon, 22 Jun 2020 05:11:12 -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=PSqV8oLC; 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 S1728097AbgFVMHA (ORCPT + 99 others); Mon, 22 Jun 2020 08:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgFVMHA (ORCPT ); Mon, 22 Jun 2020 08:07:00 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5630FC061794; Mon, 22 Jun 2020 05:07:00 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id ga6so8073954pjb.1; Mon, 22 Jun 2020 05:07:00 -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:mime-version :content-transfer-encoding; bh=Ou9Z/Ox/FwTNRKwSYB37fOjhliFS4VQZs0FMTQAQC5I=; b=PSqV8oLCQOb7Tmzo31U7GZn+L294sHL3jjZIZwdpZ3FcDVcSyU1+IKfDX63ylkv/U4 cxSiNOGrbjokKMbcEbqSSmXGoG/DxlJXTUeWnwG8oe2W4NvYHc+QTgMLdeFszPyvZzTr Uzy4Yp5J5K3unoJq0TgbjANslW/6rHLf7A6fVqwz3EKHMneyiAj1UNL2HPGKIOgPwSrU dI+xlWn2/AiZHK7rJsdSCzFPEXgCvEZggaeyoQn3UPzhHwkiGrKjsyBFZz8xKnMxFEyY MQSDu4D1qbSgLRiP83rr6LjNfHhOQGV/FQ7ZDotrV8OUMqgqjDfuDcloOLbC51wQTYX5 vIcw== 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:mime-version :content-transfer-encoding; bh=Ou9Z/Ox/FwTNRKwSYB37fOjhliFS4VQZs0FMTQAQC5I=; b=RerVJP3QxlIe/B1MD7apMDvtCx87SCfZnHe+ONCCweN9R2hUtT6DrmOYOwyckXoiN1 Vzt1cz3QWkxaRyiIHzjC/yiUltKxY9sFe7NdK1lWoOBPFVFEoMz+mZS1ZkE4sv1UwQzt qoKoegBAVGbo06/ycdbse5tcSWxlfzZjNVX7ipQ75SaaHikmb0SyEGF7gmT6KHFzNzIu CF17b9QGsJlTj+WQQCdMSkYpB0xZDZA5ufHciPFBtAljJSNgF56dMpJJ0tFIlAY3vE0U kph+TuG+0f6jkNZunM++XgPEycJhy+0F0Jb052tvuTjE2rm2U7DiYLdwmzqlv2U4ypZD RCXQ== X-Gm-Message-State: AOAM5327PUOm6wWYJVnYWMPzVqH4EiHJXWJ6LcivZSw78RN9rrI4mXM7 Nm3p0jxVg11C80xbzLG3wv4= X-Received: by 2002:a17:902:7008:: with SMTP id y8mr20024907plk.84.1592827619747; Mon, 22 Jun 2020 05:06:59 -0700 (PDT) Received: from varodek.localdomain ([2401:4900:b8b:123e:d7ae:5602:b3d:9c0]) by smtp.gmail.com with ESMTPSA id j8sm13195391pji.3.2020.06.22.05.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 05:06:58 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta Cc: Vaibhav Gupta , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org Subject: [PATCH v1] [media] saa7134: use generic power management Date: Mon, 22 Jun 2020 17:32:30 +0530 Message-Id: <20200622120229.89610-1-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.27.0 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. The required operations are done by PCI core. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/media/pci/saa7134/saa7134-core.c | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index e4623ed2f831..eb01109d4f98 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -1370,10 +1370,8 @@ static void saa7134_finidev(struct pci_dev *pci_dev) kfree(dev); } -#ifdef CONFIG_PM - /* resends a current buffer in queue after resume */ -static int saa7134_buffer_requeue(struct saa7134_dev *dev, +static int __maybe_unused saa7134_buffer_requeue(struct saa7134_dev *dev, struct saa7134_dmaqueue *q) { struct saa7134_buf *buf, *next; @@ -1397,8 +1395,9 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev, return 0; } -static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) +static int __maybe_unused saa7134_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 saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); @@ -1428,21 +1427,15 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) if (dev->remote && dev->remote->dev->users) saa7134_ir_close(dev->remote->dev); - pci_save_state(pci_dev); - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); - return 0; } -static int saa7134_resume(struct pci_dev *pci_dev) +static int __maybe_unused saa7134_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 saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); unsigned long flags; - pci_set_power_state(pci_dev, PCI_D0); - pci_restore_state(pci_dev); - /* Do things that are done in saa7134_initdev , except of initializing memory structures.*/ @@ -1490,7 +1483,6 @@ static int saa7134_resume(struct pci_dev *pci_dev) return 0; } -#endif /* ----------------------------------------------------------- */ @@ -1522,15 +1514,14 @@ EXPORT_SYMBOL(saa7134_ts_unregister); /* ----------------------------------------------------------- */ +static SIMPLE_DEV_PM_OPS(saa7134_pm_ops, saa7134_suspend, saa7134_resume); + static struct pci_driver saa7134_pci_driver = { .name = "saa7134", .id_table = saa7134_pci_tbl, .probe = saa7134_initdev, .remove = saa7134_finidev, -#ifdef CONFIG_PM - .suspend = saa7134_suspend, - .resume = saa7134_resume -#endif + .driver.pm = &saa7134_pm_ops, }; static int __init saa7134_init(void) -- 2.27.0