All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prashant Malani <pmalani@chromium.org>
To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	chrome-platform@lists.linux.dev
Cc: Prashant Malani <pmalani@chromium.org>,
	Benson Leung <bleung@chromium.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Guenter Roeck <groeck@chromium.org>
Subject: [PATCH 1/2] usb: typec: Add helper to get partner device struct
Date: Mon, 21 Nov 2022 20:13:35 +0000	[thread overview]
Message-ID: <20221121201337.2772216-2-pmalani@chromium.org> (raw)
In-Reply-To: <20221121201337.2772216-1-pmalani@chromium.org>

Some port drivers may want to set a Type-C partner as a parent for a
USB Power Delivery object, but the Type-C partner struct isn't exposed
outside of the Type-C class driver. Add a helper which returns a pointer
to the Type-C partner's device struct, so that it can be supplied as the
parent to the PD object.

Cc: Benson Leung <bleung@chromium.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/usb/typec/class.c | 13 +++++++++++++
 include/linux/usb/typec.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index bd5e5dd70431..154c70630432 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -821,6 +821,19 @@ void typec_partner_set_svdm_version(struct typec_partner *partner,
 }
 EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version);
 
+
+/**
+ * typec_partner_to_dev - Get the device struct of a USB Type-C partner.
+ * @partner: USB Type-C Partner
+ *
+ * Returns a pointer to the device struct or NULL.
+ */
+struct device *typec_partner_to_dev(struct typec_partner *partner)
+{
+	return partner ? &partner->dev : NULL;
+}
+EXPORT_SYMBOL_GPL(typec_partner_to_dev);
+
 /**
  * typec_register_partner - Register a USB Type-C Partner
  * @port: The USB Type-C Port the partner is connected to
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 7751bedcae5d..085be3e94ff8 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -327,6 +327,8 @@ void typec_partner_set_svdm_version(struct typec_partner *partner,
 				    enum usb_pd_svdm_ver svdm_version);
 int typec_get_negotiated_svdm_version(struct typec_port *port);
 
+struct device *typec_partner_to_dev(struct typec_partner *partner);
+
 int typec_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_delivery *pd);
 int typec_partner_set_usb_power_delivery(struct typec_partner *partner,
 					 struct usb_power_delivery *pd);
-- 
2.38.1.584.g0f3c55d4c2-goog


  reply	other threads:[~2022-11-21 20:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 20:13 [PATCH 0/2] platform/chrome: cros_ec_typec: Link PD object to partner Prashant Malani
2022-11-21 20:13 ` Prashant Malani [this message]
2022-11-22  9:58   ` [PATCH 1/2] usb: typec: Add helper to get partner device struct Heikki Krogerus
2022-11-22 19:05     ` Prashant Malani
2022-11-23  8:49       ` Heikki Krogerus
2022-11-21 20:13 ` [PATCH 2/2] platform/chrome: cros_ec_typec: Set parent of partner PD object Prashant Malani

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=20221121201337.2772216-2-pmalani@chromium.org \
    --to=pmalani@chromium.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=groeck@chromium.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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 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.