<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/include/linux/counter.h, branch v6.6.132</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.132</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.132'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2024-06-12T09:12:14+00:00</updated>
<entry>
<title>counter: linux/counter.h: fix Excess kernel-doc description warning</title>
<updated>2024-06-12T09:12:14+00:00</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2023-12-23T05:05:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=30dc493b81955c7d2098af3b154ab013e071bef3'/>
<id>urn:sha1:30dc493b81955c7d2098af3b154ab013e071bef3</id>
<content type='text'>
[ Upstream commit 416bdb89605d960405178b9bf04df512d1ace1a3 ]

Remove the @priv: line to prevent the kernel-doc warning:

include/linux/counter.h:400: warning: Excess struct member 'priv' description in 'counter_device'

Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Fixes: f2ee4759fb70 ("counter: remove old and now unused registration API")
Link: https://lore.kernel.org/r/20231223050511.13849-1-rdunlap@infradead.org
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>counter: Declare counter_priv() to be const</title>
<updated>2023-08-16T13:41:29+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2023-07-18T16:20:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=83bc0982bf25edfcb261bebee51abc76ce8a975b'/>
<id>urn:sha1:83bc0982bf25edfcb261bebee51abc76ce8a975b</id>
<content type='text'>
According to the gcc manual functions "whose return value is not
affected by changes to the observable state of the program and that have
no observable effects on such state other than to return a value may
lend themselves to optimizations such as common subexpression
elimination. Declaring such functions with the 'const' attribute allows
GCC to avoid emitting some calls in repeated invocations of the function
with the same argument values."

counter_priv() is such a function and so can be marked with the const
function attribute.

The effect for an arm allyesconfig build according to bloat-o-meter (on
top of v6.5-rc2) is:

	add/remove: 0/1 grow/shrink: 2/14 up/down: 524/-1064 (-540)
	Function                                     old     new   delta
	rz_mtu3_count_enable_write                   632    1152    +520
	stm32_count_enable_write                     372     376      +4
	ti_eqep_action_read                          456     452      -4
	stm32_lptim_cnt_action_write                 400     392      -8
	stm32_lptim_cnt_action_read                  300     288     -12
	rz_mtu3_count_write                          296     284     -12
	rz_mtu3_count_read                           304     292     -12
	rz_mtu3_count_function_read                  212     200     -12
	rz_mtu3_count_direction_read                 268     256     -12
	rz_mtu3_action_read                          628     616     -12
	rz_mtu3_count_function_write                 328     312     -16
	ecap_cnt_suspend                             364     340     -24
	ecap_cnt_resume                              300     276     -24
	rz_mtu3_count_ceiling_write                  596     560     -36
	rz_mtu3_count_enable_read                    332     288     -44
	rz_mtu3_count_ceiling_read                   384     340     -44
	rz_mtu3_initialize_counter                   792       -    -792
	Total: Before=60715, After=60175, chg -0.89%

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20230718162015.3940148-1-u.kleine-koenig@pengutronix.de/
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
</content>
</entry>
<entry>
<title>counter: Reduce DEFINE_COUNTER_ARRAY_POLARITY() to defining counter_array</title>
<updated>2022-10-17T13:51:29+00:00</updated>
<author>
<name>William Breathitt Gray</name>
<email>william.gray@linaro.org</email>
</author>
<published>2022-10-02T12:04:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=472a1482325b3a285e0bcf82c0b0edc689b7e8cd'/>
<id>urn:sha1:472a1482325b3a285e0bcf82c0b0edc689b7e8cd</id>
<content type='text'>
A spare warning was reported for drivers/counter/ti-ecap-capture.c::

    sparse warnings: (new ones prefixed by &gt;&gt;)
    &gt;&gt; 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
     &gt; 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 = &amp;(_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 &lt;lkp@intel.com&gt;
Link: https://lore.kernel.org/all/202210020619.NQbyomII-lkp@intel.com/
Cc: Julien Panis &lt;jpanis@baylibre.com&gt;
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
</content>
</entry>
<entry>
<title>counter: Introduce the COUNTER_COMP_ARRAY component type</title>
<updated>2022-09-30T12:32:35+00:00</updated>
<author>
<name>William Breathitt Gray</name>
<email>william.gray@linaro.org</email>
</author>
<published>2022-09-27T22:53:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d2011be1e22f7769c7c71d6d7f777ffcc544808d'/>
<id>urn:sha1:d2011be1e22f7769c7c71d6d7f777ffcc544808d</id>
<content type='text'>
The COUNTER_COMP_ARRAY Counter component type is introduced to enable
support for Counter array components. With Counter array components,
exposure for buffers on counter devices can be defined via new Counter
array component macros. This should simplify code for driver authors who
would otherwise need to define individual Counter components for each
array element.

Eight Counter array component macros are introduced::

        DEFINE_COUNTER_ARRAY_U64(_name, _length)
        DEFINE_COUNTER_ARRAY_CAPTURE(_name, _length)
        DEFINE_COUNTER_ARRAY_POLARITY(_name, _enums, _length)
        COUNTER_COMP_DEVICE_ARRAY_U64(_name, _read, _write, _array)
        COUNTER_COMP_COUNT_ARRAY_U64(_name, _read, _write, _array)
        COUNTER_COMP_SIGNAL_ARRAY_U64(_name, _read, _write, _array)
        COUNTER_COMP_ARRAY_CAPTURE(_read, _write, _array)
        COUNTER_COMP_ARRAY_POLARITY(_read, _write, _array)

Eight Counter array callbacks are introduced as well::

        int (*signal_array_u32_read)(struct counter_device *counter,
                                     struct counter_signal *signal,
                                     size_t idx, u32 *val);
        int (*signal_array_u32_write)(struct counter_device *counter,
                                      struct counter_signal *signal,
                                      size_t idx, u32 val);
        int (*device_array_u64_read)(struct counter_device *counter,
                                     size_t idx, u64 *val);
        int (*count_array_u64_read)(struct counter_device *counter,
                                    struct counter_count *count,
                                    size_t idx, u64 *val);
        int (*signal_array_u64_read)(struct counter_device *counter,
                                     struct counter_signal *signal,
                                     size_t idx, u64 *val);
        int (*device_array_u64_write)(struct counter_device *counter,
                                      size_t idx, u64 val);
        int (*count_array_u64_write)(struct counter_device *counter,
                                     struct counter_count *count,
                                     size_t idx, u64 val);
        int (*signal_array_u64_write)(struct counter_device *counter,
                                      struct counter_signal *signal,
                                      size_t idx, u64 val);

Driver authors can handle reads/writes for an array component by
receiving an element index via the `idx` parameter and processing the
respective value via the `val` parameter.

For example, suppose a driver wants to expose a Count's read-only
capture buffer of four elements using a callback
`foobar_capture_read()`::

        DEFINE_COUNTER_ARRAY_CAPTURE(foobar_capture_array, 4);
        COUNTER_COMP_ARRAY_CAPTURE(foobar_capture_read, NULL,
                                   foobar_capture_array)

Respective sysfs attributes for each array element would appear for the
respective Count:

* /sys/bus/counter/devices/counterX/countY/capture0
* /sys/bus/counter/devices/counterX/countY/capture1
* /sys/bus/counter/devices/counterX/countY/capture2
* /sys/bus/counter/devices/counterX/countY/capture3

If a user tries to read _capture2_ for example, `idx` will be `2` when
passed to the `foobar_capture_read()` callback, and thus the driver
knows which array element to handle.

Counter arrays for polarity elements can be defined in a similar
manner as u64 elements::

        const enum counter_signal_polarity foobar_polarity_states[] = {
                COUNTER_SIGNAL_POLARITY_POSITIVE,
                COUNTER_SIGNAL_POLARITY_NEGATIVE,
        };
        DEFINE_COUNTER_ARRAY_POLARITY(foobar_polarity_array,
                                      foobar_polarity_states, 4);
        COUNTER_COMP_ARRAY_POLARITY(foobar_polarity_read,
                                    foobar_polarity_write,
                                    foobar_polarity_array)

Tested-by: Julien Panis &lt;jpanis@baylibre.com&gt;
Link: https://lore.kernel.org/r/5310c22520aeae65b1b74952419f49ac4c8e1ec1.1664204990.git.william.gray@linaro.org/
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
Link: https://lore.kernel.org/r/a51fd608704bdfc5a0efa503fc5481df34241e0a.1664318353.git.william.gray@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: Introduce the Count capture component</title>
<updated>2022-09-30T12:32:35+00:00</updated>
<author>
<name>William Breathitt Gray</name>
<email>william.gray@linaro.org</email>
</author>
<published>2022-09-27T22:53:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=45d2918520b2d8e640e4fb3fbf664dfb823dc520'/>
<id>urn:sha1:45d2918520b2d8e640e4fb3fbf664dfb823dc520</id>
<content type='text'>
Some devices provide a latch function to save historic Count values.
This patch standardizes exposure of such functionality as Count capture
components. A COUNTER_COMP_CAPTURE macro is provided for driver authors
to define a capture component. A new event COUNTER_EVENT_CAPTURE is
introduced to represent Count value capture events.

Cc: Julien Panis &lt;jpanis@baylibre.com&gt;
Link: https://lore.kernel.org/r/c239572ab4208d0d6728136e82a88ad464369a7a.1664204990.git.william.gray@linaro.org/
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
Link: https://lore.kernel.org/r/3cebaa0b807a225eb277d771504fe6dba7269ffd.1664318353.git.william.gray@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: Introduce the Signal polarity component</title>
<updated>2022-09-30T12:32:35+00:00</updated>
<author>
<name>William Breathitt Gray</name>
<email>william.gray@linaro.org</email>
</author>
<published>2022-09-27T22:53:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=650ae67bbf7ba5ac193f053969612fbb93247b64'/>
<id>urn:sha1:650ae67bbf7ba5ac193f053969612fbb93247b64</id>
<content type='text'>
The Signal polarity component represents the active level of a
respective Signal. There are two possible states: positive (rising edge)
and negative (falling edge); enum counter_signal_polarity represents
these states. A convenience macro COUNTER_COMP_POLARITY() is provided
for driver authors to declare a Signal polarity component.

Cc: Julien Panis &lt;jpanis@baylibre.com&gt;
Link: https://lore.kernel.org/r/8f47d6e1db71a11bb1e2666f8e2a6e9d256d4131.1664204990.git.william.gray@linaro.org/
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
Link: https://lore.kernel.org/r/b6e53438badcb6318997d13dd2fc052f97d808ac.1664318353.git.william.gray@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: Realign counter_comp comment block to 80 characters</title>
<updated>2022-09-22T11:28:31+00:00</updated>
<author>
<name>William Breathitt Gray</name>
<email>william.gray@linaro.org</email>
</author>
<published>2022-09-22T11:20:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cca1fd41ab2862465d75443822d751e4f9a112ee'/>
<id>urn:sha1:cca1fd41ab2862465d75443822d751e4f9a112ee</id>
<content type='text'>
The member documentation comment lines for struct counter_comp extend
past the 80-characters column boundary due to extra identation at the
start of each section. This patch realigns the comment block within the
80-characters boundary by removing these superfluous indents.

Reviewed-by: Yanteng Si &lt;siyanteng@loongson.cn&gt;
Link: https://lore.kernel.org/r/20220902120839.4260-1-william.gray@linaro.org/
Signed-off-by: William Breathitt Gray &lt;william.gray@linaro.org&gt;
Link: https://lore.kernel.org/r/8294b04153c33602e9c3dd21ac90c1e99bd0fdaf.1663844776.git.william.gray@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: remove old and now unused registration API</title>
<updated>2021-12-30T16:44:07+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2021-12-30T15:03:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f2ee4759fb700b32a1bd830960fe86bf6bdfd0ab'/>
<id>urn:sha1:f2ee4759fb700b32a1bd830960fe86bf6bdfd0ab</id>
<content type='text'>
Usage of counter_register() yields issues in device lifetime tracking. All
drivers were converted to the new API, so the old one can go away.

Reviewed-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Acked-by: William Breathitt Gray &lt;vilhelm.gray@gmail.com&gt;
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20211230150300.72196-24-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: Provide alternative counter registration functions</title>
<updated>2021-12-30T16:44:06+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2021-12-30T15:02:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c18e2760308e30f007fa24b558b87c39d7e86ff1'/>
<id>urn:sha1:c18e2760308e30f007fa24b558b87c39d7e86ff1</id>
<content type='text'>
The current implementation gets device lifetime tracking wrong. The
problem is that allocation of struct counter_device is controlled by the
individual drivers but this structure contains a struct device that
might have to live longer than a driver is bound. As a result a command
sequence like:

	{ sleep 5; echo bang; } &gt; /dev/counter0 &amp;
	sleep 1;
	echo 40000000.timer:counter &gt; /sys/bus/platform/drivers/stm32-timer-counter/unbind

can keep a reference to the struct device and unbinding results in
freeing the memory occupied by this device resulting in an oops.

This commit provides two new functions (plus some helpers):
 - counter_alloc() to allocate a struct counter_device that is
   automatically freed once the embedded struct device is released
 - counter_add() to register such a device.

Note that this commit doesn't fix any issues, all drivers have to be
converted to these new functions to correct the lifetime problems.

Reviewed-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20211230150300.72196-14-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>counter: Provide a wrapper to access device private data</title>
<updated>2021-12-30T16:44:06+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2021-12-30T15:02:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5207fb2f311b0c45a9abfa1c84b7a7b657ffa550'/>
<id>urn:sha1:5207fb2f311b0c45a9abfa1c84b7a7b657ffa550</id>
<content type='text'>
For now this just wraps accessing struct counter_device::priv. However
this is about to change and converting drivers to this helper
individually makes fixing device lifetime issues result in easier to
review patches.

Reviewed-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Acked-by: William Breathitt Gray &lt;vilhelm.gray@gmail.com&gt;
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Link: https://lore.kernel.org/r/20211230150300.72196-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
