Skip to content

Commit ddec8e9

Browse files
author
Tzung-Bi Shih
committed
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8bff946 commit ddec8e9

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

drivers/platform/chrome/cros_ec_spi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ static int cros_ec_spi_receive_packet(struct cros_ec_device *ec_dev,
237237
* start of our buffer
238238
*/
239239
todo = end - ++ptr;
240-
BUG_ON(todo < 0 || todo > ec_dev->din_size);
241240
todo = min(todo, need_len);
242241
memmove(ec_dev->din, ptr, todo);
243242
ptr = ec_dev->din + todo;
@@ -345,7 +344,6 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev,
345344
* start of our buffer
346345
*/
347346
todo = end - ++ptr;
348-
BUG_ON(todo < 0 || todo > ec_dev->din_size);
349347
todo = min(todo, need_len);
350348
memmove(ec_dev->din, ptr, todo);
351349
ptr = ec_dev->din + todo;

0 commit comments

Comments
 (0)