Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

counter: interrupt-cnt: Implement watch_validate callback

The interrupt-cnt counter driver only pushes one type of event on only
one channel: COUNTER_EVENT_CHANGE_OF_STATE on channel 0. The
interrupt_cnt_watch_validate() watch_valid callback is implemented to
ensure watch configurations are valid for this driver.

Cc: Oleksij Rempel <linux@rempel-privat.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Link: https://lore.kernel.org/r/20220815225058.144203-1-william.gray@linaro.org/
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/c50b5eede7d3f523de8dc3937dc44680f2773e1d.1664318353.git.william.gray@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

William Breathitt Gray and committed by
Greg Kroah-Hartman
7bbf842c 3216e551

+11
+11
drivers/counter/interrupt-cnt.c
··· 139 139 return 0; 140 140 } 141 141 142 + static int interrupt_cnt_watch_validate(struct counter_device *counter, 143 + const struct counter_watch *watch) 144 + { 145 + if (watch->channel != 0 || 146 + watch->event != COUNTER_EVENT_CHANGE_OF_STATE) 147 + return -EINVAL; 148 + 149 + return 0; 150 + } 151 + 142 152 static const struct counter_ops interrupt_cnt_ops = { 143 153 .action_read = interrupt_cnt_action_read, 144 154 .count_read = interrupt_cnt_read, 145 155 .count_write = interrupt_cnt_write, 146 156 .function_read = interrupt_cnt_function_read, 147 157 .signal_read = interrupt_cnt_signal_read, 158 + .watch_validate = interrupt_cnt_watch_validate, 148 159 }; 149 160 150 161 static int interrupt_cnt_probe(struct platform_device *pdev)