From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9241C433FE for ; Thu, 29 Sep 2022 10:03:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A785784D69; Thu, 29 Sep 2022 12:02:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="N4zS5yw0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 30CEC84CA8; Thu, 29 Sep 2022 12:01:09 +0200 (CEST) Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4E26384CD1 for ; Thu, 29 Sep 2022 12:00:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-131a7bce1acso1212046fac.7 for ; Thu, 29 Sep 2022 03:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=GpG0iRUBct3PbTjo8ys/B313Z0O5XV1lGM5lvPUBaT0=; b=N4zS5yw0foEA7fzUqekk+YfzNgPnRM3foJQdEFwcqMXL+zDXaPy9Fea9LvGjSOxujH dyb6xa3NPpdy6b66doNrgkJNGfpv065QYrF5mbK+tPmVBM5DV2WQWAY63ba421L+sg1J MVJPul4Sprqenwu5onMNHLRI/fpjMy3C88yFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=GpG0iRUBct3PbTjo8ys/B313Z0O5XV1lGM5lvPUBaT0=; b=nTItoXx85qQLt9t0goGOLs0izTyUu4ryFKUanO9xNepRp9de2swWlWD7Rvlw+ZCbjp ZQ/wsncrFC7hSA6aE2dEmesRcd2yy+4z17xMgs74WduJo9VYAOVr+vg4v9kHw4JQozHr w/afoW4QLbeOddvnrH/p0S4WrCUEZIU7HtkG82FMMfYLWIqNkqhL+uj3eZwJjc02720H NYQxzfrOknrO6lwO047krnxzkwwyZ3nXyIA/lK9MP/AC7PNeWebNWuU0xi9ipnylmq9Z RPmQSslJiYC/rvKz4/zYNS0zyIYkbUyq5FrgyPNuJ2oWBvG4VYt+H1bQmvxwGLtchWbn +yDA== X-Gm-Message-State: ACrzQf2FicYlO8GPDBy0ebJ+PkKrPzAFM2SxVuu1zmFPZv92vaav27Tp WUpLhoJiNbE0nDYhd2xvBVwBKMOp+IbaGA70NDfjVg== X-Google-Smtp-Source: AMsMyM4mk/4sy85KJVZaUynWxn3bTmnc/o2yLO6qNwZRyV27sdcaVWrdsDCTL6WvjmAsLea3voh1Obx36gnTb6RyDtQ= X-Received: by 2002:a05:6870:390b:b0:127:42b1:e5d0 with SMTP id b11-20020a056870390b00b0012742b1e5d0mr1343454oap.64.1664445654366; Thu, 29 Sep 2022 03:00:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Simon Glass Date: Thu, 29 Sep 2022 04:00:37 -0600 Message-ID: Subject: Re: [PATCH v5 08/15] w1: Fix bus counting in w1_get_bus To: Michal Suchanek Cc: U-Boot Mailing List , Maxime Ripard , Eugen Hristev Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Tue, 27 Sept 2022 at 15:40, Michal Suchanek wrote: > > Use uclass_first_device_check/uclass_next_device_check to correctly > count buses that fail to probe. > > Fixes: d3e19cf919 ("w1: Add 1-Wire uclass") > Signed-off-by: Michal Suchanek > --- > drivers/w1/w1-uclass.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) Reviewed-by: Simon Glass although this is actually broken as it should use uclass_get_device_by_seq() for things that are numbered > > diff --git a/drivers/w1/w1-uclass.c b/drivers/w1/w1-uclass.c > index 52b519c21d..de4f25bcf9 100644 > --- a/drivers/w1/w1-uclass.c > +++ b/drivers/w1/w1-uclass.c > @@ -16,6 +16,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -182,24 +183,25 @@ static int w1_enumerate(struct udevice *bus) > int w1_get_bus(int busnum, struct udevice **busp) > { > int ret, i = 0; > - > struct udevice *dev; > > - for (ret = uclass_first_device(UCLASS_W1, &dev); > - dev && !ret; > - ret = uclass_next_device(&dev), i++) { > + for (ret = uclass_first_device_check(UCLASS_W1, &dev); > + dev; > + ret = uclass_next_device_check(&dev), i++) { > if (i == busnum) { > + if (ret) { > + debug("Cannot probe w1 bus %d: %d (%s)\n", > + busnum, ret, errno_str(ret)); > + return ret; > + } > *busp = dev; > return 0; > } > } > > - if (!ret) { > - debug("Cannot find w1 bus %d\n", busnum); > - ret = -ENODEV; > - } > + debug("Cannot find w1 bus %d\n", busnum); > > - return ret; > + return -ENODEV; > } > > u8 w1_get_device_family(struct udevice *dev) > -- > 2.37.3 >