Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp253856pxa; Tue, 4 Aug 2020 23:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZhk3A+CY0/ecdx1n0mUirAV0IaYnMpCxGIjcavzyLDxxp86ZQJ/A46inDcaJV0JfOS76Q X-Received: by 2002:a17:906:248d:: with SMTP id e13mr1659789ejb.169.1596609352660; Tue, 04 Aug 2020 23:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596609352; cv=none; d=google.com; s=arc-20160816; b=gve7srJnjSD69xxGvnpSHxeLUYFQ4xn8uJ3+Ex5WkSaWxCn/SnUjotkJIjLDJXVlzp JOXUMvMFMWldIjHf4w0lKleiIjOKxVBlYgh0peOSTou0eMgM27wv8k2WTn1vpAKEbl2X mDSifVJlU5UQ+z3zv8rfd72aP+ActJW0n2JDcDVZ0J3poSKEs3JjL1LTtG3yJC9DxlEA r2F3zhvNCldjhfRzqDTIt4g7ppGDQq36S4pkjKNot0fL2+oB6HdnZGnnmKlTfkEPu4LC C8JJ+VVOBwf7OimnzEbRTqv8SsK4Q5KZZBMA7kUwgq7NTwSE11sWdTjaJcXM1+sA1aKM 9GyQ== 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=Izm9CrPLohryxU3MDcr4vOdCg89l4cBAjIrruJENdp0=; b=IzxgG/ZjznMfVw8Vr7gMlavCro1YxKev1Fjh1BlzYbbPbn8bd+EgmTRtgPdaIpqZqt 4AB7KVtyR0Th8qWa81UwHLJf8L3O1PM3I7xH/urZSVwFMUzHb/qB5qpUnzx+7j1h2vm8 7HHnECKUF1bJyp3Mvobvs+PELiQi2vmuSuchNDXW+WZjGIQvGMRBhzJfvgA6PE8eApRw Ta/ANWMQ7ZW8zgnjoW3V31VMPq2FBcRDtOj2PyaPLDui3CesKtuO1N8QLYMQWWkUT96l gcSuuhjk8FotxEhrT7WYTqONLJ+UImdSjdv+Usxeyj/hmrBuybRKNAIp/pNK+YsEbvTy G80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ckLt2Hja; 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 f2si679354edw.385.2020.08.04.23.35.29; Tue, 04 Aug 2020 23:35:52 -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=ckLt2Hja; 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 S1728184AbgHEGee (ORCPT + 99 others); Wed, 5 Aug 2020 02:34:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726459AbgHEGee (ORCPT ); Wed, 5 Aug 2020 02:34:34 -0400 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDEC2C06174A for ; Tue, 4 Aug 2020 23:34:33 -0700 (PDT) Received: by mail-vk1-xa41.google.com with SMTP id b6so8178477vkb.6 for ; Tue, 04 Aug 2020 23:34:33 -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=Izm9CrPLohryxU3MDcr4vOdCg89l4cBAjIrruJENdp0=; b=ckLt2HjalR4fWHRxNoET0unnn2lxQb7Gdmn+8jgKHcHj6KUBZNW5cYd1C0og9dqMkm rTunozbRodwFbCT5D9790M813rgEb3Ich+lQg9nezzX+bifywuafpGRryopnFhr4bvnf siuDdd+tAlWXfwnqGTk620BIEuk84JAyps9JgLbJRFboTH6lKk2HCcVOFLT//ZjxpvzH KlagF+zSZFnCTOMZRCWhaOQXynxfx8ZCAfhtw6Rb35f0cfZR3g0YMQuGP3LlFUBS/RDo ZRGOq+yPKId5vZfkp0vwwnSyQ5/NCDoI2r2G+w0+gMAgAKuT+GYqiLBpdfiWZ9Fw0L/9 wsiA== 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=Izm9CrPLohryxU3MDcr4vOdCg89l4cBAjIrruJENdp0=; b=MbBF+utHMsdP/m1/WXSyqHDylEFn6Isr10MyrWlqY1NN/ajKw1U9iog0tTnROlVaLB 9SEjLVGB+ECZp+3cJWYFBnTP/sa/p2o1/BHDp0i4+jq2XzY2yzDI7s8ZumppPDAbTIRP 3ztmXgS+jzYGxsINtkcgFtbKgJPBIqNbFpIsbCC37oAtp0U8BBHOkUiw/+qxSh1fzURg 6DXPpNoAqZY7Ik0hvCx79tVxO1zVelJRnjS5hjgcgSBhM/VtRFwc5SEz0i+s28bTN/Oh LOv8oqly+mAfE8xLKGhK0HChgrlJWy55y/nYT48MdHs8FeQpdZG1CvFAw/kWNxWEBqbH kdBw== X-Gm-Message-State: AOAM532DIYzi6MpWYI9aimXNBtNKNN3emRwsJsFCuff94riC2qaJzkCE cTbseEOK/gB9ICNUe3HY7SapBhXRI6AeiIvM9FjN8A== X-Received: by 2002:a1f:7c45:: with SMTP id x66mr1304488vkc.53.1596609273140; Tue, 04 Aug 2020 23:34:33 -0700 (PDT) MIME-Version: 1.0 References: <20200720111625.306681-1-vaibhavgupta40@gmail.com> In-Reply-To: <20200720111625.306681-1-vaibhavgupta40@gmail.com> From: Ulf Hansson Date: Wed, 5 Aug 2020 08:33:55 +0200 Message-ID: Subject: Re: [PATCH v1] memstick: jmb38x_ms: use generic power management To: Vaibhav Gupta Cc: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Maxim Levitsky , Alex Dubov , Shuah Khan , Linux Kernel Mailing List , linux-kernel-mentees@lists.linuxfoundation.org, "linux-mmc@vger.kernel.org" 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 13:19, 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_set_power_state() and pci_set_master() 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 to_pci_dev() and dev_get_drvdata() to get > "struct pci_dev*" variable and drv data. > > Compile-tested only. > > Signed-off-by: Vaibhav Gupta Applied for next (a while ago), thanks! Kind regards Uffe > --- > drivers/memstick/host/jmb38x_ms.c | 38 +++++++++---------------------- > 1 file changed, 11 insertions(+), 27 deletions(-) > > diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c > index 0a9c5ddf2f59..2aa9592917d9 100644 > --- a/drivers/memstick/host/jmb38x_ms.c > +++ b/drivers/memstick/host/jmb38x_ms.c > @@ -793,11 +793,10 @@ static int jmb38x_ms_pmos(struct pci_dev *pdev, int flag) > return 0; > } > > -#ifdef CONFIG_PM > - > -static int jmb38x_ms_suspend(struct pci_dev *dev, pm_message_t state) > +static int __maybe_unused jmb38x_ms_suspend(struct device *dev) > { > - struct jmb38x_ms *jm = pci_get_drvdata(dev); > + struct jmb38x_ms *jm = dev_get_drvdata(dev); > + > int cnt; > > for (cnt = 0; cnt < jm->host_cnt; ++cnt) { > @@ -806,26 +805,17 @@ static int jmb38x_ms_suspend(struct pci_dev *dev, pm_message_t state) > memstick_suspend_host(jm->hosts[cnt]); > } > > - pci_save_state(dev); > - pci_enable_wake(dev, pci_choose_state(dev, state), 0); > - pci_disable_device(dev); > - pci_set_power_state(dev, pci_choose_state(dev, state)); > + device_wakeup_disable(dev); > + > return 0; > } > > -static int jmb38x_ms_resume(struct pci_dev *dev) > +static int __maybe_unused jmb38x_ms_resume(struct device *dev) > { > - struct jmb38x_ms *jm = pci_get_drvdata(dev); > + struct jmb38x_ms *jm = dev_get_drvdata(dev); > int rc; > > - pci_set_power_state(dev, PCI_D0); > - pci_restore_state(dev); > - rc = pci_enable_device(dev); > - if (rc) > - return rc; > - pci_set_master(dev); > - > - jmb38x_ms_pmos(dev, 1); > + jmb38x_ms_pmos(to_pci_dev(dev), 1); > > for (rc = 0; rc < jm->host_cnt; ++rc) { > if (!jm->hosts[rc]) > @@ -837,13 +827,6 @@ static int jmb38x_ms_resume(struct pci_dev *dev) > return 0; > } > > -#else > - > -#define jmb38x_ms_suspend NULL > -#define jmb38x_ms_resume NULL > - > -#endif /* CONFIG_PM */ > - > static int jmb38x_ms_count_slots(struct pci_dev *pdev) > { > int cnt, rc = 0; > @@ -1030,13 +1013,14 @@ static struct pci_device_id jmb38x_ms_id_tbl [] = { > { } > }; > > +static SIMPLE_DEV_PM_OPS(jmb38x_ms_pm_ops, jmb38x_ms_suspend, jmb38x_ms_resume); > + > static struct pci_driver jmb38x_ms_driver = { > .name = DRIVER_NAME, > .id_table = jmb38x_ms_id_tbl, > .probe = jmb38x_ms_probe, > .remove = jmb38x_ms_remove, > - .suspend = jmb38x_ms_suspend, > - .resume = jmb38x_ms_resume > + .driver.pm = &jmb38x_ms_pm_ops, > }; > > module_pci_driver(jmb38x_ms_driver); > -- > 2.27.0 >