[PATCH] iio: light: tsl2591: remove unneeded tsl2591_compatible_als_persist_cycle()
Guilherme Ivo Bozi
guilherme.bozi em usp.br
Seg Jun 1 19:13:39 -03 2026
Hi Lucas and Matheus,
On 01/06/2026 13:36, Lucas Rabaquim wrote:
> The function was only used to verify if als_persist is a
> TSL2591_PRST_ALS_INT_CYCLE_* value. However, before its call in
> tsl2591_write_event_value(), the line
> als_persist = tsl2591_persist_lit_to_cycle(period) is executed,
> meaning that by the time tsl2591_compatible_als_persist_cycle()
> is reached, als_persist is a TSL2591_PRST_ALS_INT_CYCLE_* value,
> making the verification pointless.
>
> Suggested-by: Jonathan Cameron <jic23 em kernel.org>
> Link: https://lore.kernel.org/linux-iio/20260529113956.1c4198fc@jic23-huawei/
>
Usually these tags are kept together without a blank line before the
Signed-off-by, see:
git log --grep="Suggested-by:"
> Signed-off-by: Lucas Rabaquim <lucas.rabaquim em usp.br>
> Co-developed-by: Matheus Silveira <matheus.feitosa em usp.br>
> Signed-off-by: Matheus Silveira <matheus.feitosa em usp.br>
> ---
> drivers/iio/light/tsl2591.c | 29 -----------------------------
> 1 file changed, 29 deletions(-)
>
> diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
> index 3ec823865ce2..39cb68abbbea 100644
> --- a/drivers/iio/light/tsl2591.c
> +++ b/drivers/iio/light/tsl2591.c
> @@ -309,31 +309,6 @@ static int tsl2591_compatible_gain(struct tsl2591_chip *chip, const u8 als_gain)
> }
> }
>
> -static int tsl2591_compatible_als_persist_cycle(struct tsl2591_chip *chip,
> - const u32 als_persist)
> -{
> - switch (als_persist) {
> - case TSL2591_PRST_ALS_INT_CYCLE_ANY:
> - case TSL2591_PRST_ALS_INT_CYCLE_2:
> - case TSL2591_PRST_ALS_INT_CYCLE_3:
> - case TSL2591_PRST_ALS_INT_CYCLE_5:
> - case TSL2591_PRST_ALS_INT_CYCLE_10:
> - case TSL2591_PRST_ALS_INT_CYCLE_15:
> - case TSL2591_PRST_ALS_INT_CYCLE_20:
> - case TSL2591_PRST_ALS_INT_CYCLE_25:
> - case TSL2591_PRST_ALS_INT_CYCLE_30:
> - case TSL2591_PRST_ALS_INT_CYCLE_35:
> - case TSL2591_PRST_ALS_INT_CYCLE_40:
> - case TSL2591_PRST_ALS_INT_CYCLE_45:
> - case TSL2591_PRST_ALS_INT_CYCLE_50:
> - case TSL2591_PRST_ALS_INT_CYCLE_55:
> - case TSL2591_PRST_ALS_INT_CYCLE_60:
> - return 0;
> - default:
> - return -EINVAL;
> - }
> -}
> -
> static int tsl2591_check_als_valid(struct i2c_client *client)
> {
> int ret;
> @@ -915,10 +890,6 @@ static int tsl2591_write_event_value(struct iio_dev *indio_dev,
> goto err_unlock;
> }
>
> - ret = tsl2591_compatible_als_persist_cycle(chip, als_persist);
> - if (ret < 0)
> - goto err_unlock;
> -
> ret = tsl2591_set_als_persist_cycle(chip, als_persist);
> if (ret < 0)
> goto err_unlock;
Apart from that, the change looks good to me.
--
Kind regards,
Guilherme Ivo
Mais detalhes sobre a lista de discussão kernel