PCI: cpcihp: Move declaration of cpci_debug to the header file
Subsystems (2)
PATCH 1/1 PCI: cpcihp: Move declaration of cpci_debug to the header file
At the moment, the global variable cpci_debug is declared in the cpci_hotplug_core.c file. Since this variable has users outside of this file and uses the extern keyword to change its visibility, move the variable declaration to the header file.
This resolves the following sparse warning:
drivers/pci/hotplug/cpci_hotplug_core.c:47:5: warning: symbol 'cpci_debug' was not declared. Should it be static?
--- drivers/pci/hotplug/cpci_hotplug.h | 3 +++ drivers/pci/hotplug/cpci_hotplug_core.c | 1 - drivers/pci/hotplug/cpci_hotplug_pci.c | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/pci/hotplug/cpci_hotplug.h +3 -0
@@ -75,6 +75,9 @@ int cpci_hp_unregister_bus(struct pci_bus *bus);int cpci_hp_start (void );int cpci_hp_stop (void ); +/* Global variables */ +extern int cpci_debug; +/* * Internal function prototypes, these functions should not be used by * board/chassis drivers.
drivers/pci/hotplug/cpci_hotplug_core.c +0 -1
@@ -44,7 +44,6 @@ static DECLARE_RWSEM(list_rwsem);static LIST_HEAD (slot_list);static int slots;static atomic_t extracting; -int cpci_debug;static struct cpci_hp_controller *controller;static struct task_struct *cpci_thread;static int thread_finished;
drivers/pci/hotplug/cpci_hotplug_pci.c +0 -2
@@ -19,8 +19,6 @@#define MY_NAME "cpci_hotplug" -extern int cpci_debug; - #define dbg(format, arg...) \ do { \ if (cpci_debug) \
Signature · 1 line
2.31.1
Quoted 35 lines · Krzysztof Wilczyński
At the moment, the global variable
cpci_debugis declared in thecpci_hotplug_core.cfile. Since this variable has users outside of this file and uses the extern keyword to change its visibility, move the variable declaration to the header file.This resolves the following sparse warning:
drivers/pci/hotplug/cpci_hotplug_core.c:47:5: warning: symbol 'cpci_debug' was not declared. Should it be static?Signed-off-by Krzysztof Wilczyński <[email protected]>--- drivers/pci/hotplug/cpci_hotplug.h | 3 +++ drivers/pci/hotplug/cpci_hotplug_core.c | 1 - drivers/pci/hotplug/cpci_hotplug_pci.c | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/pci/hotplug/cpci_hotplug.h +3
-0@@ -75,6 +75,9 @@ int cpci_hp_unregister_bus(struct pci_bus *bus);int cpci_hp_start (void );int cpci_hp_stop (void ); +/* Global variables */ +extern int cpci_debug; +/* * Internal function prototypes, these functions should not be used by * board/chassis drivers. drivers/pci/hotplug/cpci_hotplug_core.c +0
-0
drivers/pci/hotplug/cpci_hotplug_core.c static DECLARE_RWSEM(list_rwsem); · line 47
Quoted 4 lines
drivers/pci/hotplug/cpci_hotplug_core.c +0
-1@@ -44,7 +44,6 @@ static DECLARE_RWSEM(list_rwsem);static LIST_HEAD (slot_list);static int slots;static atomic_t extracting; -int cpci_debug;
We can add a declaration, but we still need a *definition* somewhere, right?
drivers/pci/hotplug/ has several drivers that are split over multiple files. IMHO there is zero benefit to splitting them into multiple files and one of the downsides is things like this that shouldn't be global, but are global because of the split.
Not sure it's worth the churn of squashing them together, at least for ancient things like this. pciehp is a perennial thorn in my side, though. Every time I look for something, I try two or three files before finding the right one.
Quoted 19 lines
drivers/pci/hotplug/cpci_hotplug_core.c +0
-0static struct cpci_hp_controller *controller;static struct task_struct *cpci_thread;static int thread_finished;drivers/pci/hotplug/cpci_hotplug_pci.c +0
-2@@ -19,8 +19,6 @@#define MY_NAME "cpci_hotplug" -extern int cpci_debug; - #define dbg(format, arg...) \ do { \ if (cpci_debug) \Signature · 1 line
2.31.1
Hi Bjorn,
[...]
Quoted 10 lines
drivers/pci/hotplug/cpci_hotplug_core.c static DECLARE_RWSEM(list_rwsem); · line 47
Quoted 7 lines
drivers/pci/hotplug/cpci_hotplug_core.c +0
-1@@ -44,7 +44,6 @@ static DECLARE_RWSEM(list_rwsem);static LIST_HEAD (slot_list);static int slots;static atomic_t extracting; -int cpci_debug;We can add a declaration, but we still need a *definition* somewhere, right?
This is my bad! Sincere apologies. I will send a v2 that drops this hunk. This should have never been removed.
Krzysztof