Skip to content

Commit 472a148

Browse files
author
William Breathitt Gray
committed
counter: Reduce DEFINE_COUNTER_ARRAY_POLARITY() to defining counter_array
A spare warning was reported for drivers/counter/ti-ecap-capture.c:: sparse warnings: (new ones prefixed by >>) >> drivers/counter/ti-ecap-capture.c:380:8: sparse: sparse: symbol 'ecap_cnt_pol_array' was not declared. Should it be static? vim +/ecap_cnt_pol_array +380 drivers/counter/ti-ecap-capture.c 379 > 380 static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_avail, ECAP_NB_CEVT); 381 The first argument to the DEFINE_COUNTER_ARRAY_POLARITY() macro is a token serving as the symbol name in the definition of a new struct counter_array structure. However, this macro actually expands to two statements:: #define DEFINE_COUNTER_ARRAY_POLARITY(_name, _enums, _length) \ DEFINE_COUNTER_AVAILABLE(_name##_available, _enums); \ struct counter_array _name = { \ .type = COUNTER_COMP_SIGNAL_POLARITY, \ .avail = &(_name##_available), \ .length = (_length), \ } Because of this, the "static" on line 380 only applies to the first statement. This patch splits out the DEFINE_COUNTER_AVAILABLE() line and leaves DEFINE_COUNTER_ARRAY_POLARITY() as a simple structure definition to avoid issues like this. Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Cc: Julien Panis <[email protected]> Signed-off-by: William Breathitt Gray <[email protected]>
1 parent 9abf231 commit 472a148

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/counter/ti-ecap-capture.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ static const enum counter_signal_polarity ecap_cnt_pol_avail[] = {
377377
COUNTER_SIGNAL_POLARITY_NEGATIVE,
378378
};
379379

380-
static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_avail, ECAP_NB_CEVT);
380+
static DEFINE_COUNTER_AVAILABLE(ecap_cnt_pol_available, ecap_cnt_pol_avail);
381+
static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_available, ECAP_NB_CEVT);
381382

382383
static struct counter_comp ecap_cnt_signal_ext[] = {
383384
COUNTER_COMP_ARRAY_POLARITY(ecap_cnt_pol_read, ecap_cnt_pol_write, ecap_cnt_pol_array),

include/linux/counter.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,10 @@ struct counter_array {
542542
#define DEFINE_COUNTER_ARRAY_CAPTURE(_name, _length) \
543543
DEFINE_COUNTER_ARRAY_U64(_name, _length)
544544

545-
#define DEFINE_COUNTER_ARRAY_POLARITY(_name, _enums, _length) \
546-
DEFINE_COUNTER_AVAILABLE(_name##_available, _enums); \
545+
#define DEFINE_COUNTER_ARRAY_POLARITY(_name, _available, _length) \
547546
struct counter_array _name = { \
548547
.type = COUNTER_COMP_SIGNAL_POLARITY, \
549-
.avail = &(_name##_available), \
548+
.avail = &(_available), \
550549
.length = (_length), \
551550
}
552551

0 commit comments

Comments
 (0)