From patchwork Mon Sep 30 12:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 174746 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7046677ill; Mon, 30 Sep 2019 05:15:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKMHEoRovfw3ZCYFKzuXVHydWAdZISXP6C/oQDNjs/GS4uS9W+N53V8pEufG4Ufghs0M7n X-Received: by 2002:a17:906:3e96:: with SMTP id a22mr18838086ejj.268.1569845749350; Mon, 30 Sep 2019 05:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569845749; cv=none; d=google.com; s=arc-20160816; b=LZBZ4nX69Q0kmsOoOFDCsvFHV500m82SluvF8EK9c81Dqfc8h22DGmqDqp3/4YXYI1 ANwjsaNkfoY4z+R/6lCyIzZ4ZArde6LHRlTAWtTjg8fhqd53+BZ3IkTMdI/GQpOeKIY0 0SvoyiBi9eED6O4FYeejVyw46CHqC9NhOSVBkcmhNbJ6Sh6VkpvYIHjr2mVK/2DEJX/v Zfn5SObcg+TVAEyGFeMfclzcxSZ526pFhTcV/hpR9hothhnRgFrbrFIghCenq+arh4HR KsvDubRDMOJiP1xqlYypP3lCIVtCKkBb7AsIMcpJbZkN+UvJKxHitpQ2tKpkxnVd6VPd zLNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ml/CTnqhVW2qBPPanZ0BKImXsly7132M8cavQjsI7e0=; b=QTC1FOUHQndFhGSqoVIHwQa/1sdA5FWObB4h4zrPZGnX/6GWvI/vMyUu6ck2mlLBrY QT8E7wldV8pU5PGgAkq7MoV0k+k+4Vv4tYRv+3dD0zmXmtXQ+q+S6A08p7nt7cUEk8W6 0gg4Nd8D3RdtC8FuOLneaxP7pv3hs/u7wInIjROfkhLqFYhuUJcg20rm8OvLCUwmhFkz 8fvren/Dcez9iRtA9e+Udb3gT14pKxuCO55c2FEi15aitx4Uq1NBRc3JGTJdrGSmYqO/ LrFU5sqVpSuz343pNhjOAhN49pqJpbJOqulenngXAbww40NpIThR628VkAjGKzZZNwNx nG3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si6231777ejs.197.2019.09.30.05.15.49; Mon, 30 Sep 2019 05:15:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730490AbfI3MPs (ORCPT + 27 others); Mon, 30 Sep 2019 08:15:48 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52461 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfI3MPr (ORCPT ); Mon, 30 Sep 2019 08:15:47 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MqapC-1hjvMD2Xwm-00meW0; Mon, 30 Sep 2019 14:15:25 +0200 From: Arnd Bergmann To: Antoine Tenart , Herbert Xu , "David S. Miller" Cc: Arnd Bergmann , Pascal van Leeuwen , Pascal van Leeuwen , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] crypto: inside-secure - Fix a maybe-uninitialized warning Date: Mon, 30 Sep 2019 14:14:33 +0200 Message-Id: <20190930121520.1388317-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:LInyj3Ud0A8wB1lffm2V4xf1mZe/8J3moJ6KlLFoXVopMJiU/KM KxE4gKuqXvHz5qvY0skfX00Qf9wBYigW3dERcUECUQk5t+w48wwHyk5tQnjQRvHg1s9vw1H cZ/9oBe3xJSdpS21GHrrqvAXp6zEoKW/PvheWvOURr3TQe8FHkaIuu0vfdLDy+QlRH18qie mrXaPorGX3+Eyn5xcLY5w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:U0vHL9TV2yo=:DiIHi5HDqbjDn+66lvh3os nzMF3Fp3UmCEhUte/68ClyljDSx7vzyaqqEWEK3TFQFqaUO2OKOiHG0v6QQruDYfewn3wNCFb u0efen0ljbb7ev/Hvu+rImGYZJ7aqaKAzCjzkZy68VBBUBnNE0DdNP9vrnIGYW5wDTDCMjqDg 0ZqHMVq/Fy6f2gXJdK1aQNMCWlldAia81jFNbJhs4IaHSpci+Gj4N5ERBVQqNYAUJnssRxxei 3+NaFM59fS8mxFIts/r+X3tzUFBalDZdjaaXLcHp5qL+EbwGiouWMl7AxfbJxN4FsJwBLpZVt j5n5Mpvh4AQijN+RYpzFl+hdyCfnL8vLJZLMGAgK9NZidxC1ItinGxHu/0SpprSCPSOxvc/i2 7o1VYme52Tde7KRHrfjkztgJO5MFe3LZbwe/iud14AEaAa59E4zgopDXjsAb5bz4H3d+LFwnL ICLYRkOIgrUuL1mTHukqdBtvE/9Lx6vABqUHymuQwwrshX9eDV/7FhAKiDh5NjOh0Mj+nTsVN JR2pmX9WvGVGppUySihKW8s1qDKKKedwhkHJyjaNDTiXxWd77ljwYX49JM8YwQf8Mp6qSWB/4 DQjNrWV11MDtCBBywbalwJl1VQ7UoVTItdfE1+PaVrsOpEB6x5cSyHMQgJu5T+ZP5ubybNd9J A0rOoVnBkAThUKeVo1NAgWtYKh6zi3bfHTyag29X2COSv1jLQzo6+CtD0791oNuOKo0ZLMtcb J1chSZt5iADXu6VIZoNlrC7b8UpGYQX8w1opW9fD8t5bhta/o9Kf3TjexUzssMFRtWKH1Qf0e tMk1goSf9Lb6jP/p+i6aXWyDLSf2kN5TD0VGDF8yUnptoPoMyijB7YRj2d+1zBN67mm10fYhJ EQZdIIA3eBVUy4Js3uXQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A previous fixup avoided an unused variable warning but replaced it with a slightly scarier warning: drivers/crypto/inside-secure/safexcel.c:1100:6: error: variable 'irq' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] This is harmless as it is impossible to get into this case, but the compiler has no way of knowing that. Add an explicit error handling case to make it obvious to both compilers and humans reading the source. Fixes: 212ef6f29e5b ("crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n") Signed-off-by: Arnd Bergmann --- drivers/crypto/inside-secure/safexcel.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.0 diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 4ab1bde8dd9b..311bf60df39f 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1120,6 +1120,8 @@ static int safexcel_request_ring_irq(void *pdev, int irqid, irq_name, irq); return irq; } + } else { + return -ENXIO; } ret = devm_request_threaded_irq(dev, irq, handler, From patchwork Mon Sep 30 12:14:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 174748 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp7047384ill; Mon, 30 Sep 2019 05:16:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDXrdGsSu7m6AgB6VqgxvrV6p7SJLURJ+845dwIAQqOCyOWLZX897Njkv33cjIhr4m670z X-Received: by 2002:a50:d49c:: with SMTP id s28mr19453728edi.101.1569845785706; Mon, 30 Sep 2019 05:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569845785; cv=none; d=google.com; s=arc-20160816; b=cImHcMOafkq2SbCo+YTpf0BzQTmFvQVImFAmAyX3bOnsbu68+W1ZygCxjEGJCnKRun gfde3ibOZQVvwP/1hEjiVULcRSwaQih3PXp4/1uGRhaLj4i82IBQLR7QFWfP3bDRpBG/ J+pbPkh3HTXxCq/rpjzmWqcCKJAclGGuYYg7KgeIt220pzOeRwyEOgzc1q1z5mDcbFBJ 6i9nkLccYkHaHDnBfxxgsmnLDsPKSim+pMoGfjv7WMSowRRRLLB/CRJ2jQLpxfTjwNwi cb6MGNIaW6lujhXEC9YlgcL3k7LZWhy4hiko8IiXpMfkopZM9eb0yxSY/+MbcHNDejA4 H3hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WCA2Iuu6vXKg2caKe/PtPiO1jREHETavmVo6HVZ8g6Y=; b=wF+vK+PQL10C98jruxBebDlNmH7LGn1mkeaHtKd6lXgqYL+ib2jfsQ0lHWbGDIb2Np 4c1tkloCRQ2GkMqoGMGPUH3PfQUqhPfQ7CspFHjVE6rKX6N5VFJsYESDDuLO7AZKAham LCCaxb7/vcKwcSPO8a25Cv0OTlM51cRW6p41xDX68MX0bOxI5XM6oJpQiy9Q3wku5XDk gTtl+BMYH9Wm2NYZpYhOPTGlivtO9hHtoMaFRv201118DI41Os1RSHqgC6kxsNuPHmG+ 4uU6FrIDqqfiQgNF+oTA8yJOt9CBjJHjfLpdi+6A1wOgvivebIUbizl37AyiY/8KUwzo RS4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si6838989eda.213.2019.09.30.05.16.25; Mon, 30 Sep 2019 05:16:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730571AbfI3MQY (ORCPT + 27 others); Mon, 30 Sep 2019 08:16:24 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:48827 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfI3MQY (ORCPT ); Mon, 30 Sep 2019 08:16:24 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MZCX1-1iaW5x1SCX-00V7fF; Mon, 30 Sep 2019 14:16:00 +0200 From: Arnd Bergmann To: Antoine Tenart , Herbert Xu , "David S. Miller" , Bjorn Helgaas Cc: Arnd Bergmann , Pascal van Leeuwen , Pascal van Leeuwen , Kelsey Skunberg , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 3/3] crypto: inside-secure - Remove #ifdef checks Date: Mon, 30 Sep 2019 14:14:35 +0200 Message-Id: <20190930121520.1388317-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190930121520.1388317-1-arnd@arndb.de> References: <20190930121520.1388317-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:DhNMaznTViuOF1AalsUIbiZreKsHiyUrkj8fjXw2kpt+XaZVRMO J8YhptUq0zNreRZ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cxNyk2pLGHZbpcccy+T 64ls0o7jlMI1K1K5AYnA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When both PCI and OF are disabled, no drivers are registered, and we get some unused-function warnings: drivers/crypto/inside-secure/safexcel.c:1221:13: error: unused function 'safexcel_unregister_algorithms' [-Werror,-Wunused-function] static void safexcel_unregister_algorithms(struct safexcel_crypto_priv *priv) drivers/crypto/inside-secure/safexcel.c:1307:12: error: unused function 'safexcel_probe_generic' [-Werror,-Wunused-function] static int safexcel_probe_generic(void *pdev, drivers/crypto/inside-secure/safexcel.c:1531:13: error: unused function 'safexcel_hw_reset_rings' [-Werror,-Wunused-function] static void safexcel_hw_reset_rings(struct safexcel_crypto_priv *priv) It's better to make the compiler see what is going on and remove such ifdef checks completely. In case of PCI, this is trivial since pci_register_driver() is defined to an empty function that makes the compiler subsequently drop all unused code silently. The global pcireg_rc/ofreg_rc variables are not actually needed here since the driver registration does not fail in ways that would make it helpful. For CONFIG_OF, an IS_ENABLED() check is still required, since platform drivers can exist both with and without it. A little change to linux/pci.h is needed to ensure that pcim_enable_device() is visible to the driver. Moving the declaration outside of ifdef would be sufficient here, but for consistency with the rest of the file, adding an inline helper is probably best. Fixes: 212ef6f29e5b ("crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n") Signed-off-by: Arnd Bergmann --- drivers/crypto/inside-secure/safexcel.c | 49 ++++++------------------- include/linux/pci.h | 1 + 2 files changed, 13 insertions(+), 37 deletions(-) -- 2.20.0 diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c index 311bf60df39f..c4e8fd27314c 100644 --- a/drivers/crypto/inside-secure/safexcel.c +++ b/drivers/crypto/inside-secure/safexcel.c @@ -1547,7 +1547,6 @@ static void safexcel_hw_reset_rings(struct safexcel_crypto_priv *priv) } } -#if IS_ENABLED(CONFIG_OF) /* for Device Tree platform driver */ static int safexcel_probe(struct platform_device *pdev) @@ -1666,9 +1665,7 @@ static struct platform_driver crypto_safexcel = { .of_match_table = safexcel_of_match_table, }, }; -#endif -#if IS_ENABLED(CONFIG_PCI) /* PCIE devices - i.e. Inside Secure development boards */ static int safexcel_pci_probe(struct pci_dev *pdev, @@ -1789,54 +1786,32 @@ static struct pci_driver safexcel_pci_driver = { .probe = safexcel_pci_probe, .remove = safexcel_pci_remove, }; -#endif - -/* Unfortunately, we have to resort to global variables here */ -#if IS_ENABLED(CONFIG_PCI) -int pcireg_rc = -EINVAL; /* Default safe value */ -#endif -#if IS_ENABLED(CONFIG_OF) -int ofreg_rc = -EINVAL; /* Default safe value */ -#endif static int __init safexcel_init(void) { -#if IS_ENABLED(CONFIG_PCI) + int ret; + /* Register PCI driver */ - pcireg_rc = pci_register_driver(&safexcel_pci_driver); -#endif + ret = pci_register_driver(&safexcel_pci_driver); -#if IS_ENABLED(CONFIG_OF) /* Register platform driver */ - ofreg_rc = platform_driver_register(&crypto_safexcel); - #if IS_ENABLED(CONFIG_PCI) - /* Return success if either PCI or OF registered OK */ - return pcireg_rc ? ofreg_rc : 0; - #else - return ofreg_rc; - #endif -#else - #if IS_ENABLED(CONFIG_PCI) - return pcireg_rc; - #else - return -EINVAL; - #endif -#endif + if (IS_ENABLED(CONFIG_OF) && !ret) { + ret = platform_driver_register(&crypto_safexcel); + if (ret) + pci_unregister_driver(&safexcel_pci_driver); + } + + return ret; } static void __exit safexcel_exit(void) { -#if IS_ENABLED(CONFIG_OF) /* Unregister platform driver */ - if (!ofreg_rc) + if (IS_ENABLED(CONFIG_OF)) platform_driver_unregister(&crypto_safexcel); -#endif -#if IS_ENABLED(CONFIG_PCI) /* Unregister PCI driver if successfully registered before */ - if (!pcireg_rc) - pci_unregister_driver(&safexcel_pci_driver); -#endif + pci_unregister_driver(&safexcel_pci_driver); } module_init(safexcel_init); diff --git a/include/linux/pci.h b/include/linux/pci.h index f9088c89a534..1a6cf19eac2d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1686,6 +1686,7 @@ static inline struct pci_dev *pci_get_class(unsigned int class, static inline void pci_set_master(struct pci_dev *dev) { } static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } static inline void pci_disable_device(struct pci_dev *dev) { } +static inline int pcim_enable_device(struct pci_dev *pdev) { return -EIO; } static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY; } static inline int __pci_register_driver(struct pci_driver *drv,