Re: [PATCH 8/8] net/iucv: Use the new device_to_pm() helper to access struct dev_pm_ops

From
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date
2020-05-26 06:35:26
Also in
linux-acpi, linux-pci, linux-pm, linux-s390, linux-scsi, linux-usb
Reply to
Krzysztof Wilczyński, 2020-05-25
On Mon, May 25, 2020 at 06:26:08PM +0000, Krzysztof Wilczyński wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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;
No need for ? : here either, just use if () please.

It's "interesting" how using your new helper doesn't actually make the
code smaller.  Perhaps it isn't a good helper function?

thanks,

greg k-h
Thread (26 messages) 26 messages, 7 authors, last reply 2020-05-26
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help