Re: [PATCH 2/21] ehci: Support for Intel Moorestown MPH and OTG host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/3/2010 8:47 AM, Wu, Hao wrote:

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 27115b4..4e14c00 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1549,6 +1549,14 @@ static void hub_free_dev(struct usb_device *udev)
  		hcd->driver->free_dev(hcd, udev);
  }

+static void otg_notify(struct usb_device *udev, unsigned action)
+{
+	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+
+	if (hcd->otg_notify)
+		hcd->otg_notify(udev, action);
+}
+
  /**
   * usb_disconnect - disconnect a device (usbcore-internal)
   * @pdev: pointer to device being disconnected
@@ -1606,6 +1614,7 @@ void usb_disconnect(struct usb_device **pdev)
  	 * notifier chain (used by usbfs and possibly others).
  	 */
  	device_del(&udev->dev);
+	otg_notify(udev, USB_DEVICE_REMOVE);

  	/* Free the device number and delete the parent's children[]
  	 * (or root_hub) pointer.
@@ -1829,6 +1838,7 @@ int usb_new_device(struct usb_device *udev)
  		dev_err(&udev->dev, "can't device_add, error %d\n", err);
  		goto fail;
  	}
+	otg_notify(udev, USB_DEVICE_ADD);

  	(void) usb_create_ep_devs(&udev->dev,&udev->ep0, udev);
  	return err;

Why would we need to create a new callback for every device added and
removed?  Why do you need this and why doesn't the existing functions to
do this type of thing work for you?

It is needed to do notification for USB device connect/disconnect events to transceiver driver in OTG case.
Those events are important for OTG state machine maintained in transceiver driver.

I agree that these events are required to transition to a different OTG state. But why ->notify method is included in usb_hcd struct. This may lead to another private interface between HCD-->OTG. IMO, we should have this callback in otg_transceiver struct but not in usb_hcd struct. We may also need events like HNP FAILED, No response for HNP enable request, and NOT found in TPL etc. So I prefer to define an enum for OTG event instead of using USB_DEVICE_ADD and USB_DEVICE_REMOVE.

Thanks,
Pavan

--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux