Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5251287ybp; Mon, 14 Oct 2019 18:32:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXZ5fkTrSTLk16aqUu8sgtG6tlDhHfKffpDBoXjwdYINp2Mxmh9dVokhxtXKovZlcha6oN X-Received: by 2002:a17:906:b74f:: with SMTP id fx15mr31570490ejb.69.1571103130916; Mon, 14 Oct 2019 18:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571103130; cv=none; d=google.com; s=arc-20160816; b=DcKNO3Y/iWrCz/8rfmTC9KOPdJguvP0h+E6k0UppzlpCqYkZ9cS5zSM+Np3YRY8k2L z45mAMvRG4DkfHhbh1grbevxVHjRiN+3CbnJ2floqse2h4qukvv3rrJoEX9hMiocWjD7 NjtRjzpvS0BdhOk/NzeDNNHFi0Fpd/zCqS8vI9JaKhqfo3nq1+eLHTgQDq/BJOzv/e73 wyqiNJxf44JscYT1TdB+389bY5z9iksUjcgklMYbHxmiTr/VGryfqHfOosmX+DgVD23k 0JPCnc/AVsQ3GqusoGGUd2/Ov7FOvRDMM1vbYR7UQPZjT1mzKfwOBK7VZQ9g0u7b2odr zydg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ff8Rekiu/6udpQKmkQB8J3DqRrIZp8ywGelr2OhSBMY=; b=mSQrUcfOXclL+AfTcXaCjtG2V8Fn4m6EO7G+XZsK+mOnV2SzhES2tKmvPSSNUYBpvL 87X1Cp0z9vOeOx+tYy1UQeTe0lv+ZVVrb2ylecbIn6Wc8cO2ILM6pNcatw7whdkzMSAW tVifRqGI/AvuRjYVsMUJETYmfdMZcevPNJYgkDmErKS6f4fUWUoOOkji2DSRH+scwdU/ dvLytOnYfawC1bZ388jFE8vDAPk3LKdNSXrCVh5fyFFDiY0KFGyUCRT3uZrpGb9MFxBU hAF8Gk/bh0M/WwkVwp9NJdj1+sW+sIm2xYgYEVNY1ljmWcGDJ4ErcMwMfnjhUw1XBOGf QFjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="il/L9pC+"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qx24si12215413ejb.138.2019.10.14.18.31.47; Mon, 14 Oct 2019 18:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="il/L9pC+"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726381AbfJNXCI (ORCPT + 99 others); Mon, 14 Oct 2019 19:02:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:52386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbfJNXCF (ORCPT ); Mon, 14 Oct 2019 19:02:05 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C27C21835; Mon, 14 Oct 2019 23:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571094124; bh=8d8h/+mvd5XsMBxMGLCeuGPUppFk4H1Hca/+Tehjdrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=il/L9pC+73O9Ib+OPXA+++8AwZ6uJFWVcbgIOplFlrFLXw3AzdxBfqDrPgtFl5ia3 I0Hu2EH8zAgSq0dG3rlra3HW3/2eF908RpHkqeYilGrmcOek37GNo+9Zov6eNCLxA/ GePRY+f3zR2EE3CP78MI7Jp9K2A5bK0+JQGwuctw= From: Bjorn Helgaas To: Dexuan Cui Cc: "Rafael J . Wysocki" , Lorenzo Pieralisi , Michael Kelley , Sasha Levin , Haiyang Zhang , KY Srinivasan , Stephen Hemminger , olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, vkuznets@redhat.com, marcelo.cerri@canonical.com, jackm@mellanox.com, linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org, Bjorn Helgaas Subject: [PATCH 5/7] PCI/PM: Make power management op coding style consistent Date: Mon, 14 Oct 2019 18:00:14 -0500 Message-Id: <20191014230016.240912-6-helgaas@kernel.org> X-Mailer: git-send-email 2.23.0.700.g56cf767bdb-goog In-Reply-To: <20191014230016.240912-1-helgaas@kernel.org> References: <20191014230016.240912-1-helgaas@kernel.org> 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 From: Bjorn Helgaas Some of the power management ops use this style: struct device_driver *drv = dev->driver; if (drv && drv->pm && drv->pm->prepare(dev)) drv->pm->prepare(dev); while others use this: const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pm && pm->runtime_resume) pm->runtime_resume(dev); Convert the first style to the second so they're all consistent. Remove local "error" variables when unnecessary. No functional change intended. Signed-off-by: Bjorn Helgaas --- drivers/pci/pci-driver.c | 76 +++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 55acb658273f..abbf5c39cb9c 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -679,11 +679,11 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) static int pci_pm_prepare(struct device *dev) { - struct device_driver *drv = dev->driver; struct pci_dev *pci_dev = to_pci_dev(dev); + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; - if (drv && drv->pm && drv->pm->prepare) { - int error = drv->pm->prepare(dev); + if (pm && pm->prepare) { + int error = pm->prepare(dev); if (error < 0) return error; @@ -917,8 +917,7 @@ static int pci_pm_suspend_noirq(struct device *dev) static int pci_pm_resume_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct device_driver *drv = dev->driver; - int error = 0; + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (dev_pm_may_skip_resume(dev)) return 0; @@ -946,17 +945,16 @@ static int pci_pm_resume_noirq(struct device *dev) if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - if (drv && drv->pm && drv->pm->resume_noirq) - error = drv->pm->resume_noirq(dev); + if (pm && pm->resume_noirq) + return pm->resume_noirq(dev); - return error; + return 0; } static int pci_pm_resume(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; - int error = 0; /* * This is necessary for the suspend error path in which resume is @@ -972,12 +970,12 @@ static int pci_pm_resume(struct device *dev) if (pm) { if (pm->resume) - error = pm->resume(dev); + return pm->resume(dev); } else { pci_pm_reenable_device(pci_dev); } - return error; + return 0; } #else /* !CONFIG_SUSPEND */ @@ -1038,16 +1036,16 @@ static int pci_pm_freeze(struct device *dev) static int pci_pm_freeze_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct device_driver *drv = dev->driver; + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend_late(dev, PMSG_FREEZE); - if (drv && drv->pm && drv->pm->freeze_noirq) { + if (pm && pm->freeze_noirq) { int error; - error = drv->pm->freeze_noirq(dev); - suspend_report_result(drv->pm->freeze_noirq, error); + error = pm->freeze_noirq(dev); + suspend_report_result(pm->freeze_noirq, error); if (error) return error; } @@ -1066,8 +1064,8 @@ static int pci_pm_freeze_noirq(struct device *dev) static int pci_pm_thaw_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct device_driver *drv = dev->driver; - int error = 0; + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + int error; if (pcibios_pm_ops.thaw_noirq) { error = pcibios_pm_ops.thaw_noirq(dev); @@ -1091,10 +1089,10 @@ static int pci_pm_thaw_noirq(struct device *dev) if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - if (drv && drv->pm && drv->pm->thaw_noirq) - error = drv->pm->thaw_noirq(dev); + if (pm && pm->thaw_noirq) + return pm->thaw_noirq(dev); - return error; + return 0; } static int pci_pm_thaw(struct device *dev) @@ -1165,24 +1163,24 @@ static int pci_pm_poweroff_late(struct device *dev) static int pci_pm_poweroff_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct device_driver *drv = dev->driver; + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; if (dev_pm_smart_suspend_and_suspended(dev)) return 0; - if (pci_has_legacy_pm_support(to_pci_dev(dev))) + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend_late(dev, PMSG_HIBERNATE); - if (!drv || !drv->pm) { + if (!pm) { pci_fixup_device(pci_fixup_suspend_late, pci_dev); return 0; } - if (drv->pm->poweroff_noirq) { + if (pm->poweroff_noirq) { int error; - error = drv->pm->poweroff_noirq(dev); - suspend_report_result(drv->pm->poweroff_noirq, error); + error = pm->poweroff_noirq(dev); + suspend_report_result(pm->poweroff_noirq, error); if (error) return error; } @@ -1208,8 +1206,8 @@ static int pci_pm_poweroff_noirq(struct device *dev) static int pci_pm_restore_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - struct device_driver *drv = dev->driver; - int error = 0; + const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + int error; if (pcibios_pm_ops.restore_noirq) { error = pcibios_pm_ops.restore_noirq(dev); @@ -1223,17 +1221,16 @@ static int pci_pm_restore_noirq(struct device *dev) if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - if (drv && drv->pm && drv->pm->restore_noirq) - error = drv->pm->restore_noirq(dev); + if (pm && pm->restore_noirq) + return pm->restore_noirq(dev); - return error; + return 0; } static int pci_pm_restore(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; - int error = 0; /* * This is necessary for the hibernation error path in which restore is @@ -1249,12 +1246,12 @@ static int pci_pm_restore(struct device *dev) if (pm) { if (pm->restore) - error = pm->restore(dev); + return pm->restore(dev); } else { pci_pm_reenable_device(pci_dev); } - return error; + return 0; } #else /* !CONFIG_HIBERNATE_CALLBACKS */ @@ -1330,9 +1327,9 @@ static int pci_pm_runtime_suspend(struct device *dev) static int pci_pm_runtime_resume(struct device *dev) { - int rc = 0; struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + int error = 0; /* * Restoring config space is necessary even if the device is not bound @@ -1348,18 +1345,17 @@ static int pci_pm_runtime_resume(struct device *dev) pci_pm_default_resume(pci_dev); if (pm && pm->runtime_resume) - rc = pm->runtime_resume(dev); + error = pm->runtime_resume(dev); pci_dev->runtime_d3cold = false; - return rc; + return error; } static int pci_pm_runtime_idle(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; - int ret = 0; /* * If pci_dev->driver is not set (unbound), the device should @@ -1372,9 +1368,9 @@ static int pci_pm_runtime_idle(struct device *dev) return -ENOSYS; if (pm->runtime_idle) - ret = pm->runtime_idle(dev); + return pm->runtime_idle(dev); - return ret; + return 0; } static const struct dev_pm_ops pci_dev_pm_ops = { -- 2.23.0.700.g56cf767bdb-goog