From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B040C433EA for ; Mon, 20 Jul 2020 14:28:52 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3DE92065E for ; Mon, 20 Jul 2020 14:28:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cm5XgV/y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3DE92065E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9684886416; Mon, 20 Jul 2020 14:28:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r1Pn0LD1k80P; Mon, 20 Jul 2020 14:28:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id E0159861CD; Mon, 20 Jul 2020 14:28:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C5176C0894; Mon, 20 Jul 2020 14:28:48 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2E764C016F for ; Mon, 20 Jul 2020 14:28:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1ABAF85AA1 for ; Mon, 20 Jul 2020 14:28:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12Gqty76HqG5 for ; Mon, 20 Jul 2020 14:28:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8E20485A00 for ; Mon, 20 Jul 2020 14:28:47 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id j20so9128714pfe.5 for ; 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=i01PksXBZXqTorJQlRRdbiiUzFcVdPWpFltvSjJSh/wVpFXNdh8L7Fh5V5eCNjEpYT 3bi8u3TonxBu19ksI9311WyNsCe9+wFaAK2EriFc3Odp72N0jW50yTiCAJIgmXaSpLNZ yJp528S6QfRRiWYcxabh1jx0IaC5Ph0JHl7zfr/ZX7eqHqt4KypYH6uPfn+t0eSSGOLF Vu86URW4A1w94VZA/j3MaQEhivp75PULWiTDxMH++0xtCplc1bAX5xUcT9pNpLhfVFgC 5dVKhxixdWujUzk5+EViJt9Z9uvUSttoJVKReYh4Lzef8wN0mU8T74A+h0HG1Kj1eRVp 9gnA== X-Gm-Message-State: AOAM530kDQnSqf1hlKQWTzj8rwa/S/Bh8MAKXN5XCu/QfXuhdFzxWmW6 tpQ7RtQPBDpE/RgyEfaGves= X-Google-Smtp-Source: ABdhPJxkd48eXlvOgVHcFNHC7hs+LWba48WNoCpqQ0EXWeCyVxMv2V7/q3ybFxEBtrVMabJk1BAYAA== 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 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 Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vaibhav Gupta Subject: [Linux-kernel-mentees] [PATCH v1] mmc: via-sdmmc: use generic power management X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" 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 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees