From nobody Tue Dec 30 18:49:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA6D0C4332F for ; Sun, 12 Nov 2023 16:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230186AbjKLQxB (ORCPT ); Sun, 12 Nov 2023 11:53:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjKLQw7 (ORCPT ); Sun, 12 Nov 2023 11:52:59 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C071BEF; Sun, 12 Nov 2023 08:52:53 -0800 (PST) Received: from dslb-188-097-210-154.188.097.pools.vodafone-ip.de ([188.97.210.154] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1r2DhZ-0001WT-K8; Sun, 12 Nov 2023 17:52:49 +0100 From: Martin Kaiser To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH] hwrng: virtio - remove #ifdef guards for PM functions Date: Sun, 12 Nov 2023 17:52:41 +0100 Message-Id: <20231112165241.176095-1-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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/v= irtio-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 =3D true; } =20 -#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) =20 return err; } -#endif =20 static const struct virtio_device_id id_table[] =3D { { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID }, @@ -252,10 +250,8 @@ static struct virtio_driver virtio_rng_driver =3D { .probe =3D virtrng_probe, .remove =3D virtrng_remove, .scan =3D virtrng_scan, -#ifdef CONFIG_PM_SLEEP - .freeze =3D virtrng_freeze, - .restore =3D virtrng_restore, -#endif + .freeze =3D pm_sleep_ptr(virtrng_freeze), + .restore =3D pm_sleep_ptr(virtrng_restore), }; =20 module_virtio_driver(virtio_rng_driver); --=20 2.39.2