Re: [PATCH 6/6] platform/chrome: cros_ec_spi: drop BUG_ON()

From: Tzung-Bi Shih
Date: Fri May 13 2022 - 01:00:47 EST


On Thu, May 12, 2022 at 08:14:10AM -0700, Guenter Roeck wrote:
> On Thu, May 12, 2022 at 1:37 AM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
> >
> > It is overkill to crash the kernel if the `din` buffer is going to full
> > or overflow.
> >
> > Drop the BUG_ON() and return -EINVAL instead.
> >
> > Signed-off-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
>
> Wonder if the return code should be -EPROTO instead, but I don't have
> a strong opinion.

Thanks for the review. I am going to split the patch into 2 smaller pieces.

For those related to preamble bytes, at the first glance, they could use
-EPROTO. But, no, they are irrelevant to the protocol. I would drop them.
See [1].

For those `din` isn't large enough, I would keep using -EINVAL as they look
more like the `ec_dev` didn't configure correctly. See [2].

[1]: https://patchwork.kernel.org/project/chrome-platform/patch/20220513044143.1045728-7-tzungbi@xxxxxxxxxx/
[2]: https://patchwork.kernel.org/project/chrome-platform/patch/20220513044143.1045728-8-tzungbi@xxxxxxxxxx/