From: Andy Yan <andy.yan@rock-chips.com> To: daniel@ffwll.ch Cc: airlied@linux.ie, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Andy Yan <andy.yan@rock-chips.com> Subject: [PATCH v2] drm/connector: Add of_drm_find_connector Date: Fri, 3 Jul 2020 17:45:06 +0800 [thread overview] Message-ID: <20200703094506.22527-1-andy.yan@rock-chips.com> (raw) Add a function to look up a connector by device tree node, like what of_drm_find_bridge/panel does. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Reported-by: kernel test robot <lkp@intel.com> --- Changes in v2: - Add function declaration drivers/gpu/drm/drm_connector.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 14 ++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index d877ddc6dc57..516376cd1868 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -743,6 +743,39 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter) } EXPORT_SYMBOL(drm_connector_list_iter_end); +#ifdef CONFIG_OF +/** + * of_drm_find_connector - look up a connector using a device tree node + * @np: device tree node of the connector + * + * + * Return: A pointer to the connector which match the specified device tree + * node or NULL if no panel matching the device tree node can be found, or + * -ENODEV: the device is not available (status != "okay" or "ok") + */ +struct drm_connector *of_drm_find_connector(struct drm_device *dev, const struct device_node *np) +{ + struct drm_connector *connector; + struct drm_connector_list_iter conn_iter; + + if (!of_device_is_available(np)) + return ERR_PTR(-ENODEV); + + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + if (connector->of_node == np) { + drm_connector_list_iter_end(&conn_iter); + return connector; + } + } + drm_connector_list_iter_end(&conn_iter); + + return NULL; +} +EXPORT_SYMBOL(of_drm_find_connector); +#endif + + static const struct drm_prop_enum_list drm_subpixel_enum_list[] = { { SubPixelUnknown, "Unknown" }, { SubPixelHorizontalRGB, "Horizontal RGB" }, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fd543d1db9b2..d249e0498375 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1129,6 +1129,9 @@ struct drm_connector { /** @attr: sysfs attributes */ struct device_attribute *attr; + /** @of_node: device tree node */ + struct device_node *of_node; + /** * @head: * @@ -1647,6 +1650,17 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); bool drm_connector_has_possible_encoder(struct drm_connector *connector, struct drm_encoder *encoder); +#if defined(CONFIG_OF) +struct drm_connector * +of_drm_find_connector(struct drm_device *dev, const struct device_node *np); +#else +static inline struct drm_connector * +of_drm_find_connector(struct drm_device *dev, const struct device_node *np) +{ + return ERR_PTR(-ENODEV); +} +#endif + /** * drm_for_each_connector_iter - connector_list iterator macro * @connector: &struct drm_connector pointer used as cursor -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Andy Yan <andy.yan@rock-chips.com> To: daniel@ffwll.ch Cc: airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, tzimmermann@suse.de, Andy Yan <andy.yan@rock-chips.com> Subject: [PATCH v2] drm/connector: Add of_drm_find_connector Date: Fri, 3 Jul 2020 17:45:06 +0800 [thread overview] Message-ID: <20200703094506.22527-1-andy.yan@rock-chips.com> (raw) Add a function to look up a connector by device tree node, like what of_drm_find_bridge/panel does. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Reported-by: kernel test robot <lkp@intel.com> --- Changes in v2: - Add function declaration drivers/gpu/drm/drm_connector.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 14 ++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index d877ddc6dc57..516376cd1868 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -743,6 +743,39 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter) } EXPORT_SYMBOL(drm_connector_list_iter_end); +#ifdef CONFIG_OF +/** + * of_drm_find_connector - look up a connector using a device tree node + * @np: device tree node of the connector + * + * + * Return: A pointer to the connector which match the specified device tree + * node or NULL if no panel matching the device tree node can be found, or + * -ENODEV: the device is not available (status != "okay" or "ok") + */ +struct drm_connector *of_drm_find_connector(struct drm_device *dev, const struct device_node *np) +{ + struct drm_connector *connector; + struct drm_connector_list_iter conn_iter; + + if (!of_device_is_available(np)) + return ERR_PTR(-ENODEV); + + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector, &conn_iter) { + if (connector->of_node == np) { + drm_connector_list_iter_end(&conn_iter); + return connector; + } + } + drm_connector_list_iter_end(&conn_iter); + + return NULL; +} +EXPORT_SYMBOL(of_drm_find_connector); +#endif + + static const struct drm_prop_enum_list drm_subpixel_enum_list[] = { { SubPixelUnknown, "Unknown" }, { SubPixelHorizontalRGB, "Horizontal RGB" }, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fd543d1db9b2..d249e0498375 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1129,6 +1129,9 @@ struct drm_connector { /** @attr: sysfs attributes */ struct device_attribute *attr; + /** @of_node: device tree node */ + struct device_node *of_node; + /** * @head: * @@ -1647,6 +1650,17 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); bool drm_connector_has_possible_encoder(struct drm_connector *connector, struct drm_encoder *encoder); +#if defined(CONFIG_OF) +struct drm_connector * +of_drm_find_connector(struct drm_device *dev, const struct device_node *np); +#else +static inline struct drm_connector * +of_drm_find_connector(struct drm_device *dev, const struct device_node *np) +{ + return ERR_PTR(-ENODEV); +} +#endif + /** * drm_for_each_connector_iter - connector_list iterator macro * @connector: &struct drm_connector pointer used as cursor -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2020-07-03 9:45 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-03 9:45 Andy Yan [this message] 2020-07-03 9:45 ` [PATCH v2] drm/connector: Add of_drm_find_connector Andy Yan 2020-07-31 2:33 ` Andy Yan 2020-07-31 2:33 ` Andy Yan 2020-07-31 6:17 ` Daniel Vetter 2020-07-31 6:17 ` Daniel Vetter
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=20200703094506.22527-1-andy.yan@rock-chips.com \ --to=andy.yan@rock-chips.com \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maarten.lankhorst@linux.intel.com \ --cc=mripard@kernel.org \ --cc=tzimmermann@suse.de \ /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: linkBe 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.