Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp253885pxa; Tue, 4 Aug 2020 23:35:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL3VokMWubf9tXW0qhhXitQgFqgUzQOUknlU51RqFGyKWDC8qERfNjw6w8OatQX/cugMDB X-Received: by 2002:a17:906:3acd:: with SMTP id z13mr1805246ejd.69.1596609357052; Tue, 04 Aug 2020 23:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596609357; cv=none; d=google.com; s=arc-20160816; b=kJzv+h1dKzshSkJzKYoRo82C44FfTt5Vrgz7VBITI3/sppQJ7a5izV6ij4QYZ3q3jb tvlwKRUMF/6A1bv00wa3arQK7aRh3haJM7uM+iZxDnvAdr+aWXqgDRFoo9ggoKFubpDj U4u16LTStJN2ExDLOFwn4Il/gU6XeQOwlhpL04mdKQ78txgFDnNJ8TpkSaTb4l2OScx9 2A0oDYfYb9TCK4aBVW12Vt561+Vz2S2YnSKmVeCmBq84I7QNsUiOYes/hgmx3iHtJxi2 p8XI9ttu67ySJvI9d95F0oZs9seRROz4QNZNZs3ZP9EA/xcdmKL9CatyCqYoqm8qqrMQ 8hvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d2ZiF+evfZ66+HifnXyioxGC5MxoHunhZYeIelbyLK0=; b=KuMcLceeQQ13XdfX5pOSw1K+xoIvz1acOGmwCVf2rn/PLgpoGh+zJab2qW0QFlE50d qlzyq7t04CEe+5J26Mf/oEkhCl1d9trLPMRlvZaWjfgRptu/kWKAGKR13r1ovfUFRcRu 73gi3IyjYvmHZw8naeUPIEUzPURBJTrsbkmNGqtR5YB9ta0y6J5pSaz5KMYqnAfmGew2 Dpj/cIlXQla25HMNUYtPMr9GXZ8oL+vUPrr5BxsbhAVGvQfVChJ7VHq4ixmfmk0l3QGg FKo08t+HCkmg5t1sbhIznqSciZbObdKd/wekcJrYTaHmzwvf0brSANmwT7xjYBDfZk/p cF3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pp1F3Gn3; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si708520ejb.106.2020.08.04.23.35.34; Tue, 04 Aug 2020 23:35:57 -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=@linaro.org header.s=google header.b=Pp1F3Gn3; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbgHEGep (ORCPT + 99 others); Wed, 5 Aug 2020 02:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbgHEGem (ORCPT ); Wed, 5 Aug 2020 02:34:42 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F677C061756 for ; Tue, 4 Aug 2020 23:34:42 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id 1so17473559vsl.1 for ; Tue, 04 Aug 2020 23:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d2ZiF+evfZ66+HifnXyioxGC5MxoHunhZYeIelbyLK0=; b=Pp1F3Gn30EM5c6aAAsf4shLRD0JwsRXxIpCpLuM6vKt8rKp33GZvzZ+lkDYgPiLsXf eZwJXF2sV30Uy39U3ktkOCtPYxfRQDoKF8HyLrQ67D7BH1Cm1DDOl5XtHacb3vD3t33M ePteu5fZNSYNfBFgtbMuuYdHzw4y6ljHTkMVNGyB/Je9JUXjGtCTsvIo2HYb4vh45Cj9 W+Kg3fsbkojGqSnPmK36SFLOcR82MXJZlJiWN5AW24RZaL+bAfHt7LVNvoy74RLeo6pR mauo67Usaupye6fc94QefbVEMyISOeirNMqzbZtMs9NJDtfjJK60+UIcTNdJDVAtNQ43 0VDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d2ZiF+evfZ66+HifnXyioxGC5MxoHunhZYeIelbyLK0=; b=XWH4pWP+tFhFKp6SeRQlF6/BPsaWPNXnm80E84639sQfmTsVSIk1IzGEXjBDKx0Emd ZmvnSrZPFDTf3f3BfaFaD2jk0Row6tz/qdoiJ5u6Tdo8HtBAM+CB5A3WvXpXcnwAEg3E 2xXKlnaLrO5OyL2PKKcsK1fzPnaOSjaz31QKkHw3xkTTVLG0rkuClyn5wvO4XgEhMaU5 HaJ9tj7snDSIfmdtUJ/0C1C7rCmFn/pfNUoYbpFDh6QnHs1lh8BJYMSoaWYBVsT0zw3u RBxMa9xohdv/Ys6B483/nXTBfW0VRwwDh9gb0ivXVVZXJb5eM5n+z+asXW/1DH62wIFu jtnQ== X-Gm-Message-State: AOAM531JCOscq3WVrMuLH/HRl/GyIgrKl34DRQBpCKiH1iQw31rLC9nK PDcyabrCMV/Ryy9e3cR9MTGbsY9DtQFj7zvsj/Oh7g== X-Received: by 2002:a67:8c06:: with SMTP id o6mr912216vsd.200.1596609281713; Tue, 04 Aug 2020 23:34:41 -0700 (PDT) MIME-Version: 1.0 References: <20200720142603.577323-1-vaibhavgupta40@gmail.com> In-Reply-To: <20200720142603.577323-1-vaibhavgupta40@gmail.com> From: Ulf Hansson Date: Wed, 5 Aug 2020 08:34:04 +0200 Message-ID: Subject: Re: [PATCH v1] mmc: via-sdmmc: use generic power management To: Vaibhav Gupta Cc: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Bruce Chang , Harald Welte , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Jul 2020 at 16:28, Vaibhav Gupta wrote: > > 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 Applied for next (a while ago), thanks! Kind regards Uffe > --- > 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 >