Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1797782ybh; Mon, 20 Jul 2020 07:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsFOY4LFWUGpYwXs/LXGUB9jpKLZ08ci4u64AuwUeoa20e6MPxykQq9GzvzAtHI5L92cfJ X-Received: by 2002:a17:906:4a87:: with SMTP id x7mr19375902eju.44.1595255386136; Mon, 20 Jul 2020 07:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595255386; cv=none; d=google.com; s=arc-20160816; b=vJlJJd4m9dhEEYeLGZ+YW69w0/27Rt+Fm84YegG1bXG/YPx7WMVRUiCeLrOAHa3YwA 7g2CWns+E3FbuZHwtz5jR36mYYMkd4caRAKs2Fy5Je5KNpLtw6KDiGVQElobZO42ja2E sTM+X7BnGFjxkL9QMNb6nu7xermr94Y/2Mm2L8Hz0ZKt5VK90tQ4uwQdCi9kha/wSP+6 NPPDdBeXRPZ2GNY+hLdVpaZqCIicYAtoyoCwHjioUWLYrLRFV5gBeeHi1igT/OZQI3Ud sjOkUKWzrZ8FkXAf4+M7++crCXdTbMcLvpofT/AG/03HTZQ7kGiUqOFJpaRGS3a5pFhs oaPQ== 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=3FlUkctU/9Z8JymGDkG+Bf/RRrvEHqZ+B4t/lCBxEH4=; b=BIObDDSE+RI6tZn/hRuu60oEAwSLkd9c5ZTT2nwb3tH4dEZBZnOwZ1Xt7Ydh8md8iu bWJT61jNkrkijMWPiY6Dx5seCZ1PFDocUSeXqIIUp6e6BPcJgWWbTSlPZwpeXhSWg0v3 /M1MWTxfI53iB5izRUazqJ4Wbll2jjRa3aaijSNqIjwHa/zNc6FtDdIR74lo1IXB8uqs yZoBiTieiBb8wyOFqZWiJFc691QN/ECV5SwEBZVxkXLudxS+iJa8j1mblLMRJsgRMq0u bxtwdkhPY3keNAH7zp3qoB6yu7uAC5g1Z/mNDVhwYEIUwZR8MtIukrJUpIoFe5ew98dN QVeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="cm5XgV/y"; 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 b12si11085321edq.471.2020.07.20.07.29.22; Mon, 20 Jul 2020 07:29:46 -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="cm5XgV/y"; 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 S1728811AbgGTO2t (ORCPT + 99 others); Mon, 20 Jul 2020 10:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728802AbgGTO2r (ORCPT ); Mon, 20 Jul 2020 10:28:47 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 947EBC061794; Mon, 20 Jul 2020 07:28:47 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id z3so9119274pfn.12; Mon, 20 Jul 2020 07:28:47 -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=3FlUkctU/9Z8JymGDkG+Bf/RRrvEHqZ+B4t/lCBxEH4=; b=cm5XgV/yWFRRE9EHS24/EqW66GsPEs3000VF0aMvp2QSusnxfH2P/N4LTQUujMF1lm tt8o/sRaKVJvTG/iFb3yhYuU0kldoxnm4qPQ0LRe0leRrGZAApAziZVNeLfDewWpDy5f xhRvGSkzenzm6zNKBtqPMohpWbINR40PZKwL2najXJv/1nQM+Sl0hgRo8EWIe3Mtltx9 iHq6HNwDU49y7+AqKuKnMSr5YTVl+ZuN2ejZlRSIKMXM2yKbqc2NgkbOtVoHQXYK/Ow7 4Y2F4pG1Nl/Xd1o88dc795XHR5KzUsCG6GnSJOmSkuyLDufEefqpkWcGpk64gX1p74mH 4n5w== 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=3FlUkctU/9Z8JymGDkG+Bf/RRrvEHqZ+B4t/lCBxEH4=; b=RgwQFkgEDla5Cj68CYGV/Gxdle6SV5ICy2lDqlzSQmdahVS5N5iwK0PydUHvtIW0O/ lJMmmUjYxMRo5N9ILM3+7PJD2xPdndcGxXo2sP7EcaWwxyCKuKRtMPQWxyhwScQ/C+nG DvzQzCO2Hl+epcF+gPqhrJR3ywk7Tggr5E+iqTaOuy0EAW/AYwX7xCNwwkQkdkIL92Mf bVkmIwUPven1oaDQvMJJYCvTqT+3grgHXrmtHgK9HwDfzP+WOW0re0tt4R7q5V95oP95 UgLLgVjWfu4thliTrIRlHqwxV+Q+As7spc6mbYPWBDUfdz8tR76Clm0wuMVOFqznLo5M 0uqQ== X-Gm-Message-State: AOAM5309X04ZN7buHIDQsAuEv6G2IL/SabpMYjtdpotXNmvGtZuZanJF CaZeFfuHbJ8RdbUChOr3QSE= X-Received: by 2002:a63:c049:: with SMTP id z9mr14766666pgi.353.1595255327105; Mon, 20 Jul 2020 07:28:47 -0700 (PDT) Received: from varodek.iballbatonwifi.com ([103.105.153.67]) by smtp.gmail.com with ESMTPSA id i67sm17581282pfg.13.2020.07.20.07.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 07:28:46 -0700 (PDT) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bruce Chang , Harald Welte , Ulf Hansson Cc: Vaibhav Gupta , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: [PATCH v1] mmc: via-sdmmc: use generic power management Date: Mon, 20 Jul 2020 19:56:04 +0530 Message-Id: <20200720142603.577323-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/disable_device(), pci_enable_wake() and pci_set_power_state() and 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/mmc/host/via-sdmmc.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c index ef95bce50889..49dab9f42b6d 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c @@ -1220,9 +1220,7 @@ static void via_sd_remove(struct pci_dev *pcidev) pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device); } -#ifdef CONFIG_PM - -static void via_init_sdc_pm(struct via_crdr_mmc_host *host) +static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host) { struct sdhcreg *pm_sdhcreg; void __iomem *addrbase; @@ -1256,30 +1254,27 @@ static void via_init_sdc_pm(struct via_crdr_mmc_host *host) via_print_sdchc(host); } -static int via_sd_suspend(struct pci_dev *pcidev, pm_message_t state) +static int __maybe_unused via_sd_suspend(struct device *dev) { struct via_crdr_mmc_host *host; - host = pci_get_drvdata(pcidev); + host = dev_get_drvdata(dev); via_save_pcictrlreg(host); via_save_sdcreg(host); - pci_save_state(pcidev); - pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); - pci_disable_device(pcidev); - pci_set_power_state(pcidev, pci_choose_state(pcidev, state)); + device_wakeup_enable(dev); return 0; } -static int via_sd_resume(struct pci_dev *pcidev) +static int __maybe_unused via_sd_resume(struct device *dev) { struct via_crdr_mmc_host *sdhost; int ret = 0; u8 gatt; - sdhost = pci_get_drvdata(pcidev); + sdhost = dev_get_drvdata(dev); gatt = VIA_CRDR_PCICLKGATT_PAD_PWRON; if (sdhost->power == MMC_VDD_165_195) @@ -1294,32 +1289,20 @@ static int via_sd_resume(struct pci_dev *pcidev) msleep(100); - pci_set_power_state(pcidev, PCI_D0); - pci_restore_state(pcidev); - ret = pci_enable_device(pcidev); - if (ret) - return ret; - via_restore_pcictrlreg(sdhost); via_init_sdc_pm(sdhost); return ret; } -#else /* CONFIG_PM */ - -#define via_sd_suspend NULL -#define via_sd_resume NULL - -#endif /* CONFIG_PM */ +static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume); static struct pci_driver via_sd_driver = { .name = DRV_NAME, .id_table = via_ids, .probe = via_sd_probe, .remove = via_sd_remove, - .suspend = via_sd_suspend, - .resume = via_sd_resume, + .driver.pm = &via_sd_pm_ops, }; module_pci_driver(via_sd_driver); -- 2.27.0