From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 510A5C49ED7 for ; Fri, 13 Sep 2019 09:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 276E7214AE for ; Fri, 13 Sep 2019 09:20:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387671AbfIMJUt (ORCPT ); Fri, 13 Sep 2019 05:20:49 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:33536 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387424AbfIMJUt (ORCPT ); Fri, 13 Sep 2019 05:20:49 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.89 #2 (Debian)) id 1i8hkx-0007qR-D4; Fri, 13 Sep 2019 19:20:44 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 13 Sep 2019 19:20:36 +1000 Date: Fri, 13 Sep 2019 19:20:36 +1000 From: Herbert Xu To: Pascal van Leeuwen Cc: linux-crypto@vger.kernel.org, antoine.tenart@bootlin.com, davem@davemloft.net, Pascal van Leeuwen Subject: Re: [PATCHv3] crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n Message-ID: <20190913092036.GA6645@gondor.apana.org.au> References: <1567783514-24947-1-git-send-email-pvanleeuwen@verimatrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567783514-24947-1-git-send-email-pvanleeuwen@verimatrix.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Sep 06, 2019 at 05:25:14PM +0200, Pascal van Leeuwen wrote: > This patch fixes an unused variable warning from the compiler when the > driver is being compiled without PCI support in the kernel. > > changes since v1: > - capture the platform_register_driver error code as well > - actually return the (last) error code > - swapped registration to do PCI first as that's just for development > boards anyway, so in case both are done we want the platform error > or no error at all if that passes > - also fixes some indentation issue in the affected code > > changes since v2: > - handle the situation where both CONFIG_PCI and CONFIG_OF are undefined > by always returning a -EINVAL error > - only unregister PCI or OF if it was previously successfully registered > > Signed-off-by: Pascal van Leeuwen > --- > drivers/crypto/inside-secure/safexcel.c | 35 ++++++++++++++++++++++----------- > 1 file changed, 24 insertions(+), 11 deletions(-) > > diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c > index e12a2a3..925c90f 100644 > --- a/drivers/crypto/inside-secure/safexcel.c > +++ b/drivers/crypto/inside-secure/safexcel.c > @@ -1501,32 +1501,45 @@ void safexcel_pci_remove(struct pci_dev *pdev) > }; > #endif > > -static int __init safexcel_init(void) > -{ > - int rc; > - > +/* 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) > - /* Register platform driver */ > - platform_driver_register(&crypto_safexcel); > +int ofreg_rc = -EINVAL; /* Default safe value */ > #endif > > +static int __init safexcel_init(void) > +{ > #if IS_ENABLED(CONFIG_PCI) > - /* Register PCI driver */ > - rc = pci_register_driver(&safexcel_pci_driver); > + /* Register PCI driver */ > + pcireg_rc = pci_register_driver(&safexcel_pci_driver); > #endif > > - return 0; > +#if IS_ENABLED(CONFIG_OF) > + /* Register platform driver */ > + ofreg_rc = platform_driver_register(&crypto_safexcel); > + return ofreg_rc; If OF registration fails then you will return an error even if PCI registration succeeded without undoing the PCI registration. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt