Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1739214rwd; Thu, 25 May 2023 17:56:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68shUnp2debZGycLI0Q0BJJZAkS+JtNMkWs2gKQd4TW3dANrUB185it3teUsZZquY3Ph1C X-Received: by 2002:a05:6a00:2d2a:b0:64b:256:204c with SMTP id fa42-20020a056a002d2a00b0064b0256204cmr873722pfb.20.1685062581268; Thu, 25 May 2023 17:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685062581; cv=none; d=google.com; s=arc-20160816; b=jj0g+mHD7U7JmcQiJvayYtS3v2BzlGsSnoNtEqMPyOrTXxTQnd9q25PwW+sZxE8IfA tLZs1+9PzwNCSNHdib99g5Wvw07Ik4rTcwMWv/3vGteREaIrSO+YxFYsBSXPy3tTan44 mrbz6/4gDO5eypQaX5Q7mWjDMNty6ojMlTxkidyFIrypCjKrp9Ox6sfzjQcRwCv1ssmW d8YhhaT8c1te4rhrFHgNlxEmeB5QCZfEVW08WIw5xcOQjy+zh5t0o3y5eozIpR+FNs9B QNnd9vZzFzjIqwA4+DM08nMSkp2Ry01uCQ0WHwAvgiHoY3fBXgEkBj+ANPRcjj/c+rzy +rlQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=j1phlNhwolmM2i+4Nwv/b+xLajOcsLktvOs+m3tIw0I=; b=p9I7ywCvJO43C45EZemIKUJZL2RsFiNW8E3XGysm7CKyEMLifpSoA6g166+IIlLfLr /EW94h4vsE4u/KgjeYO3h7UYlQ1imyFjxBt4kBripL0UnPpNXY2wFJ0ca/q41r6gzeu1 X5HZ3xtx4SOwgSkL+/C6iIUOwnmHaSOomoUP/a1aea8qZD+ELO6lHkBvAQAnYohevJqT BSAreuhvXXuWq395wByOWkHxDlsxs0ZUMdlqLIjzha+m8AfvA67y9EXUle2A7tCmR+dK xWPQHPGGmHM+kQqO6+l/XJoNy506iSZ6toyuB+JjNofCvpFtgRWm56wCrTcWRalwyRxX YJNw== 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 bs185-20020a6328c2000000b0052c2b1efee2si2566326pgb.339.2023.05.25.17.56.08; Thu, 25 May 2023 17:56:21 -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 S235472AbjEZAvD (ORCPT + 99 others); Thu, 25 May 2023 20:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236055AbjEZAu7 (ORCPT ); Thu, 25 May 2023 20:50:59 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 70A4F1B4 for ; Thu, 25 May 2023 17:50:54 -0700 (PDT) Received: (qmail 276368 invoked by uid 1000); 25 May 2023 20:50:53 -0400 Date: Thu, 25 May 2023 20:50:53 -0400 From: Alan Stern To: Roy Luo Cc: raychi@google.com, badhri@google.com, Greg Kroah-Hartman , Benjamin Tissoires , Michael Grzeschik , Bastien Nocera , Mathias Nyman , Matthias Kaehlcke , Flavio Suligoi , Douglas Anderson , Christophe JAILLET , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [RFC PATCH v1] usb: core: add sysfs entry for usb device state Message-ID: References: <20230525173818.219633-1-royluo@google.com> <408575c0-2967-4cdb-92c7-1b2845038d20@rowland.harvard.edu> <89cf2c61-a55e-4c35-93b2-35fa7ab0266b@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 Thu, May 25, 2023 at 01:31:17PM -0700, Roy Luo wrote: > On Thu, May 25, 2023 at 12:10 PM Alan Stern wrote: > > > > On Thu, May 25, 2023 at 11:46:23AM -0700, Roy Luo wrote: > > > Alan, thanks for the quick response! > > > Yes, port_dev->state is indeed the same as port_dev->child->state. However, > > > I still add port_dev->state because port_dev->child won't be assigned until > > > the corresponding usb_device is in ADDRESS state. > > > I wish I can assign get port_dev->child assigned earlier, but I think > > > the current design - assign port_dev->child and device_add() after ADDRESS > > > state - also makes sense because there are many ways that the enumeration > > > could fail in the early stage. By adding port_dev->state, I can link > > > usb_device->state to usb_port as soon as the usb_device is created to get > > > around the limitation of port_dev->child. > > > I would be very happy to hear other ideas. > > > > Is there any real reason not to set port_dev->child as soon as the > > usb_device structure is created? If enumeration fails, the pointer can > > be cleared. > > > > Alan Stern > > Currently the usb core assumes the usb_device that port_dev->child points > to is enumerated and port_dev->child->dev is registered when > port_dev->child is present. Setting port_dev->child early would break this > fundamental assumption, hence I'm a bit reluctant to go this way. Well, you could remove that assumption by adding a "child_is_registered" flag and explicitly checking it. Alan Stern