linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwrng: virtio - remove #ifdef guards for PM functions
@ 2023-11-12 16:52 Martin Kaiser
  2023-11-17 11:26 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kaiser @ 2023-11-12 16:52 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, linux-kernel, Martin Kaiser

Use pm_sleep_ptr for the freeze and restore functions instead of putting
them under #ifdef CONFIG_PM_SLEEP. The resulting code is slightly simpler.

pm_sleep_ptr lets the compiler see the functions but also allows removing
them as unused code if !CONFIG_PM_SLEEP.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
compile-tested only, I do not have this hardware

 drivers/char/hw_random/virtio-rng.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index e41a84e6b4b5..58d92d62ddfe 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -208,7 +208,6 @@ static void virtrng_scan(struct virtio_device *vdev)
 		vi->hwrng_register_done = true;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int virtrng_freeze(struct virtio_device *vdev)
 {
 	remove_common(vdev);
@@ -238,7 +237,6 @@ static int virtrng_restore(struct virtio_device *vdev)
 
 	return err;
 }
-#endif
 
 static const struct virtio_device_id id_table[] = {
 	{ VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID },
@@ -252,10 +250,8 @@ static struct virtio_driver virtio_rng_driver = {
 	.probe =	virtrng_probe,
 	.remove =	virtrng_remove,
 	.scan =		virtrng_scan,
-#ifdef CONFIG_PM_SLEEP
-	.freeze =	virtrng_freeze,
-	.restore =	virtrng_restore,
-#endif
+	.freeze =	pm_sleep_ptr(virtrng_freeze),
+	.restore =	pm_sleep_ptr(virtrng_restore),
 };
 
 module_virtio_driver(virtio_rng_driver);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwrng: virtio - remove #ifdef guards for PM functions
  2023-11-12 16:52 [PATCH] hwrng: virtio - remove #ifdef guards for PM functions Martin Kaiser
@ 2023-11-17 11:26 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2023-11-17 11:26 UTC (permalink / raw)
  To: Martin Kaiser; +Cc: linux-crypto, linux-kernel

On Sun, Nov 12, 2023 at 05:52:41PM +0100, Martin Kaiser wrote:
> Use pm_sleep_ptr for the freeze and restore functions instead of putting
> them under #ifdef CONFIG_PM_SLEEP. The resulting code is slightly simpler.
> 
> pm_sleep_ptr lets the compiler see the functions but also allows removing
> them as unused code if !CONFIG_PM_SLEEP.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> compile-tested only, I do not have this hardware
> 
>  drivers/char/hw_random/virtio-rng.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-17 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 16:52 [PATCH] hwrng: virtio - remove #ifdef guards for PM functions Martin Kaiser
2023-11-17 11:26 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).