Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp17836ybz; Fri, 24 Apr 2020 11:05:28 -0700 (PDT) X-Google-Smtp-Source: APiQypLUPq30LN9tWJqMEcTY8ifVVXfdP/FFU/PCKFliYXC2HHILOr+ii/GYNk7bXSV5XVKIWrpc X-Received: by 2002:aa7:cd01:: with SMTP id b1mr8613837edw.163.1587751528356; Fri, 24 Apr 2020 11:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587751528; cv=none; d=google.com; s=arc-20160816; b=jg+qN00kS5InuGzi3bKt3TGeXcA0cqoQXtroLOsa0u2yZMs3b3YA3BhPZyo1XtWK5j UkGyoiPgNKlqEezX2Z/GKy1byQjf1asxJqHQjz4AuagHPgUvowquvoh8vwIbZ7+5nnIT EnivZnOZFMa8c5mQlNO7JtS9uqmB3pic7f0nnNsLbb2bhhn3IFvoQ0YiwuO+FuQwO7Y+ JQNLrHY9lPGvopRiMe9TOMaN+s+uwB2vmkbJuzbmOPTGxLQ7Ay21KbsjVL1oRyGwnU6F WnPAxVWNxm/EhwVzj63oaB1IlrPE0t+5oFk4Zr+4X75+YdCpQlBBSqA+dY3mM5KDd01n onrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pOk/kzhlhPwNaetCm8gHWGwhQXlpl0JHUkFF0oAV7cs=; b=FvmH8ZIBST61gP+a6em78C2sXA9WubaQDRAFUB33XzGat7L5tGhgApebiR0R/y/YCK ZafSWOHC39qV/J/+3v0mmNgxjTtqFhDHMsMSsMb8fZucL+nkjiZKQK7NVlvFRB8KEbmj nRkfgd9I43ypIxCQsc3mOkljcHu602R8xDMGm0ifxIpszssixYoCqD7s9Ipa17Vbcy5r ouOxVFEmF9kvbUDizR8UojoBVzKYHdSGTFb7Pud+gwZ8tyUsc72Rp0zKqyERR2GPHa/U FoCNxBM+YLph9UGnQ5HIgGCp7f18KRvn9+YaG7M2w7AcgvUY44AVwv3oKFO9DoqqBNdF qX6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Fnz1wUCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b21si3599760edj.146.2020.04.24.11.05.04; Fri, 24 Apr 2020 11:05:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Fnz1wUCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgDXSCe (ORCPT + 99 others); Fri, 24 Apr 2020 14:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726908AbgDXSCd (ORCPT ); Fri, 24 Apr 2020 14:02:33 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD20BC09B048 for ; Fri, 24 Apr 2020 11:02:33 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t9so4179386pjw.0 for ; Fri, 24 Apr 2020 11:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pOk/kzhlhPwNaetCm8gHWGwhQXlpl0JHUkFF0oAV7cs=; b=Fnz1wUCcpiV9Sbd1YePKv3AoJZbAFcFu1weCKyJf/l35GLl+RBs2PnSoBgMsTXAbpN hSkWcBmxyu1B3ASUzbyGpxWEYa9ByJRR0sL+EH0O7kGCxr9A9Pz/8cy6RBWvF9FPasIb nyxWc4sgKXi4zzCu32UhYeVxmxIDJ535rbkn0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pOk/kzhlhPwNaetCm8gHWGwhQXlpl0JHUkFF0oAV7cs=; b=FZ7UigV5ybgMXeKajllAJo6o1oSmIRQCyQo+Suvpd/xfaJ6rhAycAX184onEZF3v9h Ypqx5DRlgmTHvHVHfsW55RVI7vA7XmOm/HOroR279TAjLWa9BM/cL5pfd0QnguBmp0t/ t1ouoKm98gkcMVTMgogxIEEXRfBH/kPTqutJdxkl/b+E3H0m8LYMat4aZxcYw/XqIGJF JYYOqe4OiTClw3ZhCtx9yZ+9SNoVlx/k2KxGFUPz99r9ZqfSvyrRs1EpUQHqooH+YQhA 8o6y4ypgpPIlePQnR/75EEFUH1GP8gQLb6hxUkqeZNn05vb3u2Pl6a5GFxDQZ9CfUucx oEXQ== X-Gm-Message-State: AGi0Pubo9zmAvE6A7QrOel3/3/9vuEdx78/4L9upgdUdLcUKPORdvKW0 zvU513FTfCp5kOrPXSHLdDeEfg== X-Received: by 2002:a17:90b:297:: with SMTP id az23mr7357140pjb.85.1587751353096; Fri, 24 Apr 2020 11:02:33 -0700 (PDT) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id w30sm6418630pfj.25.2020.04.24.11.02.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2020 11:02:32 -0700 (PDT) Date: Fri, 24 Apr 2020 11:02:31 -0700 From: Matthias Kaehlcke To: Georgi Djakov 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 Message-ID: <20200424180231.GN199755@google.com> References: <20200424155404.10746-1-georgi.djakov@linaro.org> <20200424155404.10746-4-georgi.djakov@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200424155404.10746-4-georgi.djakov@linaro.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > 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