diff mbox series

[v1,1/2] usb: core: acpi: Use the sysdev pointer instead of controller device

Message ID 20220425121340.1362-2-heikki.krogerus@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series usb: core: acpi: Rely on the sysdev pointer | expand

Commit Message

Heikki Krogerus April 25, 2022, 12:13 p.m. UTC
The controller device (hcd) does not always have the ACPI
companion assigned to it at all. We can not rely on it when
finding the ACPI companion for the root hub. Instead we need
to use the sysdev pointer here.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/core/usb-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko April 26, 2022, 10:18 a.m. UTC | #1
On Mon, Apr 25, 2022 at 3:41 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> The controller device (hcd) does not always have the ACPI
> companion assigned to it at all. We can not rely on it when
> finding the ACPI companion for the root hub. Instead we need
> to use the sysdev pointer here.

...

>         if (!udev->parent) {
>                 /* root hub is only child (_ADR=0) under its parent, the HC */

I believe the comment can be amended now to point out that we use the
physical device representing the parent of this child, and not
(always) a direct parent of the device in terms of Linux device model.

> -               adev = ACPI_COMPANION(udev->dev.parent);
> +               adev = ACPI_COMPANION(udev->bus->sysdev);
>                 return acpi_find_child_device(adev, 0, false);
>         }
Heikki Krogerus April 27, 2022, 7:20 a.m. UTC | #2
On Tue, Apr 26, 2022 at 12:18:24PM +0200, Andy Shevchenko wrote:
> On Mon, Apr 25, 2022 at 3:41 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> wrote:
> >
> > The controller device (hcd) does not always have the ACPI
> > companion assigned to it at all. We can not rely on it when
> > finding the ACPI companion for the root hub. Instead we need
> > to use the sysdev pointer here.
> 
> ...
> 
> >         if (!udev->parent) {
> >                 /* root hub is only child (_ADR=0) under its parent, the HC */
> 
> I believe the comment can be amended now to point out that we use the
> physical device representing the parent of this child, and not
> (always) a direct parent of the device in terms of Linux device model.

Okay, I'll try to improve the comment.

> > -               adev = ACPI_COMPANION(udev->dev.parent);
> > +               adev = ACPI_COMPANION(udev->bus->sysdev);
> >                 return acpi_find_child_device(adev, 0, false);
> >         }

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index bb1da35eb891e..fbaf5045507bb 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -206,7 +206,7 @@  usb_acpi_find_companion_for_device(struct usb_device *udev)
 
 	if (!udev->parent) {
 		/* root hub is only child (_ADR=0) under its parent, the HC */
-		adev = ACPI_COMPANION(udev->dev.parent);
+		adev = ACPI_COMPANION(udev->bus->sysdev);
 		return acpi_find_child_device(adev, 0, false);
 	}