Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3197498rwo; Mon, 24 Jul 2023 07:39:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlHGiIED6jKA9uiBnrE4dJ1yF4sL/eE9fPtXuY4EiXDXIeXycnvxnTCGNZv/lWum2nbqHrtf X-Received: by 2002:a05:6358:e490:b0:134:e631:fd2b with SMTP id by16-20020a056358e49000b00134e631fd2bmr5187354rwb.0.1690209548615; Mon, 24 Jul 2023 07:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690209548; cv=none; d=google.com; s=arc-20160816; b=GEDz3+EYPImeH8mOwG0UCmZP3YRx6pzZYtAR9TNFeaY/CpGfrhh3v2GsvxnptSdz6R IYkouA7OsME+ZuZtD9XvZpr5+NoYoLKdbakkNAIv/L/eG3xgOBPtLB7/8lB96Us8UtUz RB6O70dtrXJclGYuhifePEADVEDhFwiBW97sLB73fc2pqtgmxugZzdJu26c/rw0oriKh adVJK1QcqJ4ocpYMzo7CDhjsh3IGprwK3l13qbkO/VpQVHB5jp65bqZvJ6MSLXp0y6GT ENNYDxOTXs9LQEa2msIo1WohfZJJhWjnzkh5OGcP7Z57dw715Kicjgx11XzAjUVwKdV0 yGog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=NqK3Muf36YDQQ8VLH4jUiG3IlX2a5uWvAZcW0caZ2S4=; fh=17L/fZRze2TUT0SW7JHagYEjfqCpf+I+iuCHCWYRpOU=; b=sZ5k4pCAw1YJ6YUWtGvm3ECjtP4A3B1UhqPioETZqMOWdRJbEaeKEOdHe00NnHWmrz /Qg9IRT1oGF52MwFRQeaE2EYGrhteNK7Y9+TtGTIkrvSOFS8BdKME7U0UbYyc9txt0g5 3ElfAneUQ5KXv3YON1XUZgVdFlMkUVF1ycXciC1/hb+rsK/7wg01FgWaRWKfgwXexoBz 48/nEL03vV1QrzkJCUdH0t7xJpBwM4BPsNJq5srRE81ExBy/3BGtWvIZ1Wmn8o4+H3q9 bF/opusjXj7cgXYSxwP5dVtgelwtxfzVYtNm6P9KDDAh2QbX/Uv8EfTQjkeknsm8crEX 8ThQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d71-20020a63364a000000b0055c07307e5bsi8891104pga.64.2023.07.24.07.38.56; Mon, 24 Jul 2023 07:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjGXOSx (ORCPT + 99 others); Mon, 24 Jul 2023 10:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjGXOSw (ORCPT ); Mon, 24 Jul 2023 10:18:52 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8CC85E64 for ; Mon, 24 Jul 2023 07:18:51 -0700 (PDT) Received: (qmail 1848669 invoked by uid 1000); 24 Jul 2023 10:18:50 -0400 Date: Mon, 24 Jul 2023 10:18:50 -0400 From: Alan Stern To: Stanley Chang Cc: Greg Kroah-Hartman , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Roy Luo , Ray Chi , Flavio Suligoi , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v8 1/5] usb: phy: add usb phy notify port status API Message-ID: <802dd50c-7201-45d2-8855-6692aeb947db@rowland.harvard.edu> References: <20230724103600.14164-1-stanley_chang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724103600.14164-1-stanley_chang@realtek.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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