Re: [PATCH 2/2] staging: iio: adt7316: convert magic numbers to BIT() and GENMASK()

From: David Laight

Date: Wed Feb 04 2026 - 05:32:49 EST


On Sat, 31 Jan 2026 16:21:40 +0000
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> On Fri, 30 Jan 2026 23:38:28 -0800
> Michael Harris <michaelharriscode@xxxxxxxxx> wrote:
..
> > - return sysfs_emit(buf, "0x%x\n",
> > + return sysfs_emit(buf, "0x%lx\n",
> > chip->dac_config & ADT7316_DA_2VREF_CH_MASK);
> Is the compiler complaining about these? It really should be able to tell that the masks
> are small enough that the original can always print the right thing.

That will be because BIT() and GENMASK() generate 'unsigned long' values.
Sort of silly when they are used for hardware registers that are fixed width.
You can use BIT_U32() and GENMASK_U32() instead - they will be
'unsigned int'.

David