From: Kyle Tso <kyletso@google.com>
To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org
Cc: badhri@google.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, Kyle Tso <kyletso@google.com>,
stable@vger.kernel.org
Subject: [PATCH v2 1/3] usb: typec: Set port->pd before adding device for typec_port
Date: Fri, 23 Jun 2023 23:10:34 +0800 [thread overview]
Message-ID: <20230623151036.3955013-2-kyletso@google.com> (raw)
In-Reply-To: <20230623151036.3955013-1-kyletso@google.com>
When calling device_add in the registration of typec_port, it will do
the NULL check on usb_power_delivery handle in typec_port for the
visibility of the device attributes. It is always NULL because port->pd
is set in typec_port_set_usb_power_delivery which is later than the
device_add call.
Set port->pd before device_add and only link the device after that.
Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
Cc: stable@vger.kernel.org
Signed-off-by: Kyle Tso <kyletso@google.com>
---
update v2:
- Add "Cc: stable@vger.kernel.org"
drivers/usb/typec/class.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index faa184ae3dac..3b30948bf4b0 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -2288,6 +2288,8 @@ struct typec_port *typec_register_port(struct device *parent,
return ERR_PTR(ret);
}
+ port->pd = cap->pd;
+
ret = device_add(&port->dev);
if (ret) {
dev_err(parent, "failed to register port (%d)\n", ret);
@@ -2295,7 +2297,7 @@ struct typec_port *typec_register_port(struct device *parent,
return ERR_PTR(ret);
}
- ret = typec_port_set_usb_power_delivery(port, cap->pd);
+ ret = usb_power_delivery_link_device(port->pd, &port->dev);
if (ret) {
dev_err(&port->dev, "failed to link pd\n");
device_unregister(&port->dev);
--
2.41.0.162.gfafddb0af9-goog
next prev parent reply other threads:[~2023-06-23 15:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 15:10 [PATCH v2 0/3] Some fixes for select_usb_power_delivery Kyle Tso
2023-06-23 15:10 ` Kyle Tso [this message]
2023-06-30 12:39 ` [PATCH v2 1/3] usb: typec: Set port->pd before adding device for typec_port Heikki Krogerus
2023-06-23 15:10 ` [PATCH v2 2/3] usb: typec: Iterate pds array when showing the pd list Kyle Tso
2023-06-30 12:41 ` Heikki Krogerus
2023-06-23 15:10 ` [PATCH v2 3/3] usb: typec: Use sysfs_emit_at when concatenating the string Kyle Tso
2023-06-30 12:42 ` Heikki Krogerus
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=20230623151036.3955013-2-kyletso@google.com \
--to=kyletso@google.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.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