[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <802dd50c-7201-45d2-8855-6692aeb947db@rowland.harvard.edu>
Date: Mon, 24 Jul 2023 10:18:50 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Stanley Chang <stanley_chang@...ltek.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Roy Luo <royluo@...gle.com>, Ray Chi <raychi@...gle.com>,
Flavio Suligoi <f.suligoi@...m.it>,
linux-phy@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org
Subject: Re: [PATCH v8 1/5] usb: phy: add usb phy notify port status API
On Mon, Jul 24, 2023 at 06:34:48PM +0800, Stanley Chang wrote:
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -614,6 +614,30 @@ static int hub_ext_port_status(struct usb_hub *hub, int port1, int type,
> ret = 0;
> }
> mutex_unlock(&hub->status_mutex);
> +
> + /*
> + * There is no need to lock status_mutex here, because status_mutex
> + * protects hub->status, and the phy driver only checks the port
> + * status without changing the status.
> + */
> + if (!ret) {
> + struct usb_device *hdev = hub->hdev;
> +
> + /*
> + * Applies to roothub only. That is, when hdev->parent is
> + * empty. Only roothub will be notified of port state
> + * changes, since the USB PHY only cares about changes at
> + * the next level.
> + */
> + if (hdev && !hdev->parent) {
hdev can never be NULL, so you don't need to test it. Also, there
is an is_root_hub() routine you can call here -- it's an inline defined
in usb.h. If you use that then you won't have to explain it in the
comment.
To be fair, there are plenty of other places in the driver that test
!hdev->parent (or !udev->parent) with no explanation.
Alan Stern
Powered by blists - more mailing lists