diff mbox series

[24/34] crypto: ccp - drop platform ifdef checks

Message ID 20240403080702.3509288-25-arnd@kernel.org (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series address all -Wunused-const warnings | expand

Commit Message

Arnd Bergmann April 3, 2024, 8:06 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

When both ACPI and OF are disabled, the dev_vdata variable is unused:

drivers/crypto/ccp/sp-platform.c:33:34: error: unused variable 'dev_vdata' [-Werror,-Wunused-const-variable]

This is not a useful configuration, and there is not much point in saving
a few bytes when only one of the two is enabled, so just remove all
these ifdef checks and rely on of_match_node() and acpi_match_device()
returning NULL when these subsystems are disabled.

Fixes: 6c5063434098 ("crypto: ccp - Add ACPI support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/crypto/ccp/sp-platform.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

Comments

Tom Lendacky April 3, 2024, 3:17 p.m. UTC | #1
On 4/3/24 03:06, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When both ACPI and OF are disabled, the dev_vdata variable is unused:
> 
> drivers/crypto/ccp/sp-platform.c:33:34: error: unused variable 'dev_vdata' [-Werror,-Wunused-const-variable]
> 
> This is not a useful configuration, and there is not much point in saving
> a few bytes when only one of the two is enabled, so just remove all
> these ifdef checks and rely on of_match_node() and acpi_match_device()
> returning NULL when these subsystems are disabled.
> 
> Fixes: 6c5063434098 ("crypto: ccp - Add ACPI support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Would using __maybe_unused on dev_vdata be the safer, easier choice?

Either way, I don't think removing the #ifdefs will pose a problem, so:

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>   drivers/crypto/ccp/sp-platform.c | 14 ++------------
>   1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
> index 473301237760..ff6ceb4feee0 100644
> --- a/drivers/crypto/ccp/sp-platform.c
> +++ b/drivers/crypto/ccp/sp-platform.c
> @@ -39,44 +39,38 @@ static const struct sp_dev_vdata dev_vdata[] = {
>   	},
>   };
>   
> -#ifdef CONFIG_ACPI
>   static const struct acpi_device_id sp_acpi_match[] = {
>   	{ "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] },
>   	{ },
>   };
>   MODULE_DEVICE_TABLE(acpi, sp_acpi_match);
> -#endif
>   
> -#ifdef CONFIG_OF
>   static const struct of_device_id sp_of_match[] = {
>   	{ .compatible = "amd,ccp-seattle-v1a",
>   	  .data = (const void *)&dev_vdata[0] },
>   	{ },
>   };
>   MODULE_DEVICE_TABLE(of, sp_of_match);
> -#endif
>   
>   static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
>   {
> -#ifdef CONFIG_OF
>   	const struct of_device_id *match;
>   
>   	match = of_match_node(sp_of_match, pdev->dev.of_node);
>   	if (match && match->data)
>   		return (struct sp_dev_vdata *)match->data;
> -#endif
> +
>   	return NULL;
>   }
>   
>   static struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
>   {
> -#ifdef CONFIG_ACPI
>   	const struct acpi_device_id *match;
>   
>   	match = acpi_match_device(sp_acpi_match, &pdev->dev);
>   	if (match && match->driver_data)
>   		return (struct sp_dev_vdata *)match->driver_data;
> -#endif
> +
>   	return NULL;
>   }
>   
> @@ -212,12 +206,8 @@ static int sp_platform_resume(struct platform_device *pdev)
>   static struct platform_driver sp_platform_driver = {
>   	.driver = {
>   		.name = "ccp",
> -#ifdef CONFIG_ACPI
>   		.acpi_match_table = sp_acpi_match,
> -#endif
> -#ifdef CONFIG_OF
>   		.of_match_table = sp_of_match,
> -#endif
>   	},
>   	.probe = sp_platform_probe,
>   	.remove_new = sp_platform_remove,
Arnd Bergmann April 3, 2024, 3:50 p.m. UTC | #2
On Wed, Apr 3, 2024, at 17:17, Tom Lendacky wrote:
> On 4/3/24 03:06, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> When both ACPI and OF are disabled, the dev_vdata variable is unused:
>> 
>> drivers/crypto/ccp/sp-platform.c:33:34: error: unused variable 'dev_vdata' [-Werror,-Wunused-const-variable]
>> 
>> This is not a useful configuration, and there is not much point in saving
>> a few bytes when only one of the two is enabled, so just remove all
>> these ifdef checks and rely on of_match_node() and acpi_match_device()
>> returning NULL when these subsystems are disabled.
>> 
>> Fixes: 6c5063434098 ("crypto: ccp - Add ACPI support")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Would using __maybe_unused on dev_vdata be the safer, easier choice?

It's a simpler change, but leaves the extra complexity that
is not needed here.

      Arnd
Herbert Xu April 12, 2024, 7:30 a.m. UTC | #3
On Wed, Apr 03, 2024 at 10:06:42AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When both ACPI and OF are disabled, the dev_vdata variable is unused:
> 
> drivers/crypto/ccp/sp-platform.c:33:34: error: unused variable 'dev_vdata' [-Werror,-Wunused-const-variable]
> 
> This is not a useful configuration, and there is not much point in saving
> a few bytes when only one of the two is enabled, so just remove all
> these ifdef checks and rely on of_match_node() and acpi_match_device()
> returning NULL when these subsystems are disabled.
> 
> Fixes: 6c5063434098 ("crypto: ccp - Add ACPI support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/crypto/ccp/sp-platform.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
index 473301237760..ff6ceb4feee0 100644
--- a/drivers/crypto/ccp/sp-platform.c
+++ b/drivers/crypto/ccp/sp-platform.c
@@ -39,44 +39,38 @@  static const struct sp_dev_vdata dev_vdata[] = {
 	},
 };
 
-#ifdef CONFIG_ACPI
 static const struct acpi_device_id sp_acpi_match[] = {
 	{ "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] },
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, sp_acpi_match);
-#endif
 
-#ifdef CONFIG_OF
 static const struct of_device_id sp_of_match[] = {
 	{ .compatible = "amd,ccp-seattle-v1a",
 	  .data = (const void *)&dev_vdata[0] },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, sp_of_match);
-#endif
 
 static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
 {
-#ifdef CONFIG_OF
 	const struct of_device_id *match;
 
 	match = of_match_node(sp_of_match, pdev->dev.of_node);
 	if (match && match->data)
 		return (struct sp_dev_vdata *)match->data;
-#endif
+
 	return NULL;
 }
 
 static struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
 {
-#ifdef CONFIG_ACPI
 	const struct acpi_device_id *match;
 
 	match = acpi_match_device(sp_acpi_match, &pdev->dev);
 	if (match && match->driver_data)
 		return (struct sp_dev_vdata *)match->driver_data;
-#endif
+
 	return NULL;
 }
 
@@ -212,12 +206,8 @@  static int sp_platform_resume(struct platform_device *pdev)
 static struct platform_driver sp_platform_driver = {
 	.driver = {
 		.name = "ccp",
-#ifdef CONFIG_ACPI
 		.acpi_match_table = sp_acpi_match,
-#endif
-#ifdef CONFIG_OF
 		.of_match_table = sp_of_match,
-#endif
 	},
 	.probe = sp_platform_probe,
 	.remove_new = sp_platform_remove,