From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Andy Shevchenko <andy@infradead.org>,
Hans de Goede <hdegoede@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Darren Hart <dvhart@infradead.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/3] usb: roles: intel_xhci: Supplying software node for the role mux
Date: Mon, 19 Aug 2019 13:07:23 +0300 [thread overview]
Message-ID: <20190819100724.30051-3-heikki.krogerus@linux.intel.com> (raw)
In-Reply-To: <20190819100724.30051-1-heikki.krogerus@linux.intel.com>
The primary purpose for this node will be to allow linking
the users of the switch to it. The users will be for example
USB Type-C connectors. By supplying a reference to this
node in the software nodes representing the USB Type-C
controllers or connectors, the drivers for those devices can
access the switch.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
.../usb/roles/intel-xhci-usb-role-switch.c | 27 ++++++++++++++-----
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/roles/intel-xhci-usb-role-switch.c b/drivers/usb/roles/intel-xhci-usb-role-switch.c
index 277de96181f9..7325a84dd1c8 100644
--- a/drivers/usb/roles/intel-xhci-usb-role-switch.c
+++ b/drivers/usb/roles/intel-xhci-usb-role-switch.c
@@ -39,6 +39,10 @@ struct intel_xhci_usb_data {
void __iomem *base;
};
+static const struct software_node intel_xhci_usb_node = {
+ "intel-xhci-usb-sw",
+};
+
static int intel_xhci_usb_set_role(struct device *dev, enum usb_role role)
{
struct intel_xhci_usb_data *data = dev_get_drvdata(dev);
@@ -122,17 +126,13 @@ static enum usb_role intel_xhci_usb_get_role(struct device *dev)
return role;
}
-static const struct usb_role_switch_desc sw_desc = {
- .set = intel_xhci_usb_set_role,
- .get = intel_xhci_usb_get_role,
- .allow_userspace_control = true,
-};
-
static int intel_xhci_usb_probe(struct platform_device *pdev)
{
+ struct usb_role_switch_desc sw_desc = { };
struct device *dev = &pdev->dev;
struct intel_xhci_usb_data *data;
struct resource *res;
+ int ret;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -147,9 +147,20 @@ static int intel_xhci_usb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data);
+ ret = software_node_register(&intel_xhci_usb_node);
+ if (ret)
+ return ret;
+
+ sw_desc.set = intel_xhci_usb_set_role,
+ sw_desc.get = intel_xhci_usb_get_role,
+ sw_desc.allow_userspace_control = true,
+ sw_desc.fwnode = software_node_fwnode(&intel_xhci_usb_node);
+
data->role_sw = usb_role_switch_register(dev, &sw_desc);
- if (IS_ERR(data->role_sw))
+ if (IS_ERR(data->role_sw)) {
+ fwnode_handle_put(sw_desc.fwnode);
return PTR_ERR(data->role_sw);
+ }
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
@@ -164,6 +175,8 @@ static int intel_xhci_usb_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
usb_role_switch_unregister(data->role_sw);
+ fwnode_handle_put(software_node_fwnode(&intel_xhci_usb_node));
+
return 0;
}
--
2.23.0.rc1
next prev parent reply other threads:[~2019-08-19 10:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-19 10:07 [PATCH v3 0/3] software node: Introduce software_node_find_by_name() Heikki Krogerus
2019-08-19 10:07 ` [PATCH v3 1/3] software node: Add software_node_find_by_name() Heikki Krogerus
2019-09-04 12:37 ` Greg Kroah-Hartman
2019-08-19 10:07 ` Heikki Krogerus [this message]
2019-08-19 10:37 ` [PATCH v3 2/3] usb: roles: intel_xhci: Supplying software node for the role mux Andy Shevchenko
2019-09-04 12:37 ` Greg Kroah-Hartman
2019-08-19 10:07 ` [PATCH v3 3/3] platform/x86: intel_cht_int33fe: Use new API to gain access to the role switch Heikki Krogerus
2019-08-19 10:39 ` [PATCH v3 0/3] software node: Introduce software_node_find_by_name() Andy Shevchenko
2019-08-19 10:41 ` Rafael J. Wysocki
2019-08-19 12:46 ` Hans de Goede
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=20190819100724.30051-3-heikki.krogerus@linux.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andy@infradead.org \
--cc=dvhart@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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;
as well as URLs for NNTP newsgroup(s).