counter: chrdev: fix getting array extensions
authorFabrice Gasnier <fabrice.gasnier@foss.st.com>
Tue, 29 Aug 2023 13:40:22 +0000 (15:40 +0200)
committerWilliam Breathitt Gray <william.gray@linaro.org>
Mon, 4 Sep 2023 18:56:27 +0000 (14:56 -0400)
commit3170256d7bc1ef81587caf4b83573eb1f5bb4fb6
tree3026e7df6c8014e327a8fcc2131e02ffabac3108
parent2dde18cd1d8fac735875f2e4987f11817cc0bc2c
counter: chrdev: fix getting array extensions

When trying to watch a component array extension, and the array isn't the
first extended element, it fails as the type comparison is always done on
the 1st element. Fix it by indexing the 'ext' array.

Example on a dummy struct counter_comp:
static struct counter_comp dummy[] = {
COUNTER_COMP_DIRECTION(..),
...,
COUNTER_COMP_ARRAY_CAPTURE(...),
};
static struct counter_count dummy_cnt = {
...
.ext = dummy,
.num_ext = ARRAY_SIZE(dummy),
}

Currently, counter_get_ext() returns -EINVAL when trying to add a watch
event on one of the capture array element in such example.

Fixes: d2011be1e22f ("counter: Introduce the COUNTER_COMP_ARRAY component type")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20230829134029.2402868-2-fabrice.gasnier@foss.st.com
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
drivers/counter/counter-chrdev.c