Re: [PATCH v3] nvmem: core: Default to read-only if wp-gpios present

From: Bartosz Golaszewski

Date: Tue Apr 28 2026 - 04:09:02 EST


On Mon, 27 Apr 2026 17:19:29 +0200, Marek Vasut <marex@xxxxxxxxxxxx> said:
> In case the nvmem DT node contains "wp-gpios" DT property, the device
> currently defaults to read-write and the force_ro sysfs attribute reads
> 0. Switch to the default read-only, which is both safer, and aligned
> with eMMC HW BOOT partition force_ro sysfs attribute behavior, which
> also defaults to read-only.
>
> The adjustment of nvmem->read_only value to read-only in case wp-gpios
> DT property is present must be done only after the device_add() got
> called because device_add() does internally call nvmem_bin_attr_get_umode(),
> which configures the permissions of 'nvmem' bin attr based on the value
> of nvmem->read_only that is only parsed from DT property 'read-only',
> without any adjustment. This way, if DT property 'read-only' is present,
> the 'nvmem' attribute is always read-only. Otherwise, if the device is
> writeable, then 'nvmem' attribute is writeable, and nvmem->read_only
> defaults to read-only, but can be switched to read-write at runtime via
> the 'force_ro' attribute.

This slightly changes the behavior for user-space but I'm willing to give it
a go and see if anyone complains.

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>

Bart