From: Joshua Crofts Date: Tue, 5 May 2026 07:31:33 +0000 (+0200) Subject: iio: light: si1133: use guard(mutex)() macro X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0b396cab2f7d56126a9b36dba9d6c52292aa7bc;p=thirdparty%2Flinux.git iio: light: si1133: use guard(mutex)() macro Remove mutex_lock()/mutex_unlock() and goto instances and add guard(mutex)() macro to modernize driver and improve mutex handling. Reviewed-by: Andy Shevchenko Signed-off-by: Joshua Crofts Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c index ef5c38e303a6e..655fa778b4a63 100644 --- a/drivers/iio/light/si1133.c +++ b/drivers/iio/light/si1133.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -396,7 +397,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) int err; int expected_seq; - mutex_lock(&data->mutex); + guard(mutex)(&data->mutex); expected_seq = (data->rsp_seq + 1) & SI1133_MAX_CMD_CTR; @@ -413,7 +414,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) if (err) { dev_warn(dev, "Failed to write command 0x%02x, ret=%d\n", cmd, err); - goto out; + return err; } if (cmd == SI1133_CMD_FORCE) { @@ -421,12 +422,11 @@ static int si1133_command(struct si1133_data *data, u8 cmd) timeout = msecs_to_jiffies(SI1133_COMPLETION_TIMEOUT_MS); if (!wait_for_completion_timeout(&data->completion, timeout)) { regmap_write(data->regmap, SI1133_REG_IRQ_ENABLE, 0); - err = -ETIMEDOUT; - goto out; + return -ETIMEDOUT; } err = regmap_read(data->regmap, SI1133_REG_RESPONSE0, &resp); if (err) - goto out; + return err; } else { err = regmap_read_poll_timeout(data->regmap, SI1133_REG_RESPONSE0, resp, @@ -444,7 +444,7 @@ static int si1133_command(struct si1133_data *data, u8 cmd) * counters being out of sync. */ si1133_cmd_reset_counter(data); - goto out; + return err; } } @@ -455,9 +455,6 @@ static int si1133_command(struct si1133_data *data, u8 cmd) data->rsp_seq = expected_seq; } -out: - mutex_unlock(&data->mutex); - return err; }