* [PATCH 0/2] extcon: axp288: Move to swnodes
@ 2019-10-01 10:51 Heikki Krogerus
2019-10-01 10:51 ` [PATCH 1/2] usb: roles: Add usb_role_switch_find_by_fwnode() Heikki Krogerus
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-10-01 10:51 UTC (permalink / raw)
To: Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Greg Kroah-Hartman, linux-kernel, linux-usb
Hi Hans,
That AXP288 extcon driver is the last that uses build-in connection
description. I'm replacing it with a code that finds the role mux
software node instead.
I'm proposing also here a little helper
usb_role_switch_find_by_fwnode() that uses
class_find_device_by_fwnode() to find the role switches.
thanks,
Heikki Krogerus (2):
usb: roles: Add usb_role_switch_find_by_fwnode()
extcon: axp288: Remove the build-in connection description
drivers/extcon/extcon-axp288.c | 38 ++++++++++++++++++++--------------
drivers/usb/roles/class.c | 21 +++++++++++++++++++
include/linux/usb/role.h | 3 +++
3 files changed, 47 insertions(+), 15 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] usb: roles: Add usb_role_switch_find_by_fwnode()
2019-10-01 10:51 [PATCH 0/2] extcon: axp288: Move to swnodes Heikki Krogerus
@ 2019-10-01 10:51 ` Heikki Krogerus
2019-10-01 10:51 ` [PATCH 2/2] extcon: axp288: Remove the build-in connection description Heikki Krogerus
2019-10-06 19:37 ` [PATCH 0/2] extcon: axp288: Move to swnodes Hans de Goede
2 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-10-01 10:51 UTC (permalink / raw)
To: Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Greg Kroah-Hartman, linux-kernel, linux-usb
Simple wrapper function that searches USB role switches with
class_find_device_by_fwnode().
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/usb/roles/class.c | 21 +++++++++++++++++++++
include/linux/usb/role.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 94b4e7db2b94..8273126ffdf4 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -175,6 +175,27 @@ void usb_role_switch_put(struct usb_role_switch *sw)
}
EXPORT_SYMBOL_GPL(usb_role_switch_put);
+/**
+ * usb_role_switch_find_by_fwnode - Find USB role switch with its fwnode
+ * @fwnode: fwnode of the USB Role Switch
+ *
+ * Finds and returns role switch with @fwnode. The reference count for the
+ * found switch is incremented.
+ */
+struct usb_role_switch *
+usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode)
+{
+ struct device *dev;
+
+ if (!fwnode)
+ return NULL;
+
+ dev = class_find_device_by_fwnode(role_class, fwnode);
+
+ return dev ? to_role_switch(dev) : NULL;
+}
+EXPORT_SYMBOL_GPL(usb_role_switch_find_by_fwnode);
+
static umode_t
usb_role_switch_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{
diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
index 2d77f97df72d..efac3af83d6b 100644
--- a/include/linux/usb/role.h
+++ b/include/linux/usb/role.h
@@ -50,6 +50,9 @@ struct usb_role_switch *usb_role_switch_get(struct device *dev);
struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *node);
void usb_role_switch_put(struct usb_role_switch *sw);
+struct usb_role_switch *
+usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode);
+
struct usb_role_switch *
usb_role_switch_register(struct device *parent,
const struct usb_role_switch_desc *desc);
--
2.23.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] extcon: axp288: Remove the build-in connection description
2019-10-01 10:51 [PATCH 0/2] extcon: axp288: Move to swnodes Heikki Krogerus
2019-10-01 10:51 ` [PATCH 1/2] usb: roles: Add usb_role_switch_find_by_fwnode() Heikki Krogerus
@ 2019-10-01 10:51 ` Heikki Krogerus
2019-10-06 19:37 ` [PATCH 0/2] extcon: axp288: Move to swnodes Hans de Goede
2 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-10-01 10:51 UTC (permalink / raw)
To: Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Greg Kroah-Hartman, linux-kernel, linux-usb
Getting handle to the USB role switch by first finding its
software fwnode.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/extcon/extcon-axp288.c | 38 ++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 415afaf479e7..ae356e08c379 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -322,6 +322,25 @@ static void axp288_put_role_sw(void *data)
usb_role_switch_put(info->role_sw);
}
+static int axp288_extcon_find_role_sw(struct axp288_extcon_info *info)
+{
+ struct software_node *swnode;
+ struct fwnode_handle *fwnode;
+
+ if (!x86_match_cpu(cherry_trail_cpu_ids))
+ return 0;
+
+ swnode = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
+ if (!swnode)
+ return -EPROBE_DEFER;
+
+ fwnode = software_node_fwnode(swnode);
+ info->role_sw = usb_role_switch_find_by_fwnode(fwnode);
+ fwnode_handle_put(fwnode);
+
+ return info->role_sw ? 0 : -EPROBE_DEFER;
+}
+
static int axp288_extcon_probe(struct platform_device *pdev)
{
struct axp288_extcon_info *info;
@@ -343,9 +362,10 @@ static int axp288_extcon_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, info);
- info->role_sw = usb_role_switch_get(dev);
- if (IS_ERR(info->role_sw))
- return PTR_ERR(info->role_sw);
+ ret = axp288_extcon_find_role_sw(info);
+ if (ret)
+ return ret;
+
if (info->role_sw) {
ret = devm_add_action_or_reset(dev, axp288_put_role_sw, info);
if (ret)
@@ -440,26 +460,14 @@ static struct platform_driver axp288_extcon_driver = {
},
};
-static struct device_connection axp288_extcon_role_sw_conn = {
- .endpoint[0] = "axp288_extcon",
- .endpoint[1] = "intel_xhci_usb_sw-role-switch",
- .id = "usb-role-switch",
-};
-
static int __init axp288_extcon_init(void)
{
- if (x86_match_cpu(cherry_trail_cpu_ids))
- device_connection_add(&axp288_extcon_role_sw_conn);
-
return platform_driver_register(&axp288_extcon_driver);
}
module_init(axp288_extcon_init);
static void __exit axp288_extcon_exit(void)
{
- if (x86_match_cpu(cherry_trail_cpu_ids))
- device_connection_remove(&axp288_extcon_role_sw_conn);
-
platform_driver_unregister(&axp288_extcon_driver);
}
module_exit(axp288_extcon_exit);
--
2.23.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] extcon: axp288: Move to swnodes
2019-10-01 10:51 [PATCH 0/2] extcon: axp288: Move to swnodes Heikki Krogerus
2019-10-01 10:51 ` [PATCH 1/2] usb: roles: Add usb_role_switch_find_by_fwnode() Heikki Krogerus
2019-10-01 10:51 ` [PATCH 2/2] extcon: axp288: Remove the build-in connection description Heikki Krogerus
@ 2019-10-06 19:37 ` Hans de Goede
2019-10-08 11:15 ` Heikki Krogerus
2 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2019-10-06 19:37 UTC (permalink / raw)
To: Heikki Krogerus
Cc: MyungJoo Ham, Chanwoo Choi, Greg Kroah-Hartman, linux-kernel, linux-usb
Hi,
On 01-10-2019 12:51, Heikki Krogerus wrote:
> Hi Hans,
>
> That AXP288 extcon driver is the last that uses build-in connection
> description. I'm replacing it with a code that finds the role mux
> software node instead.
>
> I'm proposing also here a little helper
> usb_role_switch_find_by_fwnode() that uses
> class_find_device_by_fwnode() to find the role switches.
I'm building a kernel with these patches to test them now
(on hw which uses the axp288 extcon code-paths with the role-sw)
No test results yet, but I did notice this will building:
CC [M] drivers/extcon/extcon-axp288.o
drivers/extcon/extcon-axp288.c: In function ‘axp288_extcon_find_role_sw’:
drivers/extcon/extcon-axp288.c:333:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
333 | swnode = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
| ^
Regards,
Hans
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] extcon: axp288: Move to swnodes
2019-10-06 19:37 ` [PATCH 0/2] extcon: axp288: Move to swnodes Hans de Goede
@ 2019-10-08 11:15 ` Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-10-08 11:15 UTC (permalink / raw)
To: Hans de Goede
Cc: MyungJoo Ham, Chanwoo Choi, Greg Kroah-Hartman, linux-kernel, linux-usb
On Sun, Oct 06, 2019 at 09:37:25PM +0200, Hans de Goede wrote:
> Hi,
>
> On 01-10-2019 12:51, Heikki Krogerus wrote:
> > Hi Hans,
> >
> > That AXP288 extcon driver is the last that uses build-in connection
> > description. I'm replacing it with a code that finds the role mux
> > software node instead.
> >
> > I'm proposing also here a little helper
> > usb_role_switch_find_by_fwnode() that uses
> > class_find_device_by_fwnode() to find the role switches.
>
> I'm building a kernel with these patches to test them now
> (on hw which uses the axp288 extcon code-paths with the role-sw)
>
> No test results yet, but I did notice this will building:
>
> CC [M] drivers/extcon/extcon-axp288.o
> drivers/extcon/extcon-axp288.c: In function ‘axp288_extcon_find_role_sw’:
> drivers/extcon/extcon-axp288.c:333:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 333 | swnode = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
> | ^
Thanks Hans. I'll fix that.
Br,
--
heikki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-08 11:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01 10:51 [PATCH 0/2] extcon: axp288: Move to swnodes Heikki Krogerus
2019-10-01 10:51 ` [PATCH 1/2] usb: roles: Add usb_role_switch_find_by_fwnode() Heikki Krogerus
2019-10-01 10:51 ` [PATCH 2/2] extcon: axp288: Remove the build-in connection description Heikki Krogerus
2019-10-06 19:37 ` [PATCH 0/2] extcon: axp288: Move to swnodes Hans de Goede
2019-10-08 11:15 ` Heikki Krogerus
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).