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

platform/chrome: cros_ec_spi: drop unneeded BUG_ON()

In the context, the following conditions are always false:

- `todo` < 0
Suppose that EC_SPI_FRAME_START is found at the last byte of transfer.

In the case, `ptr` == `end` - 1. As a result, `todo` must be 0.

- `todo` > `ec_dev->din_size`
Suppose that there is no preamble bytes. EC_SPI_FRAME_START is found at
the first byte of transfer.

In the case, `end` == `ptr` + EC_MSG_PREAMBLE_COUNT.
As a result, `todo` == EC_MSG_PREAMBLE_COUNT - 1.
However, it already checked `ec_dev->din_size` < EC_MSG_PREAMBLE_COUNT at
the beginning of function.

Drop the unneeded BUG_ON().

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20220513044143.1045728-7-tzungbi@kernel.org

-2
-2
drivers/platform/chrome/cros_ec_spi.c
··· 237 237 * start of our buffer 238 238 */ 239 239 todo = end - ++ptr; 240 - BUG_ON(todo < 0 || todo > ec_dev->din_size); 241 240 todo = min(todo, need_len); 242 241 memmove(ec_dev->din, ptr, todo); 243 242 ptr = ec_dev->din + todo; ··· 344 345 * start of our buffer 345 346 */ 346 347 todo = end - ++ptr; 347 - BUG_ON(todo < 0 || todo > ec_dev->din_size); 348 348 todo = min(todo, need_len); 349 349 memmove(ec_dev->din, ptr, todo); 350 350 ptr = ec_dev->din + todo;