All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Georgi Djakov <georgi.djakov@linaro.org>
Cc: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org,
	robh+dt@kernel.org, rjw@rjwysocki.net, saravanak@google.com,
	sibis@codeaurora.org, rnayak@codeaurora.org,
	bjorn.andersson@linaro.org, vincent.guittot@linaro.org,
	jcrouse@codeaurora.org, evgreen@chromium.org,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 3/7] interconnect: Add of_icc_get_by_index() helper function
Date: Fri, 24 Apr 2020 11:02:31 -0700	[thread overview]
Message-ID: <20200424180231.GN199755@google.com> (raw)
In-Reply-To: <20200424155404.10746-4-georgi.djakov@linaro.org>

Hi,

On Fri, Apr 24, 2020 at 06:54:00PM +0300, Georgi Djakov wrote:
> This is the same as the traditional of_icc_get() function, but the
> difference is that it takes index as an argument, instead of name.
> 
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
> ---
> v7:
> * Addressed review comments from Sibi.
> * Re-based patch.
> 
> v2: https://lore.kernel.org/r/20190423132823.7915-3-georgi.djakov@linaro.org
> 
>  drivers/interconnect/core.c  | 68 +++++++++++++++++++++++++++---------
>  include/linux/interconnect.h |  6 ++++
>  2 files changed, 58 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
> index 2c6515e3ecf1..648237f4de49 100644
> --- a/drivers/interconnect/core.c
> +++ b/drivers/interconnect/core.c
> @@ -351,9 +351,9 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
>  }
>  
>  /**
> - * of_icc_get() - get a path handle from a DT node based on name
> + * of_icc_get_by_index() - get a path handle from a DT node based on index
>   * @dev: device pointer for the consumer device
> - * @name: interconnect path name
> + * @idx: interconnect path index
>   *
>   * This function will search for a path between two endpoints and return an
>   * icc_path handle on success. Use icc_put() to release constraints when they
> @@ -365,13 +365,12 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
>   * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
>   * when the API is disabled or the "interconnects" DT property is missing.
>   */
> -struct icc_path *of_icc_get(struct device *dev, const char *name)
> +struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
>  {
>  	struct icc_path *path = ERR_PTR(-EPROBE_DEFER);

nit: initialization is not needed. According to the diff this is existing
code, but since we are adding a new function we can as well 'fix' it :)

>  	struct icc_node *src_node, *dst_node;
>  	struct device_node *np = NULL;

ditto

>  	struct of_phandle_args src_args, dst_args;
> -	int idx = 0;
>  	int ret;
>  
>  	if (!dev || !dev->of_node)
> @@ -391,12 +390,6 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
>  	 * lets support only global ids and extend this in the future if needed
>  	 * without breaking DT compatibility.
>  	 */
> -	if (name) {
> -		idx = of_property_match_string(np, "interconnect-names", name);
> -		if (idx < 0)
> -			return ERR_PTR(idx);
> -	}
> -
>  	ret = of_parse_phandle_with_args(np, "interconnects",
>  					 "#interconnect-cells", idx * 2,
>  					 &src_args);
> @@ -439,12 +432,8 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
>  		return path;
>  	}
>  
> -	if (name)
> -		path->name = kstrdup_const(name, GFP_KERNEL);
> -	else
> -		path->name = kasprintf(GFP_KERNEL, "%s-%s",
> -				       src_node->name, dst_node->name);
> -
> +	path->name = kasprintf(GFP_KERNEL, "%s-%s",
> +			       src_node->name, dst_node->name);
>  	if (!path->name) {
>  		kfree(path);
>  		return ERR_PTR(-ENOMEM);
> @@ -452,6 +441,53 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
>  
>  	return path;
>  }
> +EXPORT_SYMBOL_GPL(of_icc_get_by_index);
> +
> +/**
> + * of_icc_get() - get a path handle from a DT node based on name
> + * @dev: device pointer for the consumer device
> + * @name: interconnect path name
> + *
> + * This function will search for a path between two endpoints and return an
> + * icc_path handle on success. Use icc_put() to release constraints when they
> + * are not needed anymore.
> + * If the interconnect API is disabled, NULL is returned and the consumer
> + * drivers will still build. Drivers are free to handle this specifically,
> + * but they don't have to.
> + *
> + * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
> + * when the API is disabled or the "interconnects" DT property is missing.
> + */
> +struct icc_path *of_icc_get(struct device *dev, const char *name)
> +{
> +	struct device_node *np = NULL;

nit: initialization is not needed

> +	int idx = 0;
> +
> +	if (!dev || !dev->of_node)
> +		return ERR_PTR(-ENODEV);
> +
> +	np = dev->of_node;
> +
> +	/*
> +	 * When the consumer DT node do not have "interconnects" property
> +	 * return a NULL path to skip setting constraints.
> +	 */
> +	if (!of_find_property(np, "interconnects", NULL))
> +		return NULL;
> +
> +	/*
> +	 * We use a combination of phandle and specifier for endpoint. For now
> +	 * lets support only global ids and extend this in the future if needed
> +	 * without breaking DT compatibility.
> +	 */
> +	if (name) {
> +		idx = of_property_match_string(np, "interconnect-names", name);
> +		if (idx < 0)
> +			return ERR_PTR(idx);
> +	}
> +
> +	return of_icc_get_by_index(dev, idx);
> +}
>  EXPORT_SYMBOL_GPL(of_icc_get);
>  
>  /**
> diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
> index d70a914cba11..34e97231a6ab 100644
> --- a/include/linux/interconnect.h
> +++ b/include/linux/interconnect.h
> @@ -28,6 +28,7 @@ struct device;
>  struct icc_path *icc_get(struct device *dev, const int src_id,
>  			 const int dst_id);
>  struct icc_path *of_icc_get(struct device *dev, const char *name);
> +struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
>  void icc_put(struct icc_path *path);
>  int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
>  void icc_set_tag(struct icc_path *path, u32 tag);
> @@ -46,6 +47,11 @@ static inline struct icc_path *of_icc_get(struct device *dev,
>  	return NULL;
>  }
>  
> +static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
> +{
> +	return NULL;
> +}
> +
>  static inline void icc_put(struct icc_path *path)
>  {
>  }

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

  reply	other threads:[~2020-04-24 18:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 15:53 [PATCH v7 0/7] Introduce OPP bandwidth bindings Georgi Djakov
2020-04-24 15:53 ` [PATCH v7 1/7] dt-bindings: opp: Introduce opp-peak-kBps and opp-avg-kBps bindings Georgi Djakov
2020-04-30  5:09   ` Viresh Kumar
2020-05-04 20:31   ` Sibi Sankar
2020-05-11 21:51   ` Rob Herring
2020-04-24 15:53 ` [PATCH v7 2/7] OPP: Add helpers for reading the binding properties Georgi Djakov
2020-04-24 17:30   ` Matthias Kaehlcke
2020-04-30  5:21     ` Viresh Kumar
2020-05-04 20:40   ` Sibi Sankar
2020-04-24 15:54 ` [PATCH v7 3/7] interconnect: Add of_icc_get_by_index() helper function Georgi Djakov
2020-04-24 18:02   ` Matthias Kaehlcke [this message]
2020-05-04 20:58   ` Sibi Sankar
2020-04-24 15:54 ` [PATCH v7 4/7] OPP: Add support for parsing interconnect bandwidth Georgi Djakov
2020-04-24 19:20   ` Matthias Kaehlcke
2020-04-28 16:21     ` Georgi Djakov
2020-04-30  5:28     ` Viresh Kumar
2020-05-04 21:03   ` Sibi Sankar
2020-04-24 15:54 ` [PATCH v7 5/7] OPP: Add sanity checks in _read_opp_key() Georgi Djakov
2020-04-24 19:26   ` Matthias Kaehlcke
2020-05-04 20:47   ` Sibi Sankar
2020-04-24 15:54 ` [PATCH v7 6/7] OPP: Update the bandwidth on OPP frequency changes Georgi Djakov
2020-04-24 19:36   ` Matthias Kaehlcke
2020-04-24 21:18   ` Saravana Kannan
2020-04-30  6:09     ` Viresh Kumar
2020-04-30  7:35       ` Saravana Kannan
2020-04-30  7:53         ` Viresh Kumar
2020-04-30 16:32           ` Saravana Kannan
2020-05-04  5:00             ` Viresh Kumar
2020-05-04 21:01               ` Saravana Kannan
2020-05-05  3:38                 ` Viresh Kumar
2020-05-04 20:54   ` Sibi Sankar
2020-04-24 15:54 ` [PATCH v7 7/7] cpufreq: dt: Add support for interconnect bandwidth scaling Georgi Djakov
2020-04-24 19:41   ` Matthias Kaehlcke
2020-05-04 20:50   ` Sibi Sankar

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=20200424180231.GN199755@google.com \
    --to=mka@chromium.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=evgreen@chromium.org \
    --cc=georgi.djakov@linaro.org \
    --cc=jcrouse@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=saravanak@google.com \
    --cc=sboyd@kernel.org \
    --cc=sibis@codeaurora.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vireshk@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.