From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Marek Vasut <marex@denx.de>
Cc: linux-i2c@vger.kernel.org,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] nvmem: core: Implement force_ro sysfs attribute
Date: Sat, 22 Jun 2024 08:49:08 +0200 [thread overview]
Message-ID: <2024062234-congested-partly-0cf1@gregkh> (raw)
In-Reply-To: <20240621160309.97843-1-marex@denx.de>
On Fri, Jun 21, 2024 at 06:02:14PM +0200, Marek Vasut wrote:
> Implement "force_ro" sysfs attribute to allow users to set read-write
> devices as read-only and back to read-write from userspace. The choice
> of the name is based on MMC core 'force_ro' attribute.
>
> This solves a situation where an AT24 I2C EEPROM with GPIO based nWP
> signal may have to be occasionally updated. Such I2C EEPROM device is
> usually set as read-only during most of the regular system operation,
> but in case it has to be updated in a controlled manner, it could be
> unlocked using this new "force_ro" sysfs attribute and then re-locked
> again.
>
> The "read-only" DT property and config->read_only configuration is
> respected and is used to set default state of the device, read-only
> or read-write, for devices which do implement .reg_write function.
> For devices which do not implement .reg_write function, the device
> is unconditionally read-only and the "force_ro" attribute is not
> visible.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Cc: Bartosz Golaszewski <brgl@bgdev.pl>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-i2c@vger.kernel.org
> ---
> drivers/nvmem/core.c | 44 +++++++++++++++++++++++++++++++++++++++
> drivers/nvmem/internals.h | 1 +
> 2 files changed, 45 insertions(+)
No Documentation/ABI/ update for the new sysfs file?
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index e1ec3b7200d7b..d263871b66dca 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -184,7 +184,30 @@ static ssize_t type_show(struct device *dev,
>
> static DEVICE_ATTR_RO(type);
>
> +static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + struct nvmem_device *nvmem = to_nvmem_device(dev);
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", nvmem->read_only);
sysfs_emit() please.
thanks,
greg k-h
prev parent reply other threads:[~2024-06-22 6:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 16:02 [PATCH] nvmem: core: Implement force_ro sysfs attribute Marek Vasut
2024-06-22 6:49 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024062234-congested-partly-0cf1@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=linux-i2c@vger.kernel.org \
--cc=marex@denx.de \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox