Skip to contentSkip to conversation

habanalabs: change unused extern decl of hdev to forward decl of hl_device

PATCH Applied Tom Rix 3 participants 3 messages Feb 8, 2023 – Feb 16, 2023

Subsystems (2)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 habanalabs: change unused extern decl of hdev to forward decl of hl_device

Building with clang W=2 has several similar warnings
drivers/accel/habanalabs/common/decoder.c:46:51: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static void dec_error_intr_work(struct hl_device *hdev, u32 base_addr, u32 core_id)

                                                  ^
drivers/accel/habanalabs/common/security.h:13:26: note: previous declaration is here
extern struct hl_device *hdev;
                         ^

There is no global definition of hdev, so the extern is not needed. Searched with
grep -r '^struct' . | grep hl_dev

Change to an forward decl to resolve these issues
drivers/accel/habanalabs/common/mmu/../security.h:133:40: error: ‘struct hl_device’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
133 | bool (*skip_block_hook)(struct hl_device *hdev,
| ^~~~~~~~~

---
 drivers/accel/habanalabs/common/security.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/habanalabs/common/security.h +1 -1
index 234b4a6ed8bc..d7a3b3e82ea4 100644
@@ -10,7 +10,7 @@
 
 #include <linux/io-64-nonatomic-lo-hi.h>
 
-extern struct hl_device *hdev;
+struct hl_device;
 
 /* special blocks */
 #define HL_MAX_NUM_OF_GLBL_ERR_CAUSE		10
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Tom Rix

Building with clang W=2 has several similar warnings
drivers/accel/habanalabs/common/decoder.c:46:51: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static void dec_error_intr_work(struct hl_device *hdev, u32 base_addr, u32 core_id)

                                                  ^
drivers/accel/habanalabs/common/security.h:13:26: note: previous declaration is here
extern struct hl_device *hdev;
                         ^

There is no global definition of hdev, so the extern is not needed. Searched with
grep -r '^struct' . | grep hl_dev

Quoted 6 lines

Change to an forward decl to resolve these issues
drivers/accel/habanalabs/common/mmu/../security.h:133:40: error: ‘struct hl_device’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
133 | bool (*skip_block_hook)(struct hl_device *hdev,
| ^~~~~~~~~

Quoted 20 lines
---
 drivers/accel/habanalabs/common/security.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/habanalabs/common/security.h +1 -1
index 234b4a6ed8bc..d7a3b3e82ea4 100644
@@ -10,7 +10,7 @@
 
 #include <linux/io-64-nonatomic-lo-hi.h>
 
-extern struct hl_device *hdev;
+struct hl_device;
 
 /* special blocks */
 #define HL_MAX_NUM_OF_GLBL_ERR_CAUSE		10
Signature · 1 line
2.26.3
maintainer Reviewed-by Applied
#2 lore raw
Quoted 34 lines · Stanislaw Gruszka
Quoted 12 lines · Tom Rix

Building with clang W=2 has several similar warnings
drivers/accel/habanalabs/common/decoder.c:46:51: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static void dec_error_intr_work(struct hl_device *hdev, u32 base_addr, u32 core_id)

                                                  ^
drivers/accel/habanalabs/common/security.h:13:26: note: previous declaration is here
extern struct hl_device *hdev;
                         ^

There is no global definition of hdev, so the extern is not needed. Searched with
grep -r '^struct' . | grep hl_dev

Quoted 6 lines

Change to an forward decl to resolve these issues
drivers/accel/habanalabs/common/mmu/../security.h:133:40: error: ‘struct hl_device’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
133 | bool (*skip_block_hook)(struct hl_device *hdev,
| ^~~~~~~~~

Quoted 12 lines
---
 drivers/accel/habanalabs/common/security.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/habanalabs/common/security.h +0 -0
index 234b4a6ed8bc..d7a3b3e82ea4 100644
@@ -10,7 +10,7 @@
 
 #include <linux/io-64-nonatomic-lo-hi.h>
 
Quoted 8 lines
Quoted 8 lines
drivers/accel/habanalabs/common/security.h +1 -2
-extern struct hl_device *hdev;
+struct hl_device;
 
 /* special blocks */
 #define HL_MAX_NUM_OF_GLBL_ERR_CAUSE         10
--

2.26.3

Thanks, applied to -next.
Oded