From: Yong Wu <yong.wu@mediatek.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
<dri-devel@lists.freedesktop.org>
Cc: James Wang <james.qian.wang@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
<iommu@lists.linux-foundation.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
<linux-kernel@vger.kernel.org>, "Joerg Roedel" <joro@8bytes.org>,
Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
<linux-mediatek@lists.infradead.org>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
"Stephen Boyd" <sboyd@kernel.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Hsin-Yi Wang <hsinyi@chromium.org>,
Robin Murphy <robin.murphy@arm.com>,
Tomasz Figa <tfiga@chromium.org>, <srv_heupstream@mediatek.com>,
Rob Clark <robdclark@gmail.com>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Sebastian Reichel <sre@kernel.org>,
Yong Wu <yong.wu@mediatek.com>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 01/23] component: Add common helper for compare/release functions
Date: Mon, 14 Feb 2022 14:07:57 +0800 [thread overview]
Message-ID: <20220214060819.7334-2-yong.wu@mediatek.com> (raw)
In-Reply-To: <20220214060819.7334-1-yong.wu@mediatek.com>
The component requires the compare/release functions, there are so many
copies in current kernel. Just define four common helpers for them.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
I have run "make htmldocs". Due to my poor english, If the grammer is
wrong or need more comments, please help to correct or supplement.
Thanks.
---
drivers/base/component.c | 58 +++++++++++++++++++++++++++++++++++++++
include/linux/component.h | 6 ++++
2 files changed, 64 insertions(+)
diff --git a/drivers/base/component.c b/drivers/base/component.c
index 2d25a6416587..3d72d2820d7d 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -11,6 +11,7 @@
#include <linux/device.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
@@ -287,6 +288,63 @@ static void take_down_master(struct master *master)
}
}
+/**
+ * component_compare_of - A common component compare function for of_node
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is device of_node. e.g.
+ * component_match_add_release(masterdev, &match, component_release_of,
+ * component_compare_of, component_dev_of_node)
+ */
+int component_compare_of(struct device *dev, void *data)
+{
+ return device_match_of_node(dev, data);
+}
+EXPORT_SYMBOL_GPL(component_compare_of);
+
+/**
+ * component_release_of - A common component release function for of_node
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * About the example, Please see component_compare_of().
+ */
+void component_release_of(struct device *dev, void *data)
+{
+ of_node_put(data);
+}
+EXPORT_SYMBOL_GPL(component_release_of);
+
+/**
+ * component_compare_dev - A common component compare function for dev
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is struce device. e.g.
+ * component_match_add(masterdev, &match, component_compare_dev, component_dev)
+ */
+int component_compare_dev(struct device *dev, void *data)
+{
+ return dev == data;
+}
+EXPORT_SYMBOL_GPL(component_compare_dev);
+
+/**
+ * component_compare_dev_name - A common component compare function for device name
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is device name string. e.g.
+ * component_match_add(masterdev, &match, component_compare_dev_name,
+ * "component_dev_name")
+ */
+int component_compare_dev_name(struct device *dev, void *data)
+{
+ return device_match_name(dev, data);
+}
+EXPORT_SYMBOL_GPL(component_compare_dev_name);
+
static void devm_component_match_release(struct device *parent, void *res)
{
struct component_match *match = res;
diff --git a/include/linux/component.h b/include/linux/component.h
index 16de18f473d7..6bc1c6e7f76d 100644
--- a/include/linux/component.h
+++ b/include/linux/component.h
@@ -82,6 +82,12 @@ struct component_master_ops {
void (*unbind)(struct device *master);
};
+/* A set helper functions for component compare/release */
+int component_compare_of(struct device *dev, void *data);
+void component_release_of(struct device *dev, void *data);
+int component_compare_dev(struct device *dev, void *data);
+int component_compare_dev_name(struct device *dev, void *data);
+
void component_master_del(struct device *,
const struct component_master_ops *);
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-14 6:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 6:07 [PATCH 00/23] component: Add common helpers for compare/release Yong Wu
2022-02-14 6:07 ` Yong Wu [this message]
2022-02-14 6:07 ` [PATCH 02/23] drm/komeda: Make use of the helper component_compare_of Yong Wu
2022-02-14 6:07 ` [PATCH 03/23] drm/armada: Make use of the helper component_compare_of/dev_name Yong Wu
2022-02-14 6:08 ` [PATCH 04/23] drm/etnaviv: " Yong Wu
2022-02-14 6:08 ` [PATCH 05/23] drm/hirin: Make use of the helper component_compare_of Yong Wu
2022-02-14 6:08 ` [PATCH 06/23] drm/ingenic: " Yong Wu
2022-02-14 10:03 ` Paul Cercueil
2022-02-14 6:08 ` [PATCH 07/23] drm/mediatek: " Yong Wu
2022-02-14 6:08 ` [PATCH 08/23] drm/meson: " Yong Wu
2022-02-14 6:08 ` [PATCH 09/23] drm/msm: " Yong Wu
2022-02-14 6:08 ` [PATCH 10/23] drm/sprd: " Yong Wu
2022-02-14 6:08 ` [PATCH 11/23] drm/sti: " Yong Wu
2022-02-14 6:08 ` [PATCH 12/23] drm/sun4i: " Yong Wu
2022-02-14 6:08 ` [PATCH 13/23] drm/rockchip: Make use of the helper component_compare_dev Yong Wu
2022-02-14 8:03 ` Heiko Stübner
2022-02-14 6:08 ` [PATCH 14/23] drm/exynos: " Yong Wu
2022-02-14 6:08 ` [PATCH 15/23] drm/mcde: " Yong Wu
2022-02-14 6:08 ` [PATCH 16/23] drm/omap: dss: " Yong Wu
2022-02-14 6:08 ` [PATCH 17/23] drm/vc4: " Yong Wu
2022-02-14 6:08 ` [PATCH 18/23] drm: of: Make use of the helper component_release_of Yong Wu
2022-02-14 6:08 ` [PATCH 19/23] iommu/mediatek: Make use of the helper component_compare/release_of Yong Wu
2022-02-14 6:08 ` [PATCH 20/23] ASoC: codecs: wcd938x: " Yong Wu
2022-02-14 12:40 ` Mark Brown
2022-02-14 12:43 ` AngeloGioacchino Del Regno
2022-02-15 2:27 ` Yong Wu
2022-02-14 6:08 ` [PATCH 21/23] power: supply: ab8500: Make use of the helper component_compare_dev Yong Wu
2022-02-14 6:08 ` [PATCH 22/23] video: omapfb: dss: " Yong Wu
2022-02-15 20:46 ` Helge Deller
2022-02-25 11:07 ` Greg Kroah-Hartman
2022-02-14 6:08 ` [PATCH 23/23] ALSA: hda/realtek: Make use of the helper component_compare_dev_name Yong Wu
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=20220214060819.7334-2-yong.wu@mediatek.com \
--to=yong.wu@mediatek.com \
--cc=airlied@linux.ie \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arnd@arndb.de \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=hsinyi@chromium.org \
--cc=iommu@lists.linux-foundation.org \
--cc=james.qian.wang@arm.com \
--cc=joro@8bytes.org \
--cc=krzysztof.kozlowski@canonical.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=liviu.dudau@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=rafael@kernel.org \
--cc=robdclark@gmail.com \
--cc=robin.murphy@arm.com \
--cc=sboyd@kernel.org \
--cc=sre@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=srv_heupstream@mediatek.com \
--cc=tfiga@chromium.org \
--cc=will@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).