Thread (1 message) 1 message, 1 author, 2016-02-05

Re: [PATCH v4 1/1] USB: core: let USB device know device node

From: Peter Chen <hidden>
Date: 2016-02-05 12:55:55
Also in: linux-arm-kernel

On Fri, Feb 5, 2016 at 12:36 AM, Alan Stern [off-list ref] wrote:
On Thu, 4 Feb 2016, Peter Chen wrote:
quoted
On Mon, Jan 25, 2016 at 03:24:39PM +0800, Peter Chen wrote:
quoted
Although most of USB devices are hot-plug's, there are still some devices
are hard wired on the board, eg, for HSIC and SSIC interface USB devices.
If these kinds of USB devices are multiple functions, and they can supply
other interfaces like i2c, gpios for other devices, we may need to
describe these at device tree.

In this commit, it uses "reg" in dts as physical port number to match
the phyiscal port number decided by USB core, if they are the same,
then the device node is for the device we are creating for USB core.

Signed-off-by: Peter Chen <redacted>
---
Changes for v4:
- The range of "reg" should be 1-31, changing device node address
  style as in lower case hexadecimal with leading zeroes suppressed
  [binding doc, usb-device.txt]
- Improve the example at binding doc, it describes node from the top
  (the controller)
- Delete the struct of_node * within struct usb_device
- Using usb_hcd_find_raw_port_number to get raw port number under root
  hub port
Hi Alan, Arnd, and others, would you please give Ack for it if you
are OK with this patch? I am not sure if Greg will queue it or not
if no one Acks it, thanks.
quoted
quoted
@@ -508,11 +509,20 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
    dev->connect_time = jiffies;
    dev->active_duration = -jiffies;
 #endif
-   if (root_hub)   /* Root hub always ok [and always wired] */
+   if (root_hub) { /* Root hub always ok [and always wired] */
            dev->authorized = 1;
-   else {
+           dev->dev.of_node = bus->controller->of_node;
+   } else {
            dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd);
            dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0;
+
+           if (dev->dev.parent->parent == bus->controller)
+                   /* device under root hub's port */
+                   port1 = usb_hcd_find_raw_port_number(usb_hcd,
+                           port1);
I would change the test to "if (!parent->parent)" and add {} around the
body (since it's 3 lines long).  Also, although this doesn't really
matter, you could consider putting the new code inside the previous big
"if" statement instead of down here at the end of the function.
Sorry, Alan, I can understand using (!parent->parent) to stands for
the device connects to the root hub port, others I can't understand.

-- 
BR,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help