Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1696434ybh; Mon, 20 Jul 2020 05:08:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrfUgLp8+ylb7OXMvkfLUuoet9FOYIletKQFbMbwQpW/X68Zo2H4xxV1eH/ZBj9pzAFWcl X-Received: by 2002:a17:906:2e83:: with SMTP id o3mr20610085eji.261.1595246894257; Mon, 20 Jul 2020 05:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595246894; cv=none; d=google.com; s=arc-20160816; b=jqcbod0cYGF1IMX7r6R4fhr+jdFkKTshEDE3eSkFyiXMLxTkzzGrA/vbRKB4DjMLEN V+u51ri1nBwLW21kOPHpxH9jtUwOqdHJpk4BNBhm6pFTTmwR3caYuV6kIy4vuQt4zSdR EkEnxOdcPEmAK1tDiKV1AC8G7XF7BVVfHHkS87DrBlXkJN1zb9KNYcGuYFvDzVIC2k5R +b2+Q3JZ7P7X14/63nO1TahhRdz4OTDxldUiKmCp7ElTIiqZ/rfo5QIc2gylWk8rUbCK bRJT3a2I6OdcK1rxVvssbdT0++d4h6aG47KjHviZLrm4mgXPZ3PkWA3YDDKHqyh0Jrd6 19lA== 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=rWZKrOwq0rwjH5TwZ+UuKWlHddegJY7Nfmtdu4+t0zs=; b=UoDwRjV6MxpraBxHOvWl8xpkrVDcDpvAfpRUpuaoSWo72226pFxWmoDB2LBBdgaaZi CGfaLrHa6HwH5VrMPy4OsE7Nt8DVunZHKQiO1eI32kHLBAxTUVz5eZKMdVHHLpoKsWZ5 fI32s4sj25P2GWVt3ZqXNImDvackkLs4iUxcB9OP0HEL7QJjL1HR3zsrDlM3K/7Nyecj mWxlq+thg5nh3ckB9a0kkRYdAzHtgFEM98fvqKlfKDk3xTcJcHwUCDLB27dtII4Qhlg9 PrOa2ruxpRXmiCIrt/maQNdGcJAIhCKjZJAUpcxSvodeSAkHBpFiNVXA+bARLXg+0+qH BGyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XzUCvGsl; 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 cx20si9621501edb.568.2020.07.20.05.07.50; Mon, 20 Jul 2020 05:08:14 -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=XzUCvGsl; 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 S1728700AbgGTMHg (ORCPT + 99 others); Mon, 20 Jul 2020 08:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgGTMHf (ORCPT ); Mon, 20 Jul 2020 08:07:35 -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 7EFC4C061794; Mon, 20 Jul 2020 05:07:35 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f16so9992958pjt.0; Mon, 20 Jul 2020 05:07:35 -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=rWZKrOwq0rwjH5TwZ+UuKWlHddegJY7Nfmtdu4+t0zs=; b=XzUCvGslWr8de/Lj8121/tEpnZIfr0ColO1QujuDd9enBJsHTsaoQhN+0ZH/29Wtpf u4b9lZRjGc02DRjbZ6I5Zg+w/FOn+3Uk87EPegYpYGXH1Ss8wKvggR5hXVSkK9USTHxc RWcpG5sfF2gHaZ0tNIQjvJ9jxtnBUJjQfjM9g0UyzaZPQbtBId1QEb1/jI4CO6FI4l1F F3ufHVkPlhFeR1YJBosKSgagBgsy+9wxBZSwQ3+JEVwAmn1nTqlN+TR+W2khuxL+hcCu cdwd+U2jp+1p4lHdYacGNIYSunMdY5dalww2HdoEhX8fPlavAXTeoubhsKHOHO90DM6A SVWw== 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=rWZKrOwq0rwjH5TwZ+UuKWlHddegJY7Nfmtdu4+t0zs=; b=RnMQviLzU09ts1i7gP3nvvdbL36bGeaLSsX+ZXFuJFIM/HbDggIQZGqrIKa0Q7dEts R86pmFs/M2XsPyXXrTiSb9rngAeThyGbGxjaMEQE5NTr/8JHS2zqxBPrvek9Vh5W5vle es0mhUaFCQPYwpNOLe9jM37K2aryAhavRCiWrOmhMb2G7E3ri4yGwDt8wNb65FmLa93R J7bvfvBGFQCSr2Ac7TDENGvN9tq+qSRKeW2jvGI6rqgHB+Uo8h2eNqbUxnsJ4IrBMpP5 +fMuOeM4JGUjkbD2pn9LV2oU15KsQZRrYbNVM3+fzH3momHqYT77Jw7wYAhsyu1cXii0 B+uA== X-Gm-Message-State: AOAM533I0Yr7b4vMITr682LwY0zcN3Xa4xs8vMrnRGySq9v4i38xXL4V fP1K4K2GYCD4+iLzOngPDj8= X-Received: by 2002:a17:90a:e017:: with SMTP id u23mr15893404pjy.137.1595246854880; Mon, 20 Jul 2020 05:07:34 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id 141sm16777668pfw.72.2020.07.20.05.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 05:07:34 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Greg Kroah-Hartman , Jiri Slaby Cc: Vaibhav Gupta , linux-serial@vger.kernel.org, Shuah Khan , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH v1] serial: pch_uart: use generic power management Date: Mon, 20 Jul 2020 17:34:15 +0530 Message-Id: <20200720120414.399961-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 Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state(), pci_enable_device() and pci_set_power_state() to do required operations. In generic mode, they are no longer needed. Change function parameter in both .suspend() and .resume() to "struct device*" type. Use dev_get_drvdata() to get drv data. Compile-tested only. Signed-off-by: Vaibhav Gupta --- drivers/tty/serial/pch_uart.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 40fa7a27722d..67aca8cb9cd4 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -1857,41 +1857,24 @@ static void pch_uart_pci_remove(struct pci_dev *pdev) kfree(priv); return; } -#ifdef CONFIG_PM -static int pch_uart_pci_suspend(struct pci_dev *pdev, pm_message_t state) + +static int __maybe_unused pch_uart_pci_suspend(struct device *dev) { - struct eg20t_port *priv = pci_get_drvdata(pdev); + struct eg20t_port *priv = dev_get_drvdata(dev); uart_suspend_port(&pch_uart_driver, &priv->port); - pci_save_state(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -static int pch_uart_pci_resume(struct pci_dev *pdev) +static int __maybe_unused pch_uart_pci_resume(struct device *dev) { - struct eg20t_port *priv = pci_get_drvdata(pdev); - int ret; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, - "%s-pci_enable_device failed(ret=%d) ", __func__, ret); - return ret; - } + struct eg20t_port *priv = dev_get_drvdata(dev); uart_resume_port(&pch_uart_driver, &priv->port); return 0; } -#else -#define pch_uart_pci_suspend NULL -#define pch_uart_pci_resume NULL -#endif static const struct pci_device_id pch_uart_pci_id[] = { {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x8811), @@ -1945,13 +1928,16 @@ static int pch_uart_pci_probe(struct pci_dev *pdev, return ret; } +static SIMPLE_DEV_PM_OPS(pch_uart_pci_pm_ops, + pch_uart_pci_suspend, + pch_uart_pci_resume); + static struct pci_driver pch_uart_pci_driver = { .name = "pch_uart", .id_table = pch_uart_pci_id, .probe = pch_uart_pci_probe, .remove = pch_uart_pci_remove, - .suspend = pch_uart_pci_suspend, - .resume = pch_uart_pci_resume, + .driver.pm = &pch_uart_pci_pm_ops, }; static int __init pch_uart_module_init(void) -- 2.27.0