Skip to content

Commit 3170256

Browse files
Fabrice GasnierWilliam Breathitt Gray
authored andcommitted
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: d2011be ("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>
1 parent 2dde18c commit 3170256

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/counter/counter-chrdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ static int counter_get_ext(const struct counter_comp *const ext,
247247
if (*id == component_id)
248248
return 0;
249249

250-
if (ext->type == COUNTER_COMP_ARRAY) {
251-
element = ext->priv;
250+
if (ext[*ext_idx].type == COUNTER_COMP_ARRAY) {
251+
element = ext[*ext_idx].priv;
252252

253253
if (component_id - *id < element->length)
254254
return 0;

0 commit comments

Comments
 (0)