Re: [RFC PATCH v2 1/2] regmap: add regmap_reg_field_* APIs
From: Andy Shevchenko
Date: Fri Nov 13 2026 - 09:54:24 EST
On Fri, Nov 13, 2026 at 9:05 AM Victor Chernyakin
<chernyakin.victor.j@xxxxxxxxxxx> wrote:
>
> These functions are equivalent to their regmap_field_* counterparts,
> but allow working with reg_field directly, without having to
> allocate and manage regmap_fields.
...
> -#define REG_FIELD(_reg, _lsb, _msb) { \
> - .reg = _reg, \
> - .lsb = _lsb, \
> - .msb = _msb, \
> - }
> +#define REG_FIELD(_reg, _lsb, _msb) ((struct reg_field){ \
> + .reg = _reg, \
> + .lsb = _lsb, \
> + .msb = _msb, \
> + })
>
> -#define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) { \
> - .reg = _reg, \
> - .lsb = _lsb, \
> - .msb = _msb, \
> - .id_size = _size, \
> - .id_offset = _offset, \
> - }
> +#define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) ((struct reg_field){ \
> + .reg = _reg, \
> + .lsb = _lsb, \
> + .msb = _msb, \
> + .id_size = _size, \
> + .id_offset = _offset, \
> + })
So, you convert them to compound literals. This change may be good on
its own (see other similar changes in the kernel).
The only problem you have is the outer parentheses. They should be
dropped. If you need them, it's a problem on the user's side of this
macros.
--
With Best Regards,
Andy Shevchenko