[PATCH] thermal: armada: Use bitfield and bitmask macros
Guilherme Ivo Bozi
guilherme.bozi em usp.br
Qua Jun 17 20:40:15 -03 2026
Hi Bryan,
On 17/06/2026 12:44, Bryan B. Lima wrote:
> Replace manual bitfield manipulations with FIELD_MODIFY(). Define
> constants with BIT() and GENMASK().
>
> Also, remove offset and shift constants for standard use of bitfield.
>
> Signed-off-by: Bryan B. Lima <bblima em usp.br>
> Co-developed-by: Gustavo S. Correa <gustavoscorrea em usp.br>
> Signed-off-by: Gustavo S. Correa <gustavoscorrea em usp.br>
The second paragraph of the commit message could be clearer.
> @@ -238,14 +227,15 @@ static void armada_ap80x_init(struct platform_device *pdev,
> u32 reg;
>
> regmap_read(priv->syscon, data->syscon_control0_off, ®);
> - reg &= ~CONTROL0_TSEN_RESET;
> - reg |= CONTROL0_TSEN_START | CONTROL0_TSEN_ENABLE;
> + FIELD_MODIFY(CONTROL0_TSEN_RESET, ®, 0);
> + FIELD_MODIFY(CONTROL0_TSEN_START, ®, 1);
> + FIELD_MODIFY(CONTROL0_TSEN_ENABLE, ®, 1);
>
> /* Sample every ~2ms */
> - reg |= CONTROL0_TSEN_OSR_MAX << CONTROL0_TSEN_OSR_SHIFT;
> + FIELD_MODIFY(CONTROL0_TSEN_OSR_MASK, ®, 1);
>
This changes the OSR field value from CONTROL0_TSEN_OSR_MAX (3) to 1. If
this is only a conversion from manual bitfield manipulation to
FIELD_MODIFY(), shouldn't this be:
FIELD_MODIFY(CONTROL0_TSEN_OSR_MASK, ®, CONTROL0_TSEN_OSR_MAX);
> /* Enable average (2 samples by default) */
> - reg &= ~CONTROL0_TSEN_AVG_BYPASS;
> + FIELD_MODIFY(CONTROL0_TSEN_AVG_BYPASS, ®, 0);
>
> regmap_write(priv->syscon, data->syscon_control0_off, reg);
> }
> @@ -260,13 +250,12 @@ static void armada_cp110_init(struct platform_device *pdev,
>
> /* Sample every ~2ms */
> regmap_read(priv->syscon, data->syscon_control0_off, ®);
> - reg |= CONTROL0_TSEN_OSR_MAX << CONTROL0_TSEN_OSR_SHIFT;
> + FIELD_MODIFY(CONTROL0_TSEN_OSR_MASK, ®, 1);
Same issue as above.
> regmap_write(priv->syscon, data->syscon_control0_off, reg);
>
> /* Average the output value over 2^1 = 2 samples */
> regmap_read(priv->syscon, data->syscon_control1_off, ®);
> - reg &= ~CONTROL1_TSEN_AVG_MASK;
> - reg |= 1;
> + FIELD_MODIFY(CONTROL1_TSEN_AVG_MASK, ®, 1);
> regmap_write(priv->syscon, data->syscon_control1_off, reg);
> }
>
Kind regards,
Guilherme Ivo
Mais detalhes sobre a lista de discussão kernel