From patchwork Tue Apr 23 13:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 162696 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3790142jan; Tue, 23 Apr 2019 06:28:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWxmlVmN3wmKlgnq28R9sC4AWt95ZRimB0vp6JZZ+JINXh+nHPH/CW23i8pT2pgMqAl/j5 X-Received: by 2002:a17:902:8c8b:: with SMTP id t11mr26532562plo.15.1556026116025; Tue, 23 Apr 2019 06:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556026116; cv=none; d=google.com; s=arc-20160816; b=lRhx6K+k0BUJHpE19+IyrPARa4P371z2BMribDCW1Mnm1pekuKG/IjfjMy0QHLRdUD VyrzffBGIAzByipWM0ooqvjdtawZF4aygeYQcSBFqe0x1F5Dkk279tZ/Z09yiwkIWShb 3niMnCzqMpgjcOHLQHiBCO+XLKdDmQXDvYvJv9PfGjZh01QimO0gBnD4LEOlg0C6BYRv Hro+958Bp6nP83Lqfw6y4fGAq4c1SAxHfkzkCk44kQU7nTwcMcFyJmaWrQFslfCFy0eO t6Q7akgDO5hfX5mTF94jPOVnwYvboYE8F3O5745VZqlhMlDYpIxQ6KGlkM7L5tODG6f6 y8dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TmzrLG0HhMUllGPErHueXstJu/wyUlmgrIkCuicVsiY=; b=v7dHP+EPwFe9U9jwOwfPSsOpd8CAr9MRzyDO+RkTEPEYZmYcH7fTcRI+A3POQdQ2t1 F0Vehyu00OClE8fIPPaSSQkCT43rk/ZM5pcII2TCGlr5tRlNaFt4zMrcF44fuyuzkkK+ oV2G6fu0W1QS9cFuODx6THGBpW8RYLBjxsrJV+9aKL86jpC7FEwqKkUa65PS/JhqgTuS Ey913Cf8vDv3DeVI+ZxPzczbV4/HoLVJPsL7akdj6SyOIBkMpK5OUJy/L2WpBoNxbV+b VQQV4Az0hBY2k4ajEocuu1UX0VmypEP+pCEzquVHcX2KOO2Ju/33rwu/0QY29JJLzJh0 PjoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjyiAvWp; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b98si13403900plb.375.2019.04.23.06.28.35; Tue, 23 Apr 2019 06:28:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjyiAvWp; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727955AbfDWN2f (ORCPT + 7 others); Tue, 23 Apr 2019 09:28:35 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41123 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbfDWN2d (ORCPT ); Tue, 23 Apr 2019 09:28:33 -0400 Received: by mail-lj1-f196.google.com with SMTP id k8so979091lja.8 for ; Tue, 23 Apr 2019 06:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TmzrLG0HhMUllGPErHueXstJu/wyUlmgrIkCuicVsiY=; b=pjyiAvWpRnfInL1U8vVm5G28PPwIa7vHVRINhbLFwD7Hh8RLqG1XBvcg6uhiz5Q7I/ oDN/v1CW3tmWtHRBfdLsTUhN3j1Ez8EdsbehRXTSLKgBkdXvWs6FxQ/neadA2MdMxyCv /T86u/ZwKidHvmiwKNAiXKqlT6ADVxSxocN6dT4P477jUUBupKtT35G3+nr8vkHzgvWd +6GveAO2cO7rhe58ZHp0+Kgisl4ilC3MIdSjLoHz7+E1PvM3J4aYUIFnfv5nb5ygA7N5 5dlcgCZuU9fe0qw3ewVCgh0ZKTnuzxJOcl7hkfXbZa6WVywG4g0j32gsnzFs0ERahaVm My7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TmzrLG0HhMUllGPErHueXstJu/wyUlmgrIkCuicVsiY=; b=WKAX9uLLRLaAQc0eYxqbaXjeM42KUAcmlojvPf6oWjw0oqc+hDtkLpO+crs6oyqL5U cg7tpViocxyCJw8K+mivHVbzeZAm24sBwzBDIl1bofY2IXq+XCtzgTEijfMbT66mPBiQ ZGbEUDGNx8iMNWHL54tqHZrfLMSsntvEB+Chk8DQ9Uws6K4uPA1QU8KGY0gYUR93F3lG +Wvi1CEOmQBVpIwYXb+x7e7KkfpT829gks0HnKggCGuNya8rLBWMcVGjOvTodrQ1Bl/R SyskxCfPktULbWn1coz6G+1O0kBUumZJMhnGVFAHtgxAGjMhjOH/u7OS0KL81qcRLETH ZY7w== X-Gm-Message-State: APjAAAWP8Z12tH5hD1ebX+MWYV2egRhKddCdVbif7JFkcAikeZRxH+Fb pZkg0Wxdoe5KD4epGY+ZKsazLQ== X-Received: by 2002:a2e:500d:: with SMTP id e13mr13748245ljb.169.1556026110607; Tue, 23 Apr 2019 06:28:30 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:29 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 2/5] interconnect: Add of_icc_get_by_index() helper function Date: Tue, 23 Apr 2019 16:28:20 +0300 Message-Id: <20190423132823.7915-3-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- drivers/interconnect/core.c | 45 ++++++++++++++++++++++++++++-------- include/linux/interconnect.h | 6 +++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 871eb4bc4efc..a7c3c262c974 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -295,9 +295,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 @@ -309,13 +309,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); struct icc_node *src_node, *dst_node; struct device_node *np = NULL; struct of_phandle_args src_args, dst_args; - int idx = 0; int ret; if (!dev || !dev->of_node) @@ -335,12 +334,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); @@ -383,6 +376,38 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } + +/** + * 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) +{ + int idx = 0; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + if (name) { + idx = of_property_match_string(dev->of_node, + "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 dc25864755ba..0e430b3b6519 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); @@ -45,6 +46,11 @@ static inline struct icc_path *of_icc_get(struct device *dev, return NULL; } +struct icc_path *of_icc_get_by_index(struct device *dev, int idx) +{ + return NULL; +} + static inline void icc_put(struct icc_path *path) { }