diff mbox series

[4/6] platform/chrome: cros_ec_proto: drop BUG_ON() in cros_ec_get_host_event()

Message ID 20220512083627.885338-5-tzungbi@kernel.org (mailing list archive)
State Superseded
Headers show
Series platform/chrome: get rid of BUG_ON() | expand

Commit Message

Tzung-Bi Shih May 12, 2022, 8:36 a.m. UTC
It is overkill to crash the kernel if the `ec_dev` doesn't support MKBP
event but gets called into cros_ec_get_host_event().

Drop the BUG_ON() and return error (0 in the case) instead.

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
 drivers/platform/chrome/cros_ec_proto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Guenter Roeck May 12, 2022, 3:12 p.m. UTC | #1
On Thu, May 12, 2022 at 1:36 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> It is overkill to crash the kernel if the `ec_dev` doesn't support MKBP
> event but gets called into cros_ec_get_host_event().
>
> Drop the BUG_ON() and return error (0 in the case) instead.
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Reviewed-by: Guenter Roeck <goeck@chromium.org>

> ---
>  drivers/platform/chrome/cros_ec_proto.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> index 9ce3374846ff..ff767dccdf0f 100644
> --- a/drivers/platform/chrome/cros_ec_proto.c
> +++ b/drivers/platform/chrome/cros_ec_proto.c
> @@ -817,7 +817,8 @@ u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev)
>  {
>         u32 host_event;
>
> -       BUG_ON(!ec_dev->mkbp_event_supported);
> +       if (!ec_dev->mkbp_event_supported)
> +               return 0;
>
>         if (ec_dev->event_data.event_type != EC_MKBP_EVENT_HOST_EVENT)
>                 return 0;
> --
> 2.36.0.512.ge40c2bad7a-goog
>
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
index 9ce3374846ff..ff767dccdf0f 100644
--- a/drivers/platform/chrome/cros_ec_proto.c
+++ b/drivers/platform/chrome/cros_ec_proto.c
@@ -817,7 +817,8 @@  u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev)
 {
 	u32 host_event;
 
-	BUG_ON(!ec_dev->mkbp_event_supported);
+	if (!ec_dev->mkbp_event_supported)
+		return 0;
 
 	if (ec_dev->event_data.event_type != EC_MKBP_EVENT_HOST_EVENT)
 		return 0;