Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp624203iol; Thu, 9 Jun 2022 10:18:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwtE516YEvwrpSQqWqMIJbWueejJdk1OfoOMs5RwqnUdZXgYnP2gm1EWaIVTOGEX+TGwko X-Received: by 2002:a17:902:d18c:b0:167:82d5:4710 with SMTP id m12-20020a170902d18c00b0016782d54710mr20338022plb.25.1654795102946; Thu, 09 Jun 2022 10:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654795102; cv=none; d=google.com; s=arc-20160816; b=w4rE04UWL6BPJEsNWaomNBP3Nz5aXLPYlIAoH9wIjgppHS1swFz2ZfFYqnWIP3uQ2T mrCXIORUWvR0U49DM1dhsM1RVX5NRdY+QqNK77+eYWzSMTcjFqrHHiJMVma68nizVmJK i/2XBV6X/qDrfJSdq5s4nhSkSqw2oJVQEFpnH2UmhykyH1+uMlPtcVfShQqw9cTfPHaE b6nhhQbDjQ6OAjHNjmUKqZ/L/3IgGjWMzY+vdvF/bgTfWys3/+9NayBnge2iwOM2h7kj pf7rCP7UbY99VUTVCNQC58nzjJ+EweEfhk061Ox2ChLgQu0Xi3xQQdJ5MdyX1Vrkjsx2 50MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=gkr4kpyjyxhytcYi9ZJbG4/P8VjvDKac01TatzKEEwk=; b=w/puBFgwUQmCgnBP2D4vounldfmCYNCunCVjntYnlSKXv9coTwjZpm4KwmGjul6fFi P5fWQixK52EJS47oElzGt2BgK591a1Q8v8TmskgYJaKb93Wetla1D5qZgKhGDTL7vMQy mL1gI7240aXjDGOHH2Nq4p0YPn/1ibb/GPXUlabluTWGpRzVchNRruDxBzlOV04JnCTO t4HYHUMctQjaFbSG7EdRN1tmInFEEOMEa64z9uPqQ9n7RAgog2aQUO226PIdV3Euo7zM kU+Vgu+rTxujC6TiPGJyDbP445KmtRo/A4C+cV0d+OqAJb20CXcU/H2WO44f4lybKWQI SgIw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt6-20020a17090afa4600b001d6d8ba05a5si29845723pjb.125.2022.06.09.10.18.04; Thu, 09 Jun 2022 10:18:22 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238013AbiFIQN3 (ORCPT + 99 others); Thu, 9 Jun 2022 12:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343941AbiFIQNY (ORCPT ); Thu, 9 Jun 2022 12:13:24 -0400 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC8031C176; Thu, 9 Jun 2022 09:13:23 -0700 (PDT) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-3137c877092so46231057b3.13; Thu, 09 Jun 2022 09:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gkr4kpyjyxhytcYi9ZJbG4/P8VjvDKac01TatzKEEwk=; b=fNcsYxJ5RMwSY2iZ85Jjh3W66a/UG7RxnFNSrEh8iYPubAh7ZanqPc/HZbTdbkaoq4 1rLSAxKDDUN52h9eECVIPDXumZkeEkmS4P+NadwKVi1adadxkRL9UxpXAZtGLtpCi8aa XIG5dAq/MmZAj1cqPHPnWDUWHf7+LRaMXVs8uhtfFRS3BNwegrRHse6FRTzj6h6IMwke 1XI4mfQKzHzg9WQzSrUmWMA/jIqjc6APzSLY39QsApNXmhPTvjo7hCd8gXAjVUh81MoN 4HK+GIR7UpVElHOTGBvI61VduB8i+xrM8N26PcUu9M850LbfqNLgsFCdCJhrl6l/mBgr H0uw== X-Gm-Message-State: AOAM531+JiPx3rSwjMIXIzXflmwGGJ04dJkdsBi9pVer1AQ9fUaW5Yyf 4pT7H5vigUpMGSOoCTbMgKqBgljRjihraqIujlw= X-Received: by 2002:a0d:c442:0:b0:2fe:beab:1fef with SMTP id g63-20020a0dc442000000b002febeab1fefmr44227485ywd.196.1654791202217; Thu, 09 Jun 2022 09:13:22 -0700 (PDT) MIME-Version: 1.0 References: <1843211.tdWV9SEqCh@kreacher> <5296779.Sb9uPGUboI@kreacher> <63d7f3ed-b5a9-c869-5d25-a33a1d4e63c8@linux.intel.com> In-Reply-To: <63d7f3ed-b5a9-c869-5d25-a33a1d4e63c8@linux.intel.com> From: "Rafael J. Wysocki" Date: Thu, 9 Jun 2022 18:13:11 +0200 Message-ID: Subject: Re: [PATCH v1 14/16] soundwire: Use acpi_dev_for_each_child() To: Pierre-Louis Bossart Cc: "Rafael J. Wysocki" , Linux ACPI , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Linux PM , Bard Liao , LKML , Hans de Goede , Vinod Koul , Sakari Ailus , Sanyog Kale , Andy Shevchenko , Mika Westerberg Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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, Jun 9, 2022 at 5:23 PM Pierre-Louis Bossart wrote: > > Thanks Rafael. This looks mostly good but I have a doubt on the error > handling, see below. > > > +static int sdw_acpi_check_duplicate(struct acpi_device *adev, void *data) > > +{ > > + struct sdw_acpi_child_walk_data *cwd = data; > > + struct sdw_bus *bus = cwd->bus; > > + struct sdw_slave_id id; > > + > > + if (adev == cwd->adev) > > + return 0; > > + > > + if (!find_slave(bus, adev, &id)) > > + return 0; > > + > > + if (cwd->id.sdw_version != id.sdw_version || cwd->id.mfg_id != id.mfg_id || > > + cwd->id.part_id != id.part_id || cwd->id.class_id != id.class_id) > > + return 0; > > + > > + if (cwd->id.unique_id != id.unique_id) { > > + dev_dbg(bus->dev, > > + "Valid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", > > + cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, > > + cwd->id.part_id); > > + cwd->ignore_unique_id = false; > > + return 0; > > + } > > + > > + dev_err(bus->dev, > > + "Invalid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", > > + cwd->id.unique_id, id.unique_id, cwd->id.mfg_id, cwd->id.part_id); > > + return -ENODEV; > > if this error happens, I would guess it's reported .... > > > +} > > + > > +static int sdw_acpi_find_one(struct acpi_device *adev, void *data) > > +{ > > + struct sdw_bus *bus = data; > > + struct sdw_acpi_child_walk_data cwd = { > > + .bus = bus, > > + .adev = adev, > > + .ignore_unique_id = true, > > + }; > > + int ret; > > + > > + if (!find_slave(bus, adev, &cwd.id)) > > + return 0; > > + > > + /* Brute-force O(N^2) search for duplicates. */ > > + ret = acpi_dev_for_each_child(ACPI_COMPANION(bus->dev), > > + sdw_acpi_check_duplicate, &cwd); > > + if (ret) > > + return ret; > > ... here, but I don't see this being propagated further... > > > + > > + if (cwd.ignore_unique_id) > > + cwd.id.unique_id = SDW_IGNORED_UNIQUE_ID; > > + > > + /* Ignore errors and continue. */ > > + sdw_slave_add(bus, &cwd.id, acpi_fwnode_handle(adev)); > > + return 0; > > +} > > + > > /* > > * sdw_acpi_find_slaves() - Find Slave devices in Master ACPI node > > * @bus: SDW bus instance > > @@ -135,8 +200,7 @@ static bool find_slave(struct sdw_bus *b > > */ > > int sdw_acpi_find_slaves(struct sdw_bus *bus) > > { > > - struct acpi_device *adev, *parent; > > - struct acpi_device *adev2, *parent2; > > + struct acpi_device *parent; > > > > parent = ACPI_COMPANION(bus->dev); > > if (!parent) { > > @@ -144,52 +208,7 @@ int sdw_acpi_find_slaves(struct sdw_bus > > return -ENODEV; > > } > > > > - list_for_each_entry(adev, &parent->children, node) { > > - struct sdw_slave_id id; > > - struct sdw_slave_id id2; > > - bool ignore_unique_id = true; > > - > > - if (!find_slave(bus, adev, &id)) > > - continue; > > - > > - /* brute-force O(N^2) search for duplicates */ > > - parent2 = parent; > > - list_for_each_entry(adev2, &parent2->children, node) { > > - > > - if (adev == adev2) > > - continue; > > - > > - if (!find_slave(bus, adev2, &id2)) > > - continue; > > - > > - if (id.sdw_version != id2.sdw_version || > > - id.mfg_id != id2.mfg_id || > > - id.part_id != id2.part_id || > > - id.class_id != id2.class_id) > > - continue; > > - > > - if (id.unique_id != id2.unique_id) { > > - dev_dbg(bus->dev, > > - "Valid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", > > - id.unique_id, id2.unique_id, id.mfg_id, id.part_id); > > - ignore_unique_id = false; > > - } else { > > - dev_err(bus->dev, > > - "Invalid unique IDs 0x%x 0x%x for Slave mfg_id 0x%04x, part_id 0x%04x\n", > > - id.unique_id, id2.unique_id, id.mfg_id, id.part_id); > > - return -ENODEV; > > - } > > - } > > - > > - if (ignore_unique_id) > > - id.unique_id = SDW_IGNORED_UNIQUE_ID; > > - > > - /* > > - * don't error check for sdw_slave_add as we want to continue > > - * adding Slaves > > - */ > > - sdw_slave_add(bus, &id, acpi_fwnode_handle(adev)); > > - } > > + acpi_dev_for_each_child(parent, sdw_acpi_find_one, bus); > > ... here? > > It looks like a change in the error handling flow where > sdw_acpi_find_slaves() is now returning 0 (success) always? > > Shouldn't the return of sdw_acpi_find_one() be trapped, e.g. with > > return acpi_dev_for_each_child(parent, sdw_acpi_find_one, bus); Sure, I'll do that. Thanks!