Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1206576iog; Tue, 14 Jun 2022 01:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAKIoGXCL/4xSO6VWkGZp0zkdXQhxEMhwcYZPxUtuG+Zb3W7hcBeVEQsQVS+gaK14ZGGxo X-Received: by 2002:a17:906:7489:b0:712:2a98:d36 with SMTP id e9-20020a170906748900b007122a980d36mr3081577ejl.340.1655194023850; Tue, 14 Jun 2022 01:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655194023; cv=none; d=google.com; s=arc-20160816; b=qN7c73CTMn9HOejwNOo+czHvIAVAmX3bxc5+dCn7oJPJqInQ2D/O1tEP5bGCz8dfU7 sEimcmSJiW5aCzkpoegChJq3tnon7mS4Ixr0gyYAIDoYFpCHoZqDytardA6HhDM2hyqD U9d8UZrVN+r9zm9i7+yx+BMOIW//TYG8HU8MiWyz2zx6yvAMP6cunYZiudJ8PM5WoOg4 xLj1mLnpYNvUHCm09EQR6G+D01fVzCnH+j7d9yxvhtdLDNbz95toJB0tOGWLt5eevLpF 7RqoOe0mSaauAgEGc4irHvzIoa0wEzBTfd0F2UDJrYefmZYmIZRDdgGtGXYbuLEp7d/Q v+FQ== 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:dkim-signature; bh=8YbqEbtpAgz34dYZpysFCmcEBViD5KRxpznNht5WRzY=; b=lM86CqUejIJIqA0MMyhk667OvEB3A/h/2ZHPj+cdD4nA6lTH+CU6KRZja1JU0+LsIl Vwd8pAFIThGh6t9aKyayV1q+fk0x0jmCNPmTbKgEraIYcQFP2qYrtb9dYGguPfaBCueq ZX2RlVtdyqIaKgy1vaxdvk/VoCKDjqQbSCFxlWcrQy7JXaaN3MV5/Sch7WBhNdboM+V4 O1BF6wM8iBgJ/E4ZCcSW9Mu/BIRXdRQvR6EEA4XOzZmOoW5BkbjfVs61NgqHxwdK9w8U BkIcQsg4LHu2CuJSSVlrFTMizff71ZgzMN48qC5noH/v+U/tIRV70ug30Z522Dkhqr+S Nv8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=agvGbtTH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a1709063f4400b006ff21423705si9203994ejj.323.2022.06.14.01.06.36; Tue, 14 Jun 2022 01:07:03 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=agvGbtTH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354716AbiFNHgP (ORCPT + 99 others); Tue, 14 Jun 2022 03:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239058AbiFNHgM (ORCPT ); Tue, 14 Jun 2022 03:36:12 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92BD83DA70; Tue, 14 Jun 2022 00:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655192171; x=1686728171; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bMs/9D+S33oJTwrcpL/K+zJElMRWgWh3nH1VpfsRUBo=; b=agvGbtTH/W9qQatP05JR26bOybHb5nKPbmhT1d+U3YVnDsAO1U1zrLZf +CXVHurmiPpM7K96NPyDGOZvZKOdal3i66YODpHvHs8Zxqs5d+6I6/NVr 1dfqCD10ln52D5o54KAkMi0eTRj7T9zBZq/wXKFCCrPOhpRdZfKypo4hm moVJscWZI+G6SnM4K5T3T/N/v+sVA+UgoBhycn2mgAVCBkyiMiic0jujn 3yY5aLhMZs3zwyMT1rdliNdXRLn6qWTamX6jIUfNclpDN3fUZzA6bLb0R L5RS5CknZKTQKXLaUy8kDsYqdUNdlRAT06OU4LVIhCUcdBCYhE695di8s Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10377"; a="342505514" X-IronPort-AV: E=Sophos;i="5.91,299,1647327600"; d="scan'208";a="342505514" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 00:36:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,299,1647327600"; d="scan'208";a="726692745" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 14 Jun 2022 00:36:06 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 14 Jun 2022 10:36:05 +0300 Date: Tue, 14 Jun 2022 10:36:05 +0300 From: Heikki Krogerus To: "Rafael J. Wysocki" Cc: Linux ACPI , LKML , Linux PM , Andy Shevchenko , Mika Westerberg , Hans de Goede , Sakari Ailus , Andreas Noever , Michael Jamet , Yehezkel Bernat , linux-usb@vger.kernel.org Subject: Re: [PATCH v2 04/16] thunderbolt: ACPI: Replace tb_acpi_find_port() with acpi_find_child_by_adr() Message-ID: References: <1843211.tdWV9SEqCh@kreacher> <2653857.mvXUDI8C0e@kreacher> <2851774.e9J7NaK4W3@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2851774.e9J7NaK4W3@kreacher> X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Jun 13, 2022 at 08:11:36PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Use acpi_find_child_by_adr() to find the child matching a given bus > address instead of tb_acpi_find_port() that walks the list of children > of an ACPI device directly for this purpose and drop the latter. > > Apart from simplifying the code, this will help to eliminate the > children list head from struct acpi_device as it is redundant and it > is used in questionable ways in some places (in particular, locking is > needed for walking the list pointed to it safely, but it is often > missing). > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Heikki Krogerus > --- > > v1 -> v2: > * Drop tb_acpi_find_port() (Heikki, Andy). > * Change the subject accordingly > > --- > drivers/thunderbolt/acpi.c | 27 ++++----------------------- > 1 file changed, 4 insertions(+), 23 deletions(-) > > Index: linux-pm/drivers/thunderbolt/acpi.c > =================================================================== > --- linux-pm.orig/drivers/thunderbolt/acpi.c > +++ linux-pm/drivers/thunderbolt/acpi.c > @@ -301,26 +301,6 @@ static bool tb_acpi_bus_match(struct dev > return tb_is_switch(dev) || tb_is_usb4_port_device(dev); > } > > -static struct acpi_device *tb_acpi_find_port(struct acpi_device *adev, > - const struct tb_port *port) > -{ > - struct acpi_device *port_adev; > - > - if (!adev) > - return NULL; > - > - /* > - * Device routers exists under the downstream facing USB4 port > - * of the parent router. Their _ADR is always 0. > - */ > - list_for_each_entry(port_adev, &adev->children, node) { > - if (acpi_device_adr(port_adev) == port->port) > - return port_adev; > - } > - > - return NULL; > -} > - > static struct acpi_device *tb_acpi_switch_find_companion(struct tb_switch *sw) > { > struct acpi_device *adev = NULL; > @@ -331,7 +311,8 @@ static struct acpi_device *tb_acpi_switc > struct tb_port *port = tb_port_at(tb_route(sw), parent_sw); > struct acpi_device *port_adev; > > - port_adev = tb_acpi_find_port(ACPI_COMPANION(&parent_sw->dev), port); > + port_adev = acpi_find_child_by_adr(ACPI_COMPANION(&parent_sw->dev), > + port->port); > if (port_adev) > adev = acpi_find_child_device(port_adev, 0, false); > } else { > @@ -364,8 +345,8 @@ static struct acpi_device *tb_acpi_find_ > if (tb_is_switch(dev)) > return tb_acpi_switch_find_companion(tb_to_switch(dev)); > else if (tb_is_usb4_port_device(dev)) > - return tb_acpi_find_port(ACPI_COMPANION(dev->parent), > - tb_to_usb4_port_device(dev)->port); > + return acpi_find_child_by_adr(ACPI_COMPANION(dev->parent), > + tb_to_usb4_port_device(dev)->port->port); > return NULL; > } > > > -- heikki