RE: [PATCH 2/6] usb: core: TPL should apply for both OTG and EH

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

 




 
> >
> >  /**
> >   * usb_enumerate_device_otg - FIXME (usbcore-internal) @@ -2261,21
> > +2259,6 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
> >  			}
> >  		}
> >  	}
> > -
> > -	if (!is_targeted(udev)) {
> > -
> > -		/* Maybe it can talk to us, though we can't talk to it.
> > -		 * (Includes HNP test device.)
> > -		 */
> > -		if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
> > -			err = usb_port_suspend(udev, PMSG_SUSPEND);
> > -			if (err < 0)
> > -				dev_dbg(&udev->dev, "HNP fail, %d\n", err);
> > -		}
> > -		err = -ENOTSUPP;
> 
> If I did not miss anything then I see an issue if above hunk is removed.
> 
> Suppose, there is an OTG B device which is not supported by host, then
> the above hunk was suspending the bus so that B device can get a chance
> to become host. By removing above hunk, how do we cater this scenario?
> 
> ~Pratyush
> 
> PS: All other changes of the series seems fine to me.
> 

Thanks, Pratyush, I will change the code like below to cover this case.

+       if (IS_ENABLED(CONFIG_USB_OTG_WHITELIST) && hcd->tpl_support &&
+               !is_targeted(udev) && IS_ENABLED(CONFIG_USB_OTG)) {
+               /* Maybe it can talk to us, though we can't talk to it.
+                * (Includes HNP test device.)
+                */
+               if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
+                       err = usb_port_suspend(udev, PMSG_AUTO_SUSPEND);
+                       if (err < 0)
+                               dev_dbg(&udev->dev, "HNP fail, %d\n", err);
+               }
+               return -ENOTSUPP;
+       }
+

Peter

> > -		goto fail;
> > -	}
> > -fail:
> >  #endif
> >  	return err;
> >  }
> > @@ -2319,6 +2302,9 @@ static int usb_enumerate_device(struct usb_device
> *udev)
> >  	if (err < 0)
> >  		return err;
> >
> > +	if (!is_targeted(udev))
> > +		return -ENOTSUPP;
> > +
> >  	usb_detect_interface_quirks(udev);
> >
> >  	return 0;
> > diff --git a/drivers/usb/core/otg_whitelist.h
> > b/drivers/usb/core/otg_whitelist.h
> > index e8cdce5..4d6a134 100644
> > --- a/drivers/usb/core/otg_whitelist.h
> > +++ b/drivers/usb/core/otg_whitelist.h
> > @@ -10,8 +10,8 @@
> >   */
> >
> >  /*
> > - * This OTG Whitelist is the OTG "Targeted Peripheral List".  It
> > should
> > - * mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
> > + * This OTG and Embedded Host Whitelist is "Targeted Peripheral List".
> > + * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
> >   *
> >   * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
> >   */
> > @@ -49,9 +49,9 @@ static struct usb_device_id whitelist_table [] = {
> > static int is_targeted(struct usb_device *dev)  {
> >  	struct usb_device_id	*id = whitelist_table;
> > +	struct usb_hcd		*hcd = bus_to_hcd(dev->bus);
> >
> > -	/* possible in developer configs only! */
> > -	if (!dev->bus->otg_port)
> > +	if (!IS_ENABLED(CONFIG_USB_OTG_WHITELIST) || !hcd->tpl_support)
> >  		return 1;
> >
> >  	/* HNP test device is _never_ targeted (see OTG spec 6.6.6) */ @@
> > -99,14 +99,12 @@ static int is_targeted(struct usb_device *dev)
> >  	/* add other match criteria here ... */
> >
> >
> > -	/* OTG MESSAGE: report errors here, customize to match your product
> */
> > -	dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
> > -		le16_to_cpu(dev->descriptor.idVendor),
> > -		le16_to_cpu(dev->descriptor.idProduct));
> > -#ifdef	CONFIG_USB_OTG_WHITELIST
> > +	/*
> > +	 * Required error message for OTG & EH compliance test,
> > +	 * customize it to match your product
> > +	 */
> > +	dev_err(&dev->dev, "unsupported device\n");
> > +
> >  	return 0;
> > -#else
> > -	return 1;
> > -#endif
> >  }
> >
> > --
> > 1.7.9.5
> >
> > --
> > 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
--
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