linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Pascal van Leeuwen <pascalvanl@gmail.com>
Cc: linux-crypto@vger.kernel.org, antoine.tenart@bootlin.com,
	davem@davemloft.net,
	Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
Subject: Re: [PATCHv3] crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n
Date: Fri, 13 Sep 2019 19:20:36 +1000	[thread overview]
Message-ID: <20190913092036.GA6645@gondor.apana.org.au> (raw)
In-Reply-To: <1567783514-24947-1-git-send-email-pvanleeuwen@verimatrix.com>

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 <pvanleeuwen@verimatrix.com>
> ---
>  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 <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2019-09-13  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 15:25 [PATCHv3] crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n Pascal van Leeuwen
2019-09-13  9:20 ` Herbert Xu [this message]
2019-09-13  9:43   ` Pascal Van Leeuwen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190913092036.GA6645@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=linux-crypto@vger.kernel.org \
    --cc=pascalvanl@gmail.com \
    --cc=pvanleeuwen@verimatrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).