From patchwork Mon May 25 18:26:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 211967 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=-9.8 required=3.0 tests=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 43C4FC433E2 for ; Mon, 25 May 2020 18:26:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32FE120776 for ; Mon, 25 May 2020 18:26:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389308AbgEYS0R (ORCPT ); Mon, 25 May 2020 14:26:17 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:36124 "EHLO mail-ej1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387644AbgEYS0Q (ORCPT ); Mon, 25 May 2020 14:26:16 -0400 Received: by mail-ej1-f67.google.com with SMTP id z5so21375647ejb.3; Mon, 25 May 2020 11:26:13 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=tkUGbMkkypRL042+ieWSoDccuHFghwak5Hi3wVxhDmE=; b=C6FvFlWGYjOrdkQk8jI5gKJ0FH/UIZfAILSeyIMoTRLVytb2uadwYyVnBKtqhCSTxo aj7PGbUmhTcR+JDysusQTqgasRYDpRRQVxdYvRfjAv9VZB2QeepMKCxd5gfoeTRCiG/e Jmgh6y48CMevLk1MxULlpxQvOwdtAh0T6TWBfaG9cwVabEG8HXYWfG+8hlVFUiRJhf7c mtlCsuSP04spjmnUmGR4zpEhwRDaInkTdyS7yw8aXxmvRwo3qaUa74CaZKTiV/4cXz5v TEJMF4mWPLspYAssS60gMRqErYpLcUVYYto+4tR5wIWJ4CrG4vDDmSFwZy+Kdd+wz9mq Thig== X-Gm-Message-State: AOAM5325TrlWaByK3eWEBqeVkTpPT770+FJzp0atfEnrNtZYykD0dU5j Ga9qYIw6jsILnnvzjKMDVjGtN1EA6vzgYy46 X-Google-Smtp-Source: ABdhPJyLZsaw5mEGXRcLaNb9q3bD5AU4cxUKQ8Vo98mbYphbp21kYQ3Rc8jcjNp3ljuzgmIEt8D4Ug== X-Received: by 2002:a17:906:f1c3:: with SMTP id gx3mr19110160ejb.278.1590431172312; Mon, 25 May 2020 11:26:12 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id n15sm15555707ejs.10.2020.05.25.11.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 11:26:11 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Dan Carpenter Cc: "Rafael J. Wysocki" , Len Brown , Kevin Hilman , Ulf Hansson , Pavel Machek , Greg Kroah-Hartman , Johan Hovold , Alex Elder , Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Julian Wiedmann , Karsten Graul , Ursula Braun , Jakub Kicinski , Bjorn Andersson , John Stultz , "David S. Miller" , greybus-dev@lists.linaro.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 1/8] driver core: Add helper for accessing Power Management callbacs Date: Mon, 25 May 2020 18:26:01 +0000 Message-Id: <20200525182608.1823735-2-kw@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525182608.1823735-1-kw@linux.com> References: <20200525182608.1823735-1-kw@linux.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add driver_to_pm() helper allowing for accessing the Power Management callbacs for a particular device. Access to the callbacs (struct dev_pm_ops) is normally done through using the pm pointer that is embedded within the device_driver struct. Helper allows for the code required to reference the pm pointer and access Power Management callbas to be simplified. Changing the following: struct device_driver *drv = dev->driver; if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) { int ret = dev->driver->pm->prepare(dev); To: const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (pm && pm->prepare) { int ret = pm->prepare(dev); Or, changing the following: const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; To: const struct dev_pm_ops *pm = driver_to_pm(dev->driver); Signed-off-by: Krzysztof Wilczyński --- include/linux/device/driver.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index ee7ba5b5417e..ccd0b315fd93 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -236,6 +236,21 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev) } #endif +/** + * driver_to_pm - Return Power Management callbacs (struct dev_pm_ops) for + * a particular device. + * @drv: Pointer to a device (struct device_driver) for which you want to access + * the Power Management callbacks. + * + * Returns a pointer to the struct dev_pm_ops embedded within the device (struct + * device_driver), or returns NULL if Power Management is not present and the + * pointer is not valid. + */ +static inline const struct dev_pm_ops *driver_to_pm(struct device_driver *drv) +{ + return drv && drv->pm ? drv->pm : NULL; +} + extern int driver_deferred_probe_timeout; void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Mon May 25 18:26:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 211968 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=-9.8 required=3.0 tests=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 C36BCC433E3 for ; Mon, 25 May 2020 18:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B19F620787 for ; Mon, 25 May 2020 18:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389468AbgEYS0V (ORCPT ); Mon, 25 May 2020 14:26:21 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:35257 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389100AbgEYS0S (ORCPT ); Mon, 25 May 2020 14:26:18 -0400 Received: by mail-ed1-f68.google.com with SMTP id be9so15716301edb.2; Mon, 25 May 2020 11:26:16 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=1bL0BwD4jERke74zdsN6GWlbqAKQcOkJQVbWbDofjCc=; b=CoHAjtuTgZ7RKbrHFOXlqXo6a0T0ih3ZweRc7jHDv1fccdmzPVdTB48Z665vf2mDPq 4vfKDab8lm7GuHVAMX2FsfrDxdM2rYU8eMu47gymPgZWJlJ2V7gB3PtCzNNyfZYcaiii +FJK74we0EI5UzE8VI8zey1ncORARQI0UCIG7d6yH5YAXcoD2VUa8yFu/vUdC122elxw jDFaymZx2lTr4udcolAOP5Wu1zam8TGXzviOR/6hg5lP0gFuwAU4ubhIORuGjekaIYn0 PxrkEfOKvL1K8zzm8SNFWbmpIZuwNYqdPLcv3ieEbWjA9RQKCdbw38MNw1md4kbYmOZ4 UlfQ== X-Gm-Message-State: AOAM530LRNPud5BE4WiJF7vu8+7TLEoiB0vfW09lNzC/H9PukFwkEjeO 02Q6ldMywmkcBnvZOU2axLg= X-Google-Smtp-Source: ABdhPJwrYFIAvzGWl142jMalbOrQRtAasOCaag/9Ikx3BCjjSja4mpWvlAvCZRDWouYD7Z+QytFuXg== X-Received: by 2002:aa7:cb8d:: with SMTP id r13mr16272548edt.12.1590431175453; Mon, 25 May 2020 11:26:15 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id n15sm15555707ejs.10.2020.05.25.11.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 11:26:14 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Dan Carpenter Cc: "Rafael J. Wysocki" , Len Brown , Kevin Hilman , Ulf Hansson , Pavel Machek , Greg Kroah-Hartman , Johan Hovold , Alex Elder , Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Julian Wiedmann , Karsten Graul , Ursula Braun , Jakub Kicinski , Bjorn Andersson , John Stultz , "David S. Miller" , greybus-dev@lists.linaro.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 3/8] greybus: Use the new device_to_pm() helper to access struct dev_pm_ops Date: Mon, 25 May 2020 18:26:03 +0000 Message-Id: <20200525182608.1823735-4-kw@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525182608.1823735-1-kw@linux.com> References: <20200525182608.1823735-1-kw@linux.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use the new device_to_pm() helper to access Power Management callbacs (struct dev_pm_ops) for a particular device (struct device_driver). No functional change intended. Signed-off-by: Krzysztof Wilczyński --- drivers/greybus/bundle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/greybus/bundle.c b/drivers/greybus/bundle.c index 84660729538b..d38d3a630812 100644 --- a/drivers/greybus/bundle.c +++ b/drivers/greybus/bundle.c @@ -108,7 +108,7 @@ static void gb_bundle_enable_all_connections(struct gb_bundle *bundle) static int gb_bundle_suspend(struct device *dev) { struct gb_bundle *bundle = to_gb_bundle(dev); - const struct dev_pm_ops *pm = dev->driver->pm; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); int ret; if (pm && pm->runtime_suspend) { @@ -135,7 +135,7 @@ static int gb_bundle_suspend(struct device *dev) static int gb_bundle_resume(struct device *dev) { struct gb_bundle *bundle = to_gb_bundle(dev); - const struct dev_pm_ops *pm = dev->driver->pm; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); int ret; ret = gb_control_bundle_resume(bundle->intf->control, bundle->id); From patchwork Mon May 25 18:26:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 211970 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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 75399C433E0 for ; Mon, 25 May 2020 18:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FCFF20776 for ; Mon, 25 May 2020 18:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389578AbgEYS01 (ORCPT ); Mon, 25 May 2020 14:26:27 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:37256 "EHLO mail-ej1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389424AbgEYS0Y (ORCPT ); Mon, 25 May 2020 14:26:24 -0400 Received: by mail-ej1-f67.google.com with SMTP id l21so21340550eji.4; Mon, 25 May 2020 11:26:21 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=zNLfwJcteMTXr7l2k3f76K9ak6QhgvPhJMdyVWXtook=; b=S2upfNGqFWbRgK7c41NmdMByKGk4hqVDyMU9Qa+RACz2GQ1itC1GNbhBGRQ8o/5R/H bzzeu4DxSD5MY+hrMhR3QsAvKPdA65bK8BcLG830DnetEQErjDpA+SgBHr4w23LucSe8 /s0SKw3buAirKCEUjLjXVNA5WV5TlGMliMTpiyTdU2msD6YuaFSYEV61G2CvQLSzKIVP m2Uhemk/HRBhxVwDCCEZ2SB6Z2DeBqp3N9iCcPYN/MI+psXLOxoUZjkKbDXXVWxMYlDe 47UHwFLs+ikmsxh7RfFnTmmIdI08QpkHiXgXD2+B2jPRCu/f0F6UWHCZXaEBij1OSlG1 KLJQ== X-Gm-Message-State: AOAM532EtWLTmnD29SMRf473doTEiqHIDde/WD1ohkL5VNqo2U1Y/Phg +Ye9Fy/SvOwFHEJW0AYWU1I= X-Google-Smtp-Source: ABdhPJxHXwXAwSKGbmYve3v9WBtP/87qC9xOP1l2MkD3w7uNppn5ljU8phz0KQh9kDPYuSYY7QZQjA== X-Received: by 2002:a17:906:e112:: with SMTP id gj18mr10286586ejb.352.1590431180269; Mon, 25 May 2020 11:26:20 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id n15sm15555707ejs.10.2020.05.25.11.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 11:26:19 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Dan Carpenter Cc: "Rafael J. Wysocki" , Len Brown , Kevin Hilman , Ulf Hansson , Pavel Machek , Greg Kroah-Hartman , Johan Hovold , Alex Elder , Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Julian Wiedmann , Karsten Graul , Ursula Braun , Jakub Kicinski , Bjorn Andersson , John Stultz , "David S. Miller" , greybus-dev@lists.linaro.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 6/8] PCI/PM: Use the new device_to_pm() helper to access struct dev_pm_ops Date: Mon, 25 May 2020 18:26:06 +0000 Message-Id: <20200525182608.1823735-7-kw@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525182608.1823735-1-kw@linux.com> References: <20200525182608.1823735-1-kw@linux.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use the new device_to_pm() helper to access Power Management callbacs (struct dev_pm_ops) for a particular device (struct device_driver). No functional change intended. Signed-off-by: Krzysztof Wilczyński --- drivers/pci/pci-driver.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0454ca0e4e3f..bb52bb6642a0 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -652,7 +652,7 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) static int pci_pm_prepare(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (pm && pm->prepare) { int error = pm->prepare(dev); @@ -721,7 +721,7 @@ static void pcie_pme_root_status_cleanup(struct pci_dev *pci_dev) static int pci_pm_suspend(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); pci_dev->skip_bus_pm = false; @@ -787,7 +787,7 @@ static int pci_pm_suspend_late(struct device *dev) static int pci_pm_suspend_noirq(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (dev_pm_smart_suspend_and_suspended(dev)) { dev->power.may_skip_resume = true; @@ -889,7 +889,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); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); pci_power_t prev_state = pci_dev->current_state; bool skip_bus_pm = pci_dev->skip_bus_pm; @@ -931,7 +931,7 @@ static int pci_pm_resume_noirq(struct device *dev) 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; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); /* * This is necessary for the suspend error path in which resume is @@ -976,7 +976,7 @@ struct dev_pm_ops __weak pcibios_pm_ops; static int pci_pm_freeze(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend(dev, PMSG_FREEZE); @@ -1012,7 +1012,7 @@ 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); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend_late(dev, PMSG_FREEZE); @@ -1040,7 +1040,7 @@ 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); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); int error; if (pcibios_pm_ops.thaw_noirq) { @@ -1073,7 +1073,7 @@ static int pci_pm_thaw_noirq(struct device *dev) static int pci_pm_thaw(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); int error = 0; if (pci_has_legacy_pm_support(pci_dev)) @@ -1094,7 +1094,7 @@ static int pci_pm_thaw(struct device *dev) static int pci_pm_poweroff(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_suspend(dev, PMSG_HIBERNATE); @@ -1138,7 +1138,7 @@ 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); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); if (dev_pm_smart_suspend_and_suspended(dev)) return 0; @@ -1181,7 +1181,7 @@ 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); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); int error; if (pcibios_pm_ops.restore_noirq) { @@ -1205,7 +1205,7 @@ static int pci_pm_restore_noirq(struct device *dev) 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; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); /* * This is necessary for the hibernation error path in which restore is @@ -1248,7 +1248,7 @@ static int pci_pm_restore(struct device *dev) static int pci_pm_runtime_suspend(struct device *dev) { struct pci_dev *pci_dev = to_pci_dev(dev); - const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); pci_power_t prev = pci_dev->current_state; int error; @@ -1303,7 +1303,7 @@ static int pci_pm_runtime_suspend(struct device *dev) static int pci_pm_runtime_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; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); pci_power_t prev_state = pci_dev->current_state; int error = 0; @@ -1334,7 +1334,7 @@ static int pci_pm_runtime_resume(struct device *dev) 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; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); /* * If pci_dev->driver is not set (unbound), the device should From patchwork Mon May 25 18:26:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 211969 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=-9.8 required=3.0 tests=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 A0C73C433E4 for ; Mon, 25 May 2020 18:26:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E31520776 for ; Mon, 25 May 2020 18:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389844AbgEYS0j (ORCPT ); Mon, 25 May 2020 14:26:39 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45603 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389535AbgEYS01 (ORCPT ); Mon, 25 May 2020 14:26:27 -0400 Received: by mail-ed1-f66.google.com with SMTP id s19so15690606edt.12; Mon, 25 May 2020 11:26:24 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=6WamrPQShgiTsDFapEcmGDUQvC5yr09yE8HLsYvPPjk=; b=XQxb+DxHoOZ+c+GE3Accdn0tG1U77du9BRJk0S1niL7Zw1/bmI+igGUL9xpFbZMftY UgMF6BZREB4LxwHDyUQkKKyvqJJJfONDQtj4+Tsw4sQQKb+htO0P+E3id+ocuumkoJUH 0odrF+vB0H/vVm2tweoBH0GVc3mb0wxMwKDDzrRh5eDrgYa4T8RWo+g/u290PJL0NVNT te3SFvExCXyML1Wb+Wiv4mzwj6dVivWH0CYsGExr9/Vwm0cmXmpbKIdNJp5Y/hLt40wi mbbQifDQm212bAcaRZH9jbjWVAsXV+DUKJTiAA5eahsng6G+zlLGrgtujSPrn7UsJ1PI wrAw== X-Gm-Message-State: AOAM530t8X8PqBtw7DmbEdymLbm6v97fl+BAAv3ew9pyqII2aAm0HEL/ dyob+DKgvi4o4qJsGSKuIsU= X-Google-Smtp-Source: ABdhPJwaQ1a3PQrLYUo66G+JvtCe5bgBlAK3z2hUCsbaw6NsBbigY5hyn9hKVKSVUbo33mXU0BIe7w== X-Received: by 2002:aa7:cf12:: with SMTP id a18mr11182818edy.193.1590431183421; Mon, 25 May 2020 11:26:23 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id n15sm15555707ejs.10.2020.05.25.11.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 11:26:22 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Dan Carpenter Cc: "Rafael J. Wysocki" , Len Brown , Kevin Hilman , Ulf Hansson , Pavel Machek , Greg Kroah-Hartman , Johan Hovold , Alex Elder , Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Julian Wiedmann , Karsten Graul , Ursula Braun , Jakub Kicinski , Bjorn Andersson , John Stultz , "David S. Miller" , greybus-dev@lists.linaro.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 8/8] net/iucv: Use the new device_to_pm() helper to access struct dev_pm_ops Date: Mon, 25 May 2020 18:26:08 +0000 Message-Id: <20200525182608.1823735-9-kw@linux.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525182608.1823735-1-kw@linux.com> References: <20200525182608.1823735-1-kw@linux.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use the new device_to_pm() helper to access Power Management callbacs (struct dev_pm_ops) for a particular device (struct device_driver). No functional change intended. Signed-off-by: Krzysztof Wilczyński --- net/iucv/iucv.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 9a2d023842fe..1a3029ab7c1f 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c @@ -1836,23 +1836,23 @@ static void iucv_external_interrupt(struct ext_code ext_code, static int iucv_pm_prepare(struct device *dev) { - int rc = 0; + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); #ifdef CONFIG_PM_DEBUG printk(KERN_INFO "iucv_pm_prepare\n"); #endif - if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) - rc = dev->driver->pm->prepare(dev); - return rc; + return pm && pm->prepare ? pm->prepare(dev) : 0; } static void iucv_pm_complete(struct device *dev) { + const struct dev_pm_ops *pm = driver_to_pm(dev->driver); + #ifdef CONFIG_PM_DEBUG printk(KERN_INFO "iucv_pm_complete\n"); #endif - if (dev->driver && dev->driver->pm && dev->driver->pm->complete) - dev->driver->pm->complete(dev); + if (pm && pm->complete) + pm->complete(dev); } /** @@ -1883,6 +1883,7 @@ static int iucv_path_table_empty(void) static int iucv_pm_freeze(struct device *dev) { int cpu; + const struct dev_pm_ops *pm; struct iucv_irq_list *p, *n; int rc = 0; @@ -1902,8 +1903,9 @@ static int iucv_pm_freeze(struct device *dev) } } iucv_pm_state = IUCV_PM_FREEZING; - if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) - rc = dev->driver->pm->freeze(dev); + pm = driver_to_pm(dev->driver); + if (pm && pm->freeze) + rc = pm->freeze(dev); if (iucv_path_table_empty()) iucv_disable(); return rc; @@ -1919,6 +1921,7 @@ static int iucv_pm_freeze(struct device *dev) */ static int iucv_pm_thaw(struct device *dev) { + const struct dev_pm_ops *pm; int rc = 0; #ifdef CONFIG_PM_DEBUG @@ -1938,8 +1941,9 @@ static int iucv_pm_thaw(struct device *dev) /* enable interrupts on all cpus */ iucv_setmask_mp(); } - if (dev->driver && dev->driver->pm && dev->driver->pm->thaw) - rc = dev->driver->pm->thaw(dev); + pm = driver_to_pm(dev->driver); + if (pm && pm->thaw) + rc = pm->thaw(dev); out: return rc; } @@ -1954,6 +1958,7 @@ static int iucv_pm_thaw(struct device *dev) */ static int iucv_pm_restore(struct device *dev) { + const struct dev_pm_ops *pm; int rc = 0; #ifdef CONFIG_PM_DEBUG @@ -1968,8 +1973,9 @@ static int iucv_pm_restore(struct device *dev) if (rc) goto out; } - if (dev->driver && dev->driver->pm && dev->driver->pm->restore) - rc = dev->driver->pm->restore(dev); + pm = driver_to_pm(dev->driver); + if (pm && pm->restore) + rc = pm->restore(dev); out: return rc; }