From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Guenter Roeck <linux@roeck-us.net>, Janne Grunau <j@jannau.net>,
Simon Ser <contact@emersion.fr>, Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
freedreno@lists.freedesktop.org
Subject: Re: [RFC PATCH v1 12/12] usb: typec: qcom: define the bridge's path
Date: Fri, 15 Sep 2023 15:14:35 +0300 [thread overview]
Message-ID: <ZQRKq7K8jKlH/Y4X@kuha.fi.intel.com> (raw)
In-Reply-To: <20230903214150.2877023-13-dmitry.baryshkov@linaro.org>
Hi Dmitry,
On Mon, Sep 04, 2023 at 12:41:50AM +0300, Dmitry Baryshkov wrote:
> In order to notify the userspace about the DRM connector's USB-C port,
> export the corresponding port's name as the bridge's path field.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 11 +++++++----
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_drm.c | 4 +++-
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_drm.h | 6 ++++--
> 3 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> index b9d4856101c7..452dc6437861 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> @@ -156,6 +156,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
> struct device_node *np = dev->of_node;
> const struct pmic_typec_resources *res;
> struct regmap *regmap;
> + char *tcpm_name;
> u32 base[2];
> int ret;
>
> @@ -211,10 +212,6 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
> mutex_init(&tcpm->lock);
> platform_set_drvdata(pdev, tcpm);
>
> - tcpm->pmic_typec_drm = qcom_pmic_typec_init_drm(dev);
> - if (IS_ERR(tcpm->pmic_typec_drm))
> - return PTR_ERR(tcpm->pmic_typec_drm);
> -
> tcpm->tcpc.fwnode = device_get_named_child_node(tcpm->dev, "connector");
> if (!tcpm->tcpc.fwnode)
> return -EINVAL;
> @@ -225,6 +222,12 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
> goto fwnode_remove;
> }
>
> + tcpm_name = tcpm_port_get_name(tcpm->tcpm_port);
> + tcpm->pmic_typec_drm = qcom_pmic_typec_init_drm(dev, tcpm_name);
So I got some questions and concerns off-list. This was one of the
concerns. That tcpm_name is now the actual port device name, so I'm
afraid this is not acceptable.
You can't use device name as a reference, ever. There is no way to
guarantee that a device with a specific name is what you meant it to
be by the time it's accessed.
If you need to deal with a device, then you have to get an actual
reference to it (class_find_device_by_fwnode() should work in this
case).
Ideally you would get the reference in the place where you actually
use it (so drm_connector.c or more likely drm_sysfs.c) but that would
mean a dependency on typec in there, if the component framework or
something like that (device links?) is not an option. You could of
course try to confine the dependency somehow. drm_class does not have
implementation for dev_uevent, so you could take over that as a
temporary solution.
The only way to avoid the dependency completely would be to pass that
device reference from here through your drm bridge chain somehow.
But that's also really fragile. But it could be acceptable as a
temporary solution perhaps, if it's even possible.
Br,
--
heikki
next prev parent reply other threads:[~2023-09-15 12:15 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-03 21:41 [RFC PATCH v1 00/12] drm,usb/typec: uABI for USB-C DisplayPort connectors Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 01/12] Revert "drm/sysfs: Link DRM connectors to corresponding Type-C connectors" Dmitry Baryshkov
2023-09-05 8:49 ` Heikki Krogerus
2023-09-05 10:56 ` Dmitry Baryshkov
2023-09-06 12:44 ` Heikki Krogerus
2023-09-06 12:48 ` Dmitry Baryshkov
2023-09-06 12:53 ` Laurent Pinchart
2023-09-06 14:32 ` Maxime Ripard
2023-09-06 13:38 ` Heikki Krogerus
2023-09-11 21:15 ` Dmitry Baryshkov
2023-09-12 11:05 ` Heikki Krogerus
2023-09-12 17:39 ` Dmitry Baryshkov
2023-09-13 9:27 ` Heikki Krogerus
2023-09-13 10:26 ` Dmitry Baryshkov
2023-09-13 13:14 ` Heikki Krogerus
2023-09-13 13:47 ` Dmitry Baryshkov
2023-09-14 9:26 ` Heikki Krogerus
2023-09-14 9:35 ` Neil Armstrong
2023-09-14 10:16 ` Dmitry Baryshkov
2023-09-14 10:40 ` Dmitry Baryshkov
2023-09-14 14:55 ` Heikki Krogerus
2023-09-13 9:38 ` Neil Armstrong
2023-09-13 10:34 ` Heikki Krogerus
2023-09-13 3:00 ` [Freedreno] " Rob Clark
2023-09-03 21:41 ` [RFC PATCH v1 02/12] drm/sysfs: link DRM connector device to the connector's fw nodes Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 03/12] drm/connector: extend PATH property to covert Type-C case Dmitry Baryshkov
2023-10-03 9:15 ` Simon Ser
2023-09-03 21:41 ` [RFC PATCH v1 04/12] drm/bridge-connector: set the PATH property for the connector Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 05/12] drm/bridge: remove conditionals around devicetree pointers Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 06/12] soc: qcom: pmic_glink_altmode: fix DRM connector type Dmitry Baryshkov
2023-09-04 15:42 ` Bjorn Andersson
2023-09-03 21:41 ` [RFC PATCH v1 07/12] soc: qcom: pmic_glink_altmode: report that this is a Type-C connector Dmitry Baryshkov
2023-09-04 15:43 ` Bjorn Andersson
2023-09-04 15:45 ` Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 08/12] usb: typec: support generating Type-C port names for userspace Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 09/12] usb: typec: tcpm: " Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 10/12] usb: typec: qcom: implement proper error path in probe() Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 11/12] usb: typec: qcom: extract DRM bridge functionality to separate file Dmitry Baryshkov
2023-09-03 21:41 ` [RFC PATCH v1 12/12] usb: typec: qcom: define the bridge's path Dmitry Baryshkov
2023-09-15 12:14 ` Heikki Krogerus [this message]
2023-10-23 18:24 ` Dmitry Baryshkov
2023-10-30 8:19 ` Heikki Krogerus
2023-10-30 9:47 ` Dmitry Baryshkov
2023-10-30 10:13 ` Simon Ser
2023-10-30 10:22 ` Dmitry Baryshkov
2023-10-30 10:26 ` Simon Ser
2023-10-30 12:12 ` Dmitry Baryshkov
2023-09-04 15:46 ` [RFC PATCH v1 00/12] drm,usb/typec: uABI for USB-C DisplayPort connectors Bjorn Andersson
2023-09-04 15:49 ` Dmitry Baryshkov
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=ZQRKq7K8jKlH/Y4X@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=agross@kernel.org \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=andrzej.hajda@intel.com \
--cc=bryan.odonoghue@linaro.org \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=j@jannau.net \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@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: 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
all inboxes | Powered by JetHome®