linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: djakov@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
	festevam@gmail.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, abel.vesa@nxp.com,
	abailon@baylibre.com, l.stach@pengutronix.de,
	laurent.pinchart@ideasonboard.com, marex@denx.de,
	paul.elder@ideasonboard.com, Markus.Niebel@ew.tq-group.com,
	aford173@gmail.com
Cc: kernel@pengutronix.de, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-imx@nxp.com,
	abelvesa@kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH V2 3/9] interconnect: add device managed bulk API
Date: Thu, 16 Jun 2022 15:33:14 +0800	[thread overview]
Message-ID: <20220616073320.2203000-4-peng.fan@oss.nxp.com> (raw)
In-Reply-To: <20220616073320.2203000-1-peng.fan@oss.nxp.com>

From: Peng Fan <peng.fan@nxp.com>

Add device managed bulk API to simplify driver.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/interconnect/bulk.c  | 42 ++++++++++++++++++++++++++++++++++++
 include/linux/interconnect.h |  7 ++++++
 2 files changed, 49 insertions(+)

diff --git a/drivers/interconnect/bulk.c b/drivers/interconnect/bulk.c
index 448cc536aa79..8b1d8a412464 100644
--- a/drivers/interconnect/bulk.c
+++ b/drivers/interconnect/bulk.c
@@ -115,3 +115,45 @@ void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
 		icc_disable(paths[num_paths].path);
 }
 EXPORT_SYMBOL_GPL(icc_bulk_disable);
+
+struct icc_bulk_devres {
+	struct icc_bulk_data *paths;
+	int num_paths;
+};
+
+static void devm_icc_bulk_release(struct device *dev, void *res)
+{
+	struct icc_bulk_devres *devres = res;
+
+	icc_bulk_put(devres->num_paths, devres->paths);
+}
+
+/**
+ * devm_of_icc_bulk_get() - resource managed of_icc_bulk_get
+ * @dev: the device requesting the path
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the table with the paths we want to get
+ *
+ * Returns 0 on success or negative errno otherwise.
+ */
+int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths)
+{
+	struct icc_bulk_devres *devres;
+	int ret;
+
+	devres = devres_alloc(devm_icc_bulk_release, sizeof(*devres), GFP_KERNEL);
+	if (!devres)
+		return -ENOMEM;
+
+	ret = of_icc_bulk_get(dev, num_paths, paths);
+	if (!ret) {
+		devres->paths = paths;
+		devres->num_paths = num_paths;
+		devres_add(dev, devres);
+	} else {
+		devres_free(devres);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(devm_of_icc_bulk_get);
diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h
index f685777b875e..2b0e784ba771 100644
--- a/include/linux/interconnect.h
+++ b/include/linux/interconnect.h
@@ -44,6 +44,7 @@ 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 *devm_of_icc_get(struct device *dev, const char *name);
+int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths);
 struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
 void icc_put(struct icc_path *path);
 int icc_enable(struct icc_path *path);
@@ -116,6 +117,12 @@ static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_
 	return 0;
 }
 
+static inline int devm_of_icc_bulk_get(struct device *dev, int num_paths,
+				       struct icc_bulk_data *paths)
+{
+	return 0;
+}
+
 static inline void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
 {
 }
-- 
2.25.1


  parent reply	other threads:[~2022-06-16  7:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16  7:33 [PATCH V2 0/9] interconnect: support i.MX8MP Peng Fan (OSS)
2022-06-16  7:33 ` [PATCH V2 1/9] dt-bindings: interconnect: imx8m: Add bindings for imx8mp noc Peng Fan (OSS)
2022-06-27 22:18   ` Rob Herring
2022-06-16  7:33 ` [PATCH V2 2/9] dt-bindings: interconnect: add fsl,imx8mp.h Peng Fan (OSS)
2022-06-27 22:19   ` Rob Herring
2022-06-16  7:33 ` Peng Fan (OSS) [this message]
2022-06-16  7:33 ` [PATCH V2 4/9] interconnect: imx: fix max_node_id Peng Fan (OSS)
2022-06-16  7:33 ` [PATCH V2 5/9] interconnect: imx: set src node Peng Fan (OSS)
2022-06-16  7:33 ` [PATCH V2 6/9] interconnect: imx: introduce imx_icc_provider Peng Fan (OSS)
2022-06-16  7:33 ` [PATCH V2 7/9] interconnect: imx: set of_node for interconnect provider Peng Fan (OSS)
2022-06-29 15:08   ` Lucas Stach
2022-06-29 17:32     ` Laurent Pinchart
2022-07-03  8:43       ` Peng Fan (OSS)
2022-07-02 12:48     ` Peng Fan
2022-06-16  7:33 ` [PATCH V2 8/9] interconnect: imx: configure NoC mode/prioriry/ext_control Peng Fan (OSS)
2022-06-28 17:57   ` Georgi Djakov
2022-07-02 12:41     ` Peng Fan
2022-06-29 15:14   ` Lucas Stach
2022-07-02 12:50     ` Peng Fan
2022-06-16  7:33 ` [PATCH V2 9/9] interconnect: imx: Add platform driver for imx8mp Peng Fan (OSS)
2022-06-28 17:58   ` Georgi Djakov
2022-06-29 15:17   ` Lucas Stach
2022-07-02 12:51     ` Peng Fan

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=20220616073320.2203000-4-peng.fan@oss.nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=Markus.Niebel@ew.tq-group.com \
    --cc=abailon@baylibre.com \
    --cc=abel.vesa@nxp.com \
    --cc=abelvesa@kernel.org \
    --cc=aford173@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djakov@kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=l.stach@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=paul.elder@ideasonboard.com \
    --cc=peng.fan@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@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).