linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>, linux-kernel@vger.kernel.org
Cc: maxime.ripard@free-electrons.com
Subject: Re: [RESEND RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()'
Date: Wed, 2 Mar 2016 13:58:26 +0000	[thread overview]
Message-ID: <56D6F182.6070301@linaro.org> (raw)
In-Reply-To: <1456851552-15913-2-git-send-email-andrew.smirnov@gmail.com>

Sorry for so late review comments,


On 01/03/16 16:59, Andrey Smirnov wrote:
> Add 'of_nvmem_cell_from_device_node()' -- a function that allows to
> obtain 'struct nvmem_cell' from a device tree node representing it. One
> use-case for such a function would be to access nvmem cells with known
> phandles.

Totally missing the purpose of this new API, Why is of_nvmem_cell_get() 
not useful, its exactly doing same thing.

Unless you randomly want to handle phandles without proper dt bindings.

Thanks
srini

>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>   drivers/nvmem/core.c           | 44 +++++++++++++++++++++++++++++-------------
>   include/linux/nvmem-consumer.h |  7 +++++++
>   2 files changed, 38 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 6fd4e5a..08550dd 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -601,29 +601,21 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
>
>   #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
>   /**
> - * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
> + * of_nvmem_cell_from_device_node() - Get a nvmem cell from device node representation
>    *
> - * @dev node: Device tree node that uses the nvmem cell
> - * @id: nvmem cell name from nvmem-cell-names property.
> + * @np node: Device tree node representing NVMEM cell
>    *
>    * Return: Will be an ERR_PTR() on error or a valid pointer
>    * to a struct nvmem_cell.  The nvmem_cell will be freed by the
>    * nvmem_cell_put().
>    */
> -struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
> -					    const char *name)
> +struct nvmem_cell *of_nvmem_cell_from_device_node(struct device_node *cell_np)
>   {
> -	struct device_node *cell_np, *nvmem_np;
> +	struct device_node *nvmem_np;
>   	struct nvmem_cell *cell;
>   	struct nvmem_device *nvmem;
>   	const __be32 *addr;
> -	int rval, len, index;
> -
> -	index = of_property_match_string(np, "nvmem-cell-names", name);
> -
> -	cell_np = of_parse_phandle(np, "nvmem-cells", index);
> -	if (!cell_np)
> -		return ERR_PTR(-EINVAL);
> +	int rval, len;
>
>   	nvmem_np = of_get_next_parent(cell_np);
>   	if (!nvmem_np)
> @@ -682,6 +674,32 @@ err_mem:
>
>   	return ERR_PTR(rval);
>   }
> +EXPORT_SYMBOL_GPL(of_nvmem_cell_from_device_node);
> +
> +/**
> + * of_nvmem_cell_get() - Get a nvmem cell from given device node referencing it and cell id
> + *
> + * @dev node: Device tree node that uses the nvmem cell
> + * @id: nvmem cell name from nvmem-cell-names property.
> + *
> + * Return: Will be an ERR_PTR() on error or a valid pointer
> + * to a struct nvmem_cell.  The nvmem_cell will be freed by the
> + * nvmem_cell_put().
> + */
> +struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
> +					    const char *name)
> +{
> +	struct device_node *cell_np;
> +	int index;
> +
> +	index = of_property_match_string(np, "nvmem-cell-names", name);
> +
> +	cell_np = of_parse_phandle(np, "nvmem-cells", index);
> +	if (!cell_np)
> +		return ERR_PTR(-EINVAL);
> +
> +	return of_nvmem_cell_from_device_node(cell_np);
> +}
>   EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
>   #endif
>
> diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
> index 9bb77d3..ff0abb0 100644
> --- a/include/linux/nvmem-consumer.h
> +++ b/include/linux/nvmem-consumer.h
> @@ -136,11 +136,18 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
>   #endif /* CONFIG_NVMEM */
>
>   #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
> +struct nvmem_cell *of_nvmem_cell_from_device_node(struct device_node *np);
>   struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
>   				     const char *name);
>   struct nvmem_device *of_nvmem_device_get(struct device_node *np,
>   					 const char *name);
>   #else
> +
> +static inline struct nvmem_cell *
> +of_nvmem_cell_from_device_node(struct device_node *np)
> +{
> +	return ERR_PTR(-ENOSYS);
> +}
>   static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
>   				     const char *name)
>   {
>

  reply	other threads:[~2016-03-02 13:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 16:59 [RESEND RFC 0/3] Proposed extensions for NVMEM Andrey Smirnov
2016-03-01 16:59 ` [RESEND RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()' Andrey Smirnov
2016-03-02 13:58   ` Srinivas Kandagatla [this message]
2016-03-02 18:11     ` Andrey Smirnov
2016-03-01 16:59 ` [RESEND RFC 2/3] nvmem: Add 'nvmem-blob' driver Andrey Smirnov
2016-03-02 13:58   ` Srinivas Kandagatla
2016-03-02 17:21     ` Andrey Smirnov
2016-03-07  8:18       ` Maxime Ripard
2016-03-08  4:07         ` Andrey Smirnov
2016-03-08 22:28           ` Maxime Ripard
2016-03-08 22:46             ` Andrey Smirnov
2016-03-08 23:24               ` Trent Piepho
2016-03-09 10:13                 ` Maxime Ripard
2016-03-09 19:50                   ` Trent Piepho
2016-03-09  9:58               ` Maxime Ripard
2016-03-09 17:04                 ` Andrey Smirnov
2016-03-09  7:59             ` Sascha Hauer
2016-03-01 16:59 ` [RESEND RFC 3/3] nvmem: Add 'nvmem-composite' driver Andrey Smirnov
2016-03-02 13:59   ` Srinivas Kandagatla
2016-03-02 18:33     ` Andrey Smirnov
2016-03-17 11:26       ` Srinivas Kandagatla
2016-03-21 16:12         ` Andrey Smirnov
2016-03-21 16:56           ` Srinivas Kandagatla

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=56D6F182.6070301@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=andrew.smirnov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    /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).