Skip to content

Commit 212ef6f

Browse files
Pascal van Leeuwenherbertx
authored andcommitted
crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n
This patch fixes an unused variable warning from the compiler when the driver is being compiled without PCI support in the kernel. Fixes: 625f269 ("crypto: inside-secure - add support for...") Signed-off-by: Pascal van Leeuwen <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 5fc194e commit 212ef6f

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

drivers/crypto/inside-secure/safexcel.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,32 +1789,50 @@ static struct pci_driver safexcel_pci_driver = {
17891789
};
17901790
#endif
17911791

1792-
static int __init safexcel_init(void)
1793-
{
1794-
int rc;
1795-
1792+
/* Unfortunately, we have to resort to global variables here */
1793+
#if IS_ENABLED(CONFIG_PCI)
1794+
int pcireg_rc = -EINVAL; /* Default safe value */
1795+
#endif
17961796
#if IS_ENABLED(CONFIG_OF)
1797-
/* Register platform driver */
1798-
platform_driver_register(&crypto_safexcel);
1797+
int ofreg_rc = -EINVAL; /* Default safe value */
17991798
#endif
18001799

1800+
static int __init safexcel_init(void)
1801+
{
18011802
#if IS_ENABLED(CONFIG_PCI)
1802-
/* Register PCI driver */
1803-
rc = pci_register_driver(&safexcel_pci_driver);
1803+
/* Register PCI driver */
1804+
pcireg_rc = pci_register_driver(&safexcel_pci_driver);
18041805
#endif
18051806

1806-
return 0;
1807+
#if IS_ENABLED(CONFIG_OF)
1808+
/* Register platform driver */
1809+
ofreg_rc = platform_driver_register(&crypto_safexcel);
1810+
#if IS_ENABLED(CONFIG_PCI)
1811+
/* Return success if either PCI or OF registered OK */
1812+
return pcireg_rc ? ofreg_rc : 0;
1813+
#else
1814+
return ofreg_rc;
1815+
#endif
1816+
#else
1817+
#if IS_ENABLED(CONFIG_PCI)
1818+
return pcireg_rc;
1819+
#else
1820+
return -EINVAL;
1821+
#endif
1822+
#endif
18071823
}
18081824

18091825
static void __exit safexcel_exit(void)
18101826
{
18111827
#if IS_ENABLED(CONFIG_OF)
1812-
/* Unregister platform driver */
1828+
/* Unregister platform driver */
1829+
if (!ofreg_rc)
18131830
platform_driver_unregister(&crypto_safexcel);
18141831
#endif
18151832

18161833
#if IS_ENABLED(CONFIG_PCI)
1817-
/* Unregister PCI driver if successfully registered before */
1834+
/* Unregister PCI driver if successfully registered before */
1835+
if (!pcireg_rc)
18181836
pci_unregister_driver(&safexcel_pci_driver);
18191837
#endif
18201838
}

0 commit comments

Comments
 (0)