diff mbox series

HID: amd_sfh: change global variables to static

Message ID 20220420142244.556429-1-trix@redhat.com
State Accepted
Commit 62f8857b2d082069b11851d1ae8ce101752436ee
Headers show
Series HID: amd_sfh: change global variables to static | expand

Commit Message

Tom Rix April 20, 2022, 2:22 p.m. UTC
Smatch reports this representative issue
amd_sfh_hid_report_desc.h:182:10: warning: symbol 'gyro3_report_descriptor' was not declared. Should it be static?
Similar issues for comp3_report_descriptor and als_report_descriptor.

Global variables should not be defined in header files.
This only works because amd_sfh_hid_report_desc.h in only included by
amd_sfh_hid_desc.c so change the storage-class specifiers to static.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Basavaraj Natikar April 20, 2022, 5:50 p.m. UTC | #1
On 4/20/2022 7:52 PM, Tom Rix wrote:
> Smatch reports this representative issue
> amd_sfh_hid_report_desc.h:182:10: warning: symbol 'gyro3_report_descriptor' was not declared. Should it be static?
> Similar issues for comp3_report_descriptor and als_report_descriptor.
>
> Global variables should not be defined in header files.
> This only works because amd_sfh_hid_report_desc.h in only included by
> amd_sfh_hid_desc.c so change the storage-class specifiers to static.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h    | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> index b07dc4bbb858..7a2b4e434e4f 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> @@ -179,7 +179,7 @@ static const u8 accel3_report_descriptor[] = {
>  0xC0			/* HID end collection */
>  };
>  
> -const u8 gyro3_report_descriptor[] = {
> +static const u8 gyro3_report_descriptor[] = {
>  0x05, 0x20,		/* Usage page */
>  0x09, 0x76,		/* Motion type Gyro3D */
>  0xA1, 0x00,		/* HID Collection (Physical) */
> @@ -340,7 +340,7 @@ const u8 gyro3_report_descriptor[] = {
>  0xC0,			/* HID end collection */
>  };
>  
> -const u8 comp3_report_descriptor[] = {
> +static const u8 comp3_report_descriptor[] = {
>  0x05, 0x20,		/* Usage page */
>  0x09, 0x83,		/* Motion type Orientation compass 3D */
>  0xA1, 0x00,		/* HID Collection (Physical) */
> @@ -512,7 +512,7 @@ const u8 comp3_report_descriptor[] = {
>  0xC0				/* HID end collection */
>  };
>  
> -const u8 als_report_descriptor[] = {
> +static const u8 als_report_descriptor[] = {
>  0x05, 0x20,	/* HID usage page sensor */
>  0x09, 0x41,	/* HID usage sensor type Ambientlight  */
>  0xA1, 0x00,	/* HID Collection (Physical) */

Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Jiri Kosina April 21, 2022, 8:19 a.m. UTC | #2
On Wed, 20 Apr 2022, Tom Rix wrote:

> Smatch reports this representative issue
> amd_sfh_hid_report_desc.h:182:10: warning: symbol 'gyro3_report_descriptor' was not declared. Should it be static?
> Similar issues for comp3_report_descriptor and als_report_descriptor.
> 
> Global variables should not be defined in header files.
> This only works because amd_sfh_hid_report_desc.h in only included by
> amd_sfh_hid_desc.c so change the storage-class specifiers to static.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

Applied, thanks Tom.
diff mbox series

Patch

diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index b07dc4bbb858..7a2b4e434e4f 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -179,7 +179,7 @@  static const u8 accel3_report_descriptor[] = {
 0xC0			/* HID end collection */
 };
 
-const u8 gyro3_report_descriptor[] = {
+static const u8 gyro3_report_descriptor[] = {
 0x05, 0x20,		/* Usage page */
 0x09, 0x76,		/* Motion type Gyro3D */
 0xA1, 0x00,		/* HID Collection (Physical) */
@@ -340,7 +340,7 @@  const u8 gyro3_report_descriptor[] = {
 0xC0,			/* HID end collection */
 };
 
-const u8 comp3_report_descriptor[] = {
+static const u8 comp3_report_descriptor[] = {
 0x05, 0x20,		/* Usage page */
 0x09, 0x83,		/* Motion type Orientation compass 3D */
 0xA1, 0x00,		/* HID Collection (Physical) */
@@ -512,7 +512,7 @@  const u8 comp3_report_descriptor[] = {
 0xC0				/* HID end collection */
 };
 
-const u8 als_report_descriptor[] = {
+static const u8 als_report_descriptor[] = {
 0x05, 0x20,	/* HID usage page sensor */
 0x09, 0x41,	/* HID usage sensor type Ambientlight  */
 0xA1, 0x00,	/* HID Collection (Physical) */