aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 19:39:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 19:39:59 -0700
commit35f7a95266153b1cf0caca3aa9661cb721864527 (patch)
tree670f1a57e48937cc79fa5d0fd440872273ed725a /drivers/usb
parentMerge tag 'acpi-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (diff)
parentsoftware node: Initialize the return value in software_node_find_by_name() (diff)
downloadlinux-dev-35f7a95266153b1cf0caca3aa9661cb721864527.tar.xz
linux-dev-35f7a95266153b1cf0caca3aa9661cb721864527.zip
Merge tag 'devprop-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "Improve software node support (Heikki Krogerus) and clean up two assorted pieces of code (Andy Shevchenko, Geert Uytterhoeven)" * tag 'devprop-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: software node: Initialize the return value in software_node_find_by_name() software node: Initialize the return value in software_node_to_swnode() ACPI / property: Fix acpi_graph_get_remote_endpoint() name in kerneldoc device property: Remove duplicate test for NULL platform/x86: intel_cht_int33fe: Use new API to gain access to the role switch usb: roles: intel_xhci: Supplying software node for the role mux software node: Add software_node_find_by_name()
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/roles/intel-xhci-usb-role-switch.c27
1 files 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;
}