From patchwork Sun Nov 12 16:52:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 164260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp777639vqg; Sun, 12 Nov 2023 08:55:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF19HRfVzCjkji4bzyq9t1TQexWe8lXaN9/lxNd0hFalLlKG6CPsA/2QfW98BlHjA+vpSzV X-Received: by 2002:a17:902:dacb:b0:1cc:4a84:27fa with SMTP id q11-20020a170902dacb00b001cc4a8427famr5696018plx.9.1699808141152; Sun, 12 Nov 2023 08:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699808141; cv=none; d=google.com; s=arc-20160816; b=l50AuqSZQt2VjP8gx8F28d4SpKbW/lGCP9QN2wju1YIBzGVTzw1Za26WiYm0VNymoI 2VR8NZciX0NDpYEE+ZkHkWO7JXgB5Dbldr6N88nZenHanP+7ltKKSgJPHeWyGcw7Jz/6 rcnLBJmKwNe/Wx7x9NLiLSUoydaEG+9MC1kQopQMJfobTff1EczMb/51QY6YKuARviD9 8bJGRQ7g/JD1OYcXnVmWlMWpfJo3hQVT3W3SoM8mq98IVo3kG2NWbKuUc9wMYcrDg1mU YFGKINlR2lBi8MhEIn7DBtbCsEilySdTLzxtg+RH1D+xcz8BGZswPtDXI2dyzHRjRK9c bNpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=4v/xRjbpWDajEC1NbPpoTGnIeZLYpuKE/acxXPtCruo=; fh=GFhSUdb9YgP3Q23X/tJSF+gB4Sk1FBeDneJrxigahZ8=; b=SBNL6zHG5d0PhtAA5vvTvEv39wxiKoNboUZrosy2x8o6lvaWk+sugya3xpfmx3YTrB LEdbOtWbr7mFSPPtuQeHtDXGCKPI7CaJCDiFHuEnAoGRTTWTtjKKGnadBXgfNpiOtH4V K6Bj6hv0t7mXUFhNEic6vVoKijgcDlkabI5yJaAWgc1w/J1hl1WD60D2eYVywNKDA3TM AUPrs7yM7Cadq2GLVfjSSd9bs8Iru+K6Fs71La5LqOqVRHW2b3f7VA/g2YpIPSoAMSm0 VUgG8FRFcmNibn6y7A4dGzsSBIE5m2JD9EdU/3BkUzNulyKC2Yf+V2Tvs0nkw/SMfgL2 ubXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o18-20020a170902d4d200b001c7249f5e40si4117573plg.469.2023.11.12.08.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 08:55:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BAD878057E44; Sun, 12 Nov 2023 08:55:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjKLQxA (ORCPT + 30 others); Sun, 12 Nov 2023 11:53:00 -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 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 12 Nov 2023 08:55:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782378021329057241 X-GMAIL-MSGID: 1782378021329057241 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/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);