From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>, Sekhar Nori <nsekhar@ti.com>,
Kevin Hilman <khilman@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Grygorii Strashko <grygorii.strashko@ti.com>,
"David S . Miller" <davem@davemloft.net>,
Lukas Wunner <lukas@wunner.de>, Rob Herring <robh@kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>,
David Lechner <david@lechnology.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Lunn <andrew@lunn.ch>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
netdev@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH v2 01/15] nvmem: add support for cell lookups
Date: Tue, 26 Jun 2018 12:06:19 +0100 [thread overview]
Message-ID: <25ebceca-8cdd-edae-6393-dd29eb323c53@linaro.org> (raw)
In-Reply-To: <20180626102245.30711-2-brgl@bgdev.pl>
Thanks for the patch,
On 26/06/18 11:22, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> We can currently only register nvmem cells from device tree or by
> manually calling nvmem_add_cells(). The latter options however forces
> users to make sure that the nvmem provider with which the cells are
> associated is registered before the call.
>
> This patch proposes a new solution inspired by other frameworks that
> offer resource lookups (GPIO, PWM etc.). It adds a function that allows
> machine code to register nvmem lookup which are later lazily used to
> add corresponding nvmem cells.
>
Overall the idea look fine to me.
This needs to be documented in ./Documentation/nvmem/nvmem.txt
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
> drivers/nvmem/core.c | 57 +++++++++++++++++++++++++++++++++-
> include/linux/nvmem-consumer.h | 6 ++++
> include/linux/nvmem-provider.h | 6 ++++
> 3 files changed, 68 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index b5b0cdc21d01..a2e87b464319 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -62,6 +62,9 @@ static DEFINE_IDA(nvmem_ida);
> static LIST_HEAD(nvmem_cells);
> static DEFINE_MUTEX(nvmem_cells_mutex);
>
> +static LIST_HEAD(nvmem_cell_lookups);
> +static DEFINE_MUTEX(nvmem_lookup_mutex);
> +
> #ifdef CONFIG_DEBUG_LOCK_ALLOC
> static struct lock_class_key eeprom_lock_key;
> #endif
> @@ -247,6 +250,23 @@ static const struct attribute_group *nvmem_ro_root_dev_groups[] = {
> NULL,
> };
>
> +/**
> + * nvmem_register_lookup() - register a number of nvmem cell lookup entries
> + *
Can we rename this to nvmem_add_lookup_table()?
register sound bit heavy here.
We should also have something like nvmem_remove_lookup_table() for
consistency, and it should ensure that it clears the cells entry too.
> + * @lookup: array of nvmem cell lookup entries
> + * @nentries: number of lookup entries in the array
> + */
> +void nvmem_register_lookup(struct nvmem_cell_lookup *lookup, size_t nentries)
> +{
> + int i;
> + > + mutex_lock(&nvmem_lookup_mutex);
> + for (i = 0; i < nentries; i++)
> + list_add_tail(&lookup[i].list, &nvmem_cell_lookups);
> + mutex_unlock(&nvmem_lookup_mutex);
> +}
> +EXPORT_SYMBOL_GPL(nvmem_register_lookup);
> +
> static void nvmem_release(struct device *dev)
> {
> struct nvmem_device *nvmem = to_nvmem_device(dev);
> @@ -916,6 +936,37 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
> EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
> #endif
>
next prev parent reply other threads:[~2018-06-26 11:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 10:22 [PATCH v2 00/15] ARM: davinci: step towards removing at24_platform_data Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 01/15] nvmem: add support for cell lookups Bartosz Golaszewski
2018-06-26 11:06 ` Srinivas Kandagatla [this message]
2018-06-28 7:56 ` Bartosz Golaszewski
2018-06-28 9:33 ` Srinivas Kandagatla
2018-06-26 10:22 ` [PATCH v2 02/15] ARM: davinci: dm365-evm: use nvmem lookup for mac address Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 03/15] ARM: davinci: dm644-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 04/15] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 05/15] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 06/15] ARM: davinci: mityomapl138: add nvmem cells lookup entries Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 07/15] net: davinci_emac: use nvmem to retrieve the mac address Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 08/15] ARM: davinci: mityomapl138: don't read the MAC address from machine code Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 09/15] ARM: davinci: dm365-evm: use device properties for at24 eeprom Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 10/15] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 11/15] ARM: davinci: dm644x-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 12/15] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 13/15] ARM: davinci: sffsdr: fix the at24 eeprom device name Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 14/15] ARM: davinci: sffsdr: use device properties for at24 eeprom Bartosz Golaszewski
2018-06-26 10:22 ` [PATCH v2 15/15] ARM: davinci: remove dead code Bartosz Golaszewski
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=25ebceca-8cdd-edae-6393-dd29eb323c53@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=andrew@lunn.ch \
--cc=bgolaszewski@baylibre.com \
--cc=brgl@bgdev.pl \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=david@lechnology.com \
--cc=f.fainelli@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=grygorii.strashko@ti.com \
--cc=ivan.khoronzhuk@linaro.org \
--cc=khilman@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lukas@wunner.de \
--cc=netdev@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=robh@kernel.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;
as well as URLs for NNTP newsgroup(s).