Re: [PATCH v8 03/12] iio: ssp_sensors: refactor transfer logic into helper

From: Jonathan Cameron

Date: Sun May 17 2026 - 08:41:16 EST


On Fri, 15 May 2026 23:10:08 +0530
Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx> wrote:

> From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
>
> Extract the core transfer logic under comm_lock into a new
> __ssp_do_transfer() helper. The change is preparatory for converting
> mutex usage to guard() helpers in subsequent patches.
>
> This restructuring simplifies ssp_do_transfer() and makes the
> transfer flow easier to follow.
>
> No functional change intended.
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
> ---
> drivers/iio/common/ssp_sensors/ssp_spi.c | 50 +++++++++++++++---------
> 1 file changed, 32 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c
> index 3d377a482161..ebcda6de56c4 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_spi.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_spi.c
> @@ -196,20 +196,13 @@ static inline void ssp_pending_del(struct ssp_data *data, struct ssp_msg *msg,
> mutex_unlock(&data->pending_lock);
> }
>
> -static int ssp_do_transfer(struct ssp_data *data, struct ssp_msg *msg,
> - struct completion *done, int timeout)
> +static int __ssp_do_transfer(struct ssp_data *data, struct ssp_msg *msg,
> + bool no_irq)
> {
> int status;
> - /*
> - * check if this is a short one way message or the whole transfer has
> - * second part after an interrupt
> - */
> - const bool use_no_irq = msg->length == 0;
>
> - if (data->shut_down)
> - return -EPERM;
> -
> - msg->done = done;
> + /* msg->done must be initialized by caller */
> + WARN_ON(!msg->done);

Generally we avoid WARN_ON unless we don't mind the system going down hard
(which is a common configuration of the kernel)

Is returning an error (and dev_err()) not sufficient?

>
> mutex_lock(&data->comm_lock);
>