drivers: can: stm32_can: Fix shifting zero width or out of bounds
When attaching the filters in a way that the filter width dos not change but the type, CAN_NO_FREE_FILTER was returned when the new filter is at the end. Also shifting is not necessary when the start is already out of bounds. Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
parent
4fb64d11c8
commit
8484855428
1 changed files with 14 additions and 10 deletions
|
@ -702,19 +702,23 @@ static inline int can_stm32_set_filter(const struct zcan_filter *filter,
|
||||||
scale_reg);
|
scale_reg);
|
||||||
|
|
||||||
start_index = filter_index_new + filter_in_bank[bank_mode];
|
start_index = filter_index_new + filter_in_bank[bank_mode];
|
||||||
res = can_stm32_shift_arr(device_data->rx_response,
|
|
||||||
start_index,
|
|
||||||
shift_width);
|
|
||||||
|
|
||||||
if (filter_index_new >= CONFIG_CAN_MAX_FILTER || res) {
|
if (shift_width && start_index <= CAN_MAX_NUMBER_OF_FILTERS) {
|
||||||
LOG_INF("No space for a new filter!");
|
res = can_stm32_shift_arr(device_data->rx_response,
|
||||||
filter_nr = CAN_NO_FREE_FILTER;
|
start_index,
|
||||||
goto done;
|
shift_width);
|
||||||
|
|
||||||
|
if (filter_index_new >= CONFIG_CAN_MAX_FILTER || res) {
|
||||||
|
LOG_INF("No space for a new filter!");
|
||||||
|
filter_nr = CAN_NO_FREE_FILTER;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
can_stm32_shift_bits(&device_data->response_type,
|
||||||
|
start_index,
|
||||||
|
shift_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
can_stm32_shift_bits(&device_data->response_type,
|
|
||||||
start_index,
|
|
||||||
shift_width);
|
|
||||||
can->FM1R = mode_reg;
|
can->FM1R = mode_reg;
|
||||||
can->FS1R = scale_reg;
|
can->FS1R = scale_reg;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue