Re: [PATCH v2 09/16] nvmem: microchip-otpc: Avoid reading a write-only register

Claudiu Beznea
2025-02-17T09:10:55Z

On 10.02.2025 18:50, Alexander Dahl wrote:
> The OTPC Control Register (OTPC_CR) has just write-only members.
> Reading from that register leads to a warning in OTPC Write Protection
> Status Register (OTPC_WPSR) in field Software Error Type (SWETYP) of
> type READ_WO (A write-only register has been read (warning).)
>
> Just create the register write content from scratch is sufficient here.
>
> Signed-off-by: Alexander Dahl <ada@thorsis.com>
> Fixes: 98830350d3fc ("nvmem: microchip-otpc: add support")

Fixes tag goes above your SoB.

> ---
>
> Notes:
> v2:
> - Add Fixes tag
> - Remove temporary variable usage
> - Reword misleading subject (s/writing/reading/)
>
> drivers/nvmem/microchip-otpc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/nvmem/microchip-otpc.c b/drivers/nvmem/microchip-otpc.c
> index df979e8549fdb..e2851c63cc0b4 100644
> --- a/drivers/nvmem/microchip-otpc.c
> +++ b/drivers/nvmem/microchip-otpc.c
> @@ -82,9 +82,7 @@ static int mchp_otpc_prepare_read(struct mchp_otpc *otpc,
> writel_relaxed(tmp, otpc->base + MCHP_OTPC_MR);
>
> /* Set read. */
> - tmp = readl_relaxed(otpc->base + MCHP_OTPC_CR);
> - tmp |= MCHP_OTPC_CR_READ;
> - writel_relaxed(tmp, otpc->base + MCHP_OTPC_CR);
> + writel_relaxed(MCHP_OTPC_CR_READ, otpc->base + MCHP_OTPC_CR);
>
> /* Wait for packet to be transferred into temporary buffers. */
> return read_poll_timeout(readl_relaxed, tmp, !(tmp & MCHP_OTPC_SR_READ),