Message ID | 1434569645-30322-4-git-send-email-hdegoede@redhat.com |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
Hi Hans. On 17 June 2015 at 13:33, Hans de Goede <hdegoede@redhat.com> wrote: > Drop the unneeded portnr function argument, the portnr is part of the > usb_device struct which is passed via the dev argument. > > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > common/usb.c | 10 +++++----- > drivers/usb/host/usb-uclass.c | 2 +- > include/usb.h | 6 +++--- > 3 files changed, 9 insertions(+), 9 deletions(-) This was needed in the case where a fake usb_device was passed in. Has your previous refactoring changed that? Regards, Simon
Hi, On 29-06-15 05:44, Simon Glass wrote: > Hi Hans. > > On 17 June 2015 at 13:33, Hans de Goede <hdegoede@redhat.com> wrote: >> Drop the unneeded portnr function argument, the portnr is part of the >> usb_device struct which is passed via the dev argument. >> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com> >> --- >> common/usb.c | 10 +++++----- >> drivers/usb/host/usb-uclass.c | 2 +- >> include/usb.h | 6 +++--- >> 3 files changed, 9 insertions(+), 9 deletions(-) > > This was needed in the case where a fake usb_device was passed in. Has > your previous refactoring changed that? The portnr is still passed but it is padded via the usb_device struct's portnr member. When doing a CONFIG_DM_USB=y build the only call site of usb_setup_device() is usb_scan_device() from drivers/usb/host/usb-uclass.c which does: udev->portnr = port; debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? dev_get_parentdata(parent) : NULL; ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); So portnr is always set in the usb_device strict, and that is what gets used after this patch. Regards, Hans
Hi Hans, On 30 June 2015 at 06:29, Hans de Goede <hdegoede@redhat.com> wrote: > Hi, > > > On 29-06-15 05:44, Simon Glass wrote: >> >> Hi Hans. >> >> On 17 June 2015 at 13:33, Hans de Goede <hdegoede@redhat.com> wrote: >>> >>> Drop the unneeded portnr function argument, the portnr is part of the >>> usb_device struct which is passed via the dev argument. >>> >>> Signed-off-by: Hans de Goede <hdegoede@redhat.com> >>> --- >>> common/usb.c | 10 +++++----- >>> drivers/usb/host/usb-uclass.c | 2 +- >>> include/usb.h | 6 +++--- >>> 3 files changed, 9 insertions(+), 9 deletions(-) >> >> >> This was needed in the case where a fake usb_device was passed in. Has >> your previous refactoring changed that? > > > The portnr is still passed but it is padded via the usb_device struct's > portnr member. When doing a CONFIG_DM_USB=y build the only call site of > usb_setup_device() is usb_scan_device() from drivers/usb/host/usb-uclass.c > which does: > > udev->portnr = port; > debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); > parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? > dev_get_parentdata(parent) : NULL; > ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); > > So portnr is always set in the usb_device strict, and that is what gets > used after this patch. OK thanks for explaining that. Acked-by: Simon Glass <sjg@chromium.org> Regards, Simon
On 30 June 2015 at 08:51, Simon Glass <sjg@chromium.org> wrote: > Hi Hans, > > On 30 June 2015 at 06:29, Hans de Goede <hdegoede@redhat.com> wrote: >> Hi, >> >> >> On 29-06-15 05:44, Simon Glass wrote: >>> >>> Hi Hans. >>> >>> On 17 June 2015 at 13:33, Hans de Goede <hdegoede@redhat.com> wrote: >>>> >>>> Drop the unneeded portnr function argument, the portnr is part of the >>>> usb_device struct which is passed via the dev argument. >>>> >>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com> >>>> --- >>>> common/usb.c | 10 +++++----- >>>> drivers/usb/host/usb-uclass.c | 2 +- >>>> include/usb.h | 6 +++--- >>>> 3 files changed, 9 insertions(+), 9 deletions(-) >>> >>> >>> This was needed in the case where a fake usb_device was passed in. Has >>> your previous refactoring changed that? >> >> >> The portnr is still passed but it is padded via the usb_device struct's >> portnr member. When doing a CONFIG_DM_USB=y build the only call site of >> usb_setup_device() is usb_scan_device() from drivers/usb/host/usb-uclass.c >> which does: >> >> udev->portnr = port; >> debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); >> parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? >> dev_get_parentdata(parent) : NULL; >> ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); >> >> So portnr is always set in the usb_device strict, and that is what gets >> used after this patch. > > OK thanks for explaining that. > > Acked-by: Simon Glass <sjg@chromium.org> Applied to u-boot-dm/next, thanks!
diff --git a/common/usb.c b/common/usb.c index 4ddf98f..d237478 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1030,7 +1030,7 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read) } static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read, - struct usb_device *parent, int portnr) + struct usb_device *parent) { int err; @@ -1048,7 +1048,7 @@ static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read, err = usb_setup_descriptor(dev, do_read); if (err) return err; - err = usb_legacy_port_reset(parent, portnr); + err = usb_legacy_port_reset(parent, dev->portnr); if (err) return err; @@ -1126,7 +1126,7 @@ int usb_select_config(struct usb_device *dev) } int usb_setup_device(struct usb_device *dev, bool do_read, - struct usb_device *parent, int portnr) + struct usb_device *parent) { int addr; int ret; @@ -1135,7 +1135,7 @@ int usb_setup_device(struct usb_device *dev, bool do_read, addr = dev->devnum; dev->devnum = 0; - ret = usb_prepare_device(dev, addr, do_read, parent, portnr); + ret = usb_prepare_device(dev, addr, do_read, parent); if (ret) return ret; ret = usb_select_config(dev); @@ -1165,7 +1165,7 @@ int usb_new_device(struct usb_device *dev) #ifdef CONFIG_USB_XHCI do_read = false; #endif - err = usb_setup_device(dev, do_read, dev->parent, dev->portnr); + err = usb_setup_device(dev, do_read, dev->parent); if (err) return err; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 10d4712..18680c9 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -565,7 +565,7 @@ int usb_scan_device(struct udevice *parent, int port, debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? dev_get_parentdata(parent) : NULL; - ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev, port); + ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); debug("read_descriptor for '%s': ret=%d\n", parent->name, ret); if (ret) return ret; diff --git a/include/usb.h b/include/usb.h index 6b5d536..8a71e28 100644 --- a/include/usb.h +++ b/include/usb.h @@ -734,14 +734,14 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index); * * @dev: USB device pointer. This need not be a real device - it is * common for it to just be a local variable with its ->dev - * member (i.e. @dev->dev) set to the parent device + * member (i.e. @dev->dev) set to the parent device and + * dev->portnr set to the port number on the hub (1=first) * @do_read: true to read the device descriptor before an address is set * (should be false for XHCI buses, true otherwise) * @parent: Parent device (either UCLASS_USB or UCLASS_USB_HUB) - * @portnr: Port number on hub (1=first) or 0 for none * @return 0 if OK, -ve on error */ int usb_setup_device(struct usb_device *dev, bool do_read, - struct usb_device *parent, int portnr); + struct usb_device *parent); /** * usb_hub_scan() - Scan a hub and find its devices
Drop the unneeded portnr function argument, the portnr is part of the usb_device struct which is passed via the dev argument. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- common/usb.c | 10 +++++----- drivers/usb/host/usb-uclass.c | 2 +- include/usb.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)