* [PATCH] iio: light: veml3328: remove redundant cast in read_avail
@ 2026-07-27 11:27 Giorgi Tchankvetadze
2026-07-27 13:15 ` David Lechner
0 siblings, 1 reply; 4+ messages in thread
From: Giorgi Tchankvetadze @ 2026-07-27 11:27 UTC (permalink / raw)
To: joshua.crofts1, jic23
Cc: dlechner, nuno.sa, andy, linux-iio, linux-kernel,
Giorgi Tchankvetadze
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;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: light: veml3328: remove redundant cast in read_avail
2026-07-27 11:27 [PATCH] iio: light: veml3328: remove redundant cast in read_avail Giorgi Tchankvetadze
@ 2026-07-27 13:15 ` David Lechner
2026-07-27 13:50 ` Giorgi Tchankvetadze
2026-07-27 15:28 ` Joshua Crofts
0 siblings, 2 replies; 4+ messages in thread
From: David Lechner @ 2026-07-27 13:15 UTC (permalink / raw)
To: Giorgi Tchankvetadze, joshua.crofts1, jic23
Cc: nuno.sa, andy, linux-iio, linux-kernel, Giorgi Tchankvetadze
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];
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: light: veml3328: remove redundant cast in read_avail
2026-07-27 13:15 ` David Lechner
@ 2026-07-27 13:50 ` Giorgi Tchankvetadze
2026-07-27 15:28 ` Joshua Crofts
1 sibling, 0 replies; 4+ messages in thread
From: Giorgi Tchankvetadze @ 2026-07-27 13:50 UTC (permalink / raw)
To: David Lechner
Cc: joshua.crofts1, jic23, nuno.sa, andy, linux-iio, linux-kernel,
Giorgi Tchankvetadze
On Mon, Jul 27, 2026 at 5:16 PM David Lechner <dlechner@baylibre.com> wrote:
>
> Usually, we would declare the array like:
>
> static const int veml3328_scale_vals[4][4][2] ...
>
> in which case this cast would be needed.
>
>
I intentionally kept the patch tiny and dealt with the obvious thing,
but yes, I agree this is how it should be done.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: light: veml3328: remove redundant cast in read_avail
2026-07-27 13:15 ` David Lechner
2026-07-27 13:50 ` Giorgi Tchankvetadze
@ 2026-07-27 15:28 ` Joshua Crofts
1 sibling, 0 replies; 4+ messages in thread
From: Joshua Crofts @ 2026-07-27 15:28 UTC (permalink / raw)
To: David Lechner
Cc: Giorgi Tchankvetadze, jic23, nuno.sa, andy, linux-iio,
linux-kernel, Giorgi Tchankvetadze
On Mon, 27 Jul 2026 08:15:59 -0500
David Lechner <dlechner@baylibre.com> wrote:
> 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.
>
I don't really see a reason to do this... but up to Giorgi
to send a new patch or stick with the cast removal, I'm
indifferent.
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-27 15:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 11:27 [PATCH] iio: light: veml3328: remove redundant cast in read_avail Giorgi Tchankvetadze
2026-07-27 13:15 ` David Lechner
2026-07-27 13:50 ` Giorgi Tchankvetadze
2026-07-27 15:28 ` Joshua Crofts
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.