[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aG88SyVAdO0txGMi@google.com>
Date: Thu, 10 Jul 2025 04:06:35 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Radu Vele <raduvele@...gle.com>
Cc: Benson Leung <bleung@...omium.org>,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
Jameson Thies <jthies@...gle.com>,
Andrei Kuchynski <akuchynski@...omium.org>,
chrome-platform@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/2] platform/chrome: cros_ec_typec: Add lock per-port
On Wed, Jul 09, 2025 at 01:22:32PM +0000, Radu Vele wrote:
> @@ -8,6 +8,7 @@
>
> #include <linux/acpi.h>
> #include <linux/module.h>
> +#include <linux/mutex.h>
> #include <linux/of.h>
> #include <linux/platform_data/cros_ec_commands.h>
> #include <linux/platform_data/cros_usbpd_notify.h>
Please consider to include linux/cleanup.h and use guard() to simplify the
patch.
> @@ -54,8 +55,11 @@ static int cros_typec_enter_usb_mode(struct typec_port *tc_port, enum usb_mode m
> .mode_to_enter = CROS_EC_ALTMODE_USB4
> };
>
> - return cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL,
> + mutex_lock(&port->lock);
> + int ret = cros_ec_cmd(port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL,
> &req, sizeof(req), NULL, 0);
> + mutex_unlock(&port->lock);
> + return ret;
E.g.:
guard(mutex)(&port->lock);
return cros_ec_cmd(...);
> static int cros_typec_perform_role_swap(struct typec_port *tc_port, int target_role, u8 swap_type)
> @@ -70,6 +74,8 @@ static int cros_typec_perform_role_swap(struct typec_port *tc_port, int target_r
> if (!data->pd_ctrl_ver)
> return -EOPNOTSUPP;
>
> + mutex_lock(&port->lock);
It can drop all the following diff hunks in the function if using:
guard(mutex)(&port->lock);
> @@ -1232,6 +1248,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
> return -EINVAL;
> }
>
> + mutex_lock(&typec->ports[port_num]->lock);
It can drop all the following diff hunks in the function if using:
guard(mutex)(&typec->ports[port_num]->lock);
Powered by blists - more mailing lists