counter: Reduce DEFINE_COUNTER_ARRAY_POLARITY() to defining counter_array
authorWilliam Breathitt Gray <william.gray@linaro.org>
Sun, 2 Oct 2022 12:04:19 +0000 (08:04 -0400)
committerWilliam Breathitt Gray <william.gray@linaro.org>
Mon, 17 Oct 2022 13:51:29 +0000 (09:51 -0400)
commit472a1482325b3a285e0bcf82c0b0edc689b7e8cd
treec52d35cb4ad12987ed8e9c60d23bf9e04e8d2b8d
parent9abf2313adc1ca1b6180c508c25f22f9395cc780
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 <lkp@intel.com>
Link: https://lore.kernel.org/all/202210020619.NQbyomII-lkp@intel.com/
Cc: Julien Panis <jpanis@baylibre.com>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
drivers/counter/ti-ecap-capture.c
include/linux/counter.h