From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Kyle Tso <kyletso@google.com>
Cc: linux@roeck-us.net, gregkh@linuxfoundation.org,
hdegoede@redhat.com, robh+dt@kernel.org, badhri@google.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v5 1/8] usb: typec: Manage SVDM version
Date: Wed, 3 Feb 2021 15:34:08 +0200 [thread overview]
Message-ID: <20210203133408.GF1687065@kuha.fi.intel.com> (raw)
In-Reply-To: <20210203124724.GD1687065@kuha.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
Hi Kyle,
On Wed, Feb 03, 2021 at 02:47:28PM +0200, Heikki Krogerus wrote:
> You need to document those exported functions! You need to do that in
> any case, but in this case it's very important, because the purpose of
> these functions is not clear from the ctx.
>
> I'm sorry for noticing that so late. Since you do need to fix that,
> please see if you can also store that detail in the partner device
> object instead of the port object.
I'm attaching here my (quite crude) proposal how to do this. It should
give you an idea what I'm after here.
Br,
--
heikki
[-- Attachment #2: svdm_version_proposal.diff --]
[-- Type: text/plain, Size: 2407 bytes --]
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 8f77669f9cf4f..04238b0a5d47f 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -36,6 +36,8 @@ struct typec_partner {
enum typec_accessory accessory;
struct ida mode_ids;
int num_altmodes;
+
+ enum usb_pd_svdm_ver svdm_version;
};
struct typec_port {
@@ -792,6 +794,18 @@ typec_partner_register_altmode(struct typec_partner *partner,
}
EXPORT_SYMBOL_GPL(typec_partner_register_altmode);
+/**
+ * typec_partner_set_svdm_version - Set negotiated SVDM version
+ * @partner: The partner.
+ * ...
+ */
+void typec_partner_set_svdm_version(struct typec_partner *partner,
+ enum usb_pd_svdm_ver svdm_version)
+{
+ partner->svdm_version = svdm_version;
+}
+EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version);
+
/**
* typec_register_partner - Register a USB Type-C Partner
* @port: The USB Type-C Port the partner is connected to
@@ -1847,6 +1861,27 @@ EXPORT_SYMBOL_GPL(typec_set_mode);
/* --------------------------------------- */
+/**
+ * typec_get_negotiated_svdm_version - Get negotiated SVDM version
+ * @port: The port.
+ * ...
+ */
+int typec_get_negotiated_svdm_version(struct typec_port *port)
+{
+ enum usb_pd_svdm_ver svdm_version;
+ struct device *partner_dev;
+
+ partner_dev = device_find_child(&port->dev, NULL, partner_match);
+ if (!partner_dev)
+ return -ENODEV;
+
+ svdm_version = to_typec_partner(partner_dev)->svdm_version;
+ put_device(partner_dev);
+
+ return svdm_version
+}
+EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version);
+
/**
* typec_get_drvdata - Return private driver data pointer
* @port: USB Type-C port
diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
index 5e0a7b7647c3b..91e119e37ba70 100644
--- a/include/linux/usb/typec_altmode.h
+++ b/include/linux/usb/typec_altmode.h
@@ -132,6 +132,16 @@ typec_altmode_get_orientation(struct typec_altmode *altmode)
return typec_get_orientation(typec_altmode2port(altmode));
}
+/**
+ * typec_get_negotiated_svdm_version - Get negotiated SVDM version
+ * ...
+ */
+static inline int
+typec_altmode_get_svdm_version(struct typec_altmode *altmode)
+{
+ return typec_get_negotiated_svdm_version(typec_altmode2port(altmode));
+}
+
/**
* struct typec_altmode_driver - USB Type-C alternate mode device driver
* @id_table: Null terminated array of SVIDs
next prev parent reply other threads:[~2021-02-03 13:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 16:17 [PATCH v5 0/8] common SVDM version and VDO from dt Kyle Tso
2021-02-02 16:17 ` [PATCH v5 1/8] usb: typec: Manage SVDM version Kyle Tso
2021-02-03 12:47 ` Heikki Krogerus
2021-02-03 13:34 ` Heikki Krogerus [this message]
2021-02-03 14:51 ` Guenter Roeck
2021-02-03 15:01 ` Heikki Krogerus
2021-02-03 15:04 ` Heikki Krogerus
2021-02-03 15:42 ` Kyle Tso
2021-02-03 17:07 ` Guenter Roeck
2021-02-02 16:17 ` [PATCH v5 2/8] usb: pd: Update VDO definitions Kyle Tso
2021-02-03 12:48 ` Heikki Krogerus
2021-02-03 13:09 ` Greg KH
2021-02-03 16:54 ` Benson Leung
2021-02-04 2:24 ` Kyle Tso
2021-02-02 16:17 ` [PATCH v5 3/8] usb: pd: Make SVDM Version configurable in VDM header Kyle Tso
2021-02-02 16:17 ` [PATCH v5 4/8] usb: typec: tcpm: Detemine common SVDM Version Kyle Tso
2021-02-02 16:17 ` [PATCH v5 5/8] usb: typec: ucsi: " Kyle Tso
2021-02-02 16:17 ` [PATCH v5 6/8] usb: typec: displayport: Fill the negotiated SVDM Version in the header Kyle Tso
2021-02-02 16:17 ` [PATCH v5 7/8] dt-bindings: connector: Add SVDM VDO properties Kyle Tso
2021-02-02 16:17 ` [PATCH v5 8/8] usb: typec: tcpm: Get Sink VDO from fwnode Kyle Tso
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=20210203133408.GF1687065@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=badhri@google.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh+dt@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