mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>,
	joshua.crofts1@gmail.com, jic23@kernel.org
Cc: nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
Subject: Re: [PATCH] iio: light: veml3328: remove redundant cast in read_avail
Date: Mon, 27 Jul 2026 08:15:59 -0500	[thread overview]
Message-ID: <90018da7-8d84-4bfd-b2e1-f832ca03f764@baylibre.com> (raw)
In-Reply-To: <20260727112726.211344-1-giorgitchankvetadze1997@gmail.com>

On 7/27/26 6:27 AM, Giorgi Tchankvetadze wrote:
> From: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> 
> veml3328_scale_vals is declared as a const int array, so
> veml3328_scale_vals[it_inx] already decays to const int *,
> matching the type of *vals. The explicit (const int *) cast
> is therefore redundant and can be dropped.
> 
> No functional change.
> 
> Signed-off-by: Giorgi Tchankvetadze <giorgi@tchankvetadze.com>
> ---
>  drivers/iio/light/veml3328.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/veml3328.c b/drivers/iio/light/veml3328.c
> index 7ff1753925c4..a3c49beee93a 100644
> --- a/drivers/iio/light/veml3328.c
> +++ b/drivers/iio/light/veml3328.c
> @@ -228,7 +228,7 @@ static int veml3328_read_avail(struct iio_dev *indio_dev,
>  			return -EINVAL;
>  
>  		*length = 8;
> -		*vals = (const int *)veml3328_scale_vals[it_inx];
> +		*vals = veml3328_scale_vals[it_inx];
>  		*type = IIO_VAL_INT_PLUS_MICRO;
>  		return IIO_AVAIL_LIST;
>  	}

We'll see if there are other opinions (before sending a v2)...

Usually, we would declare the array like:

static const int veml3328_scale_vals[4][4][2] ...

in which case this cast would be needed.


Currently, it is `static const int veml3328_scale_vals[4][8]` and
accessed like:

	/* Stride by 2 through the flattened array to match (val, val2) */
	*val = veml3328_scale_vals[it_inx][gain_inx * 2];
	*val2 = veml3328_scale_vals[it_inx][gain_inx * 2 + 1];

Normally, we would do that like:

	*val = veml3328_scale_vals[it_inx][gain_inx][0];
	*val2 = veml3328_scale_vals[it_inx][gain_inx][1];



  reply	other threads:[~2026-07-27 13:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 11:27 Giorgi Tchankvetadze
2026-07-27 13:15 ` David Lechner [this message]
2026-07-27 13:50   ` Giorgi Tchankvetadze
2026-07-28 21:38     ` Jonathan Cameron
2026-07-27 15:28   ` Joshua Crofts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90018da7-8d84-4bfd-b2e1-f832ca03f764@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=andy@kernel.org \
    --cc=giorgi@tchankvetadze.com \
    --cc=giorgitchankvetadze1997@gmail.com \
    --cc=jic23@kernel.org \
    --cc=joshua.crofts1@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®