Re: [PATCH 47/49] regmap-irq: Add get_irq_reg() callback

From: Andy Shevchenko
Date: Tue Jun 21 2022 - 05:51:58 EST


On Mon, Jun 20, 2022 at 10:12 PM Aidan MacDonald
<aidanmacdonald.0x0@xxxxxxxxx> wrote:
>
> Replace the internal sub_irq_reg() function with a public callback
> that drivers can use when they have more complex register layouts.
> The default implementation is regmap_irq_get_irq_reg_linear(), used
> if the chip doesn't provide its own callback.

...

> + /*
> + * While possible that a user-defined get_irq_reg callback might be

->get_irq_reg()

> + * linear enough to support bulk reads, most of the time it won't.
> + * Therefore only allow them if the default callback is being used.
> + */
> return !map->use_single_read && map->reg_stride == 1 &&
> - data->irq_reg_stride == 1;
> + data->irq_reg_stride == 1 &&
> + data->get_irq_reg == regmap_irq_get_irq_reg_linear;

If initially this had been as

return _reg_stride && irq_reg_stride &&
!map->use_single_read;

you would have done less changes by squeezing a new condition just in
between the other two. It will preserve the grouping of the checks as
well.

> }

...

> + /*
> + * Note we can't use get_irq_reg() here because the offsets

->get_irq_reg()

> + * in 'subreg' are *not* interchangeable with indices.
> + */

...

> + /*
> + * For not_fixed_stride, don't use get_irq_reg().

Ditto.

> + * It would produce an incorrect result.
> + */

...

> + reg = chip->main_status +
> + (i * map->reg_stride *
> + data->irq_reg_stride);

Parentheses are not necessary. And perhaps the last two can be put on
a single line.

...

> + /*
> + * NOTE: This is for backward compatibility only and will be removed

FIXME ?

> + * when not_fixed_stride is dropped (it's only used by qcom-pm8008).
> + */

--
With Best Regards,
Andy Shevchenko