linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: core: skip interfaces disabled in devicetree
@ 2019-02-16 17:04 Mans Rullgard
  2019-02-19 13:11 ` Greg Kroah-Hartman
  2019-02-19 14:52 ` [PATCH v2] " Mans Rullgard
  0 siblings, 2 replies; 5+ messages in thread
From: Mans Rullgard @ 2019-02-16 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb; +Cc: linux-kernel

If an interface has an associated devicetree node with status disabled,
do not register the device.  This is useful for boards with a built-in
multifunction USB device where some functions are broken or otherwise
undesired.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/usb/core/message.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index bfa5eda0cc26..6b45d4835e41 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 	for (i = 0; i < nintf; ++i) {
 		struct usb_interface *intf = cp->interface[i];
 
+		if (intf->dev.of_node &&
+		    !of_device_is_available(intf->dev.of_node))
+			continue;
+
 		dev_dbg(&dev->dev,
 			"adding %s (config #%d, interface %d)\n",
 			dev_name(&intf->dev), configuration,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: core: skip interfaces disabled in devicetree
  2019-02-16 17:04 [PATCH] usb: core: skip interfaces disabled in devicetree Mans Rullgard
@ 2019-02-19 13:11 ` Greg Kroah-Hartman
  2019-02-19 13:24   ` Måns Rullgård
  2019-02-19 14:52 ` [PATCH v2] " Mans Rullgard
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-19 13:11 UTC (permalink / raw)
  To: Mans Rullgard; +Cc: linux-usb, linux-kernel

On Sat, Feb 16, 2019 at 05:04:52PM +0000, Mans Rullgard wrote:
> If an interface has an associated devicetree node with status disabled,
> do not register the device.  This is useful for boards with a built-in
> multifunction USB device where some functions are broken or otherwise
> undesired.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  drivers/usb/core/message.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index bfa5eda0cc26..6b45d4835e41 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
>  	for (i = 0; i < nintf; ++i) {
>  		struct usb_interface *intf = cp->interface[i];
>  
> +		if (intf->dev.of_node &&
> +		    !of_device_is_available(intf->dev.of_node))
> +			continue;

Shouldn't you at least print some message out saying you are skipping
this?  Odds are this is going to cause regressions in devices that were
not expecting this, right?  So pointing them at why their devices now no
longer work would be good :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: core: skip interfaces disabled in devicetree
  2019-02-19 13:11 ` Greg Kroah-Hartman
@ 2019-02-19 13:24   ` Måns Rullgård
  2019-02-19 13:42     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Måns Rullgård @ 2019-02-19 13:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

> On Sat, Feb 16, 2019 at 05:04:52PM +0000, Mans Rullgard wrote:
>> If an interface has an associated devicetree node with status disabled,
>> do not register the device.  This is useful for boards with a built-in
>> multifunction USB device where some functions are broken or otherwise
>> undesired.
>> 
>> Signed-off-by: Mans Rullgard <mans@mansr.com>
>> ---
>>  drivers/usb/core/message.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>> 
>> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
>> index bfa5eda0cc26..6b45d4835e41 100644
>> --- a/drivers/usb/core/message.c
>> +++ b/drivers/usb/core/message.c
>> @@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
>>  	for (i = 0; i < nintf; ++i) {
>>  		struct usb_interface *intf = cp->interface[i];
>>  
>> +		if (intf->dev.of_node &&
>> +		    !of_device_is_available(intf->dev.of_node))
>> +			continue;
>
> Shouldn't you at least print some message out saying you are skipping
> this?  Odds are this is going to cause regressions in devices that were
> not expecting this, right?  So pointing them at why their devices now no
> longer work would be good :)

They will only be skipped if there is a device tree node for the
interface _and_ it has and explicit status = "disabled" property.
The default is still to create devices for all interfaces.

That said, printing a message is probably a good idea anyway.  Would
"info" level be appropriate for this?

-- 
Måns Rullgård

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: core: skip interfaces disabled in devicetree
  2019-02-19 13:24   ` Måns Rullgård
@ 2019-02-19 13:42     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-19 13:42 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-usb, linux-kernel

On Tue, Feb 19, 2019 at 01:24:51PM +0000, Måns Rullgård wrote:
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> 
> > On Sat, Feb 16, 2019 at 05:04:52PM +0000, Mans Rullgard wrote:
> >> If an interface has an associated devicetree node with status disabled,
> >> do not register the device.  This is useful for boards with a built-in
> >> multifunction USB device where some functions are broken or otherwise
> >> undesired.
> >> 
> >> Signed-off-by: Mans Rullgard <mans@mansr.com>
> >> ---
> >>  drivers/usb/core/message.c | 4 ++++
> >>  1 file changed, 4 insertions(+)
> >> 
> >> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> >> index bfa5eda0cc26..6b45d4835e41 100644
> >> --- a/drivers/usb/core/message.c
> >> +++ b/drivers/usb/core/message.c
> >> @@ -2007,6 +2007,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
> >>  	for (i = 0; i < nintf; ++i) {
> >>  		struct usb_interface *intf = cp->interface[i];
> >>  
> >> +		if (intf->dev.of_node &&
> >> +		    !of_device_is_available(intf->dev.of_node))
> >> +			continue;
> >
> > Shouldn't you at least print some message out saying you are skipping
> > this?  Odds are this is going to cause regressions in devices that were
> > not expecting this, right?  So pointing them at why their devices now no
> > longer work would be good :)
> 
> They will only be skipped if there is a device tree node for the
> interface _and_ it has and explicit status = "disabled" property.
> The default is still to create devices for all interfaces.

Yes, but today if you have such a status field set, it will not skip
them, so who knows who has their DT messed up :)

> That said, printing a message is probably a good idea anyway.  Would
> "info" level be appropriate for this?

That is a good idea.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] usb: core: skip interfaces disabled in devicetree
  2019-02-16 17:04 [PATCH] usb: core: skip interfaces disabled in devicetree Mans Rullgard
  2019-02-19 13:11 ` Greg Kroah-Hartman
@ 2019-02-19 14:52 ` Mans Rullgard
  1 sibling, 0 replies; 5+ messages in thread
From: Mans Rullgard @ 2019-02-19 14:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb; +Cc: linux-kernel

If an interface has an associated devicetree node with status disabled,
do not register the device.  This is useful for boards with a built-in
multifunction USB device where some functions are broken or otherwise
undesired.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
Changed in v2:
- print message about skipped interfaces
---
 drivers/usb/core/message.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index bfa5eda0cc26..46bf79bc03ad 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -2007,6 +2007,13 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
 	for (i = 0; i < nintf; ++i) {
 		struct usb_interface *intf = cp->interface[i];
 
+		if (intf->dev.of_node &&
+		    !of_device_is_available(intf->dev.of_node)) {
+			dev_info(&dev->dev, "skipping disabled interface %d\n",
+				 intf->cur_altsetting->desc.bInterfaceNumber);
+			continue;
+		}
+
 		dev_dbg(&dev->dev,
 			"adding %s (config #%d, interface %d)\n",
 			dev_name(&intf->dev), configuration,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-19 14:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-16 17:04 [PATCH] usb: core: skip interfaces disabled in devicetree Mans Rullgard
2019-02-19 13:11 ` Greg Kroah-Hartman
2019-02-19 13:24   ` Måns Rullgård
2019-02-19 13:42     ` Greg Kroah-Hartman
2019-02-19 14:52 ` [PATCH v2] " Mans Rullgard

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).