Re: [PATCH] iio: light: veml3328: remove redundant cast in read_avail

Joshua Crofts <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, 27 Jul 2026 08:15:59 -0500
David Lechner <[email protected]> wrote:

> On 7/27/26 6:27 AM, Giorgi Tchankvetadze wrote:
> > From: Giorgi Tchankvetadze <[email protected]>
> > 
> > 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 <[email protected]>
> > ---
> >  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.