Re: [PATCHv2] crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 06, 2019 at 10:07:23AM +0200, Pascal van Leeuwen wrote:
>
> diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
> index e12a2a3..2331b31 100644
> --- a/drivers/crypto/inside-secure/safexcel.c
> +++ b/drivers/crypto/inside-secure/safexcel.c
> @@ -1505,29 +1505,29 @@ static int __init safexcel_init(void)
>  {
>  	int rc;
>  
> -#if IS_ENABLED(CONFIG_OF)
> -		/* Register platform driver */
> -		platform_driver_register(&crypto_safexcel);
> +#if IS_ENABLED(CONFIG_PCI)
> +	/* Register PCI driver */
> +	rc = pci_register_driver(&safexcel_pci_driver);
>  #endif
>  
> -#if IS_ENABLED(CONFIG_PCI)
> -		/* Register PCI driver */
> -		rc = pci_register_driver(&safexcel_pci_driver);
> +#if IS_ENABLED(CONFIG_OF)
> +	/* Register platform driver */
> +	rc = platform_driver_register(&crypto_safexcel);
>  #endif
>  
> -	return 0;
> +	return rc;
>  }

According to the Kconfig it is theoretically possible for both
PCI and OF to be off (with COMPILE_TEST enabled).  So you should
add an rc = 0 at the top.

You also need to check rc after each registration and abort if
an error is detected.  After the second step, aborting would
also require unwinding the first step.

So something like:

	int rc = 0;

#if IS_ENABLED(CONFIG_PCI)
	/* Register PCI driver */
	rc = pci_register_driver(&safexcel_pci_driver);
#endif
	if (rc)
		goto out;

#if IS_ENABLED(CONFIG_OF)
	/* Register platform driver */
	rc = platform_driver_register(&crypto_safexcel);
#endif
	if (rc)
		goto undo_pci;

undo_pci:
#if IS_ENABLED(CONFIG_PCI)
	pci_unregister_driver(&safexcel_pci_driver);
#endif
out:
	return rc;

As you can see, these ifdefs get out-of-control pretty quickly.
In fact, we can remove all the CONFIG_PCI ifdefs by adding just
one more stub function in pci.h for pcim_enable_device.

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux