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 D3732C19F21 for ; Thu, 4 Aug 2022 19:36:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89884845F6; Thu, 4 Aug 2022 21:36:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de 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=suse.de header.i=@suse.de header.b="qV/5I/Ot"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SYFmzG6w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1936284837; Thu, 4 Aug 2022 21:36:52 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AFDD5845F6 for ; Thu, 4 Aug 2022 21:36:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 75D7D34498; Thu, 4 Aug 2022 19:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1659641808; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gCBLcSmIDlCZtyS06ogiCLuWNbEhdimfcIAs4Va3cEk=; b=qV/5I/OtRaPDt4tiXMhnpJS/sntpwuy5P3oojdY4/NFBi5bEWA775qfjHFQLcJ+/YSlJgq f5gpaLZlEf6+3W8wkTX/ks46WcSjsmPeNr8/beWsM2fIvOGKQ0wYNZjLbEbFpMQ/LdRipK cSc+DyQIhyjlPbn92eoa/Hne2GGzTGc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1659641808; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gCBLcSmIDlCZtyS06ogiCLuWNbEhdimfcIAs4Va3cEk=; b=SYFmzG6wgt3CyxLvIdJdhGpm2fBKouPJOvdYjKkuNmVMJeOMGgSCFKFM1da1NbM8inrR6i hw7ldWE5/9j72kAA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 56D9A2C141; Thu, 4 Aug 2022 19:36:48 +0000 (UTC) Date: Thu, 4 Aug 2022 21:36:47 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Simon Glass Cc: U-Boot Mailing List , Viktor =?utf-8?B?S8WZaXbDoWs=?= , Tomas Hlavacek , Marek Vasut , Pavel Herrmann Subject: Re: [PATCH] dm: core: Do not stop uclass iteration on error. Message-ID: <20220804193647.GF17705@kitsune.suse.cz> References: <20220804175944.4130-1-msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Hello, On Thu, Aug 04, 2022 at 01:22:57PM -0600, Simon Glass wrote: > Hi Michal, > > On Thu, 4 Aug 2022 at 11:59, Michal Suchanek wrote: > > > > When probing a device fails NULL pointer is returned, and other devices > > cannot be iterated. Skip to next device on error instead. > > > > Fixes: 6494d708bf ("dm: Add base driver model support") > > Signed-off-by: Michal Suchanek > > --- > > drivers/core/uclass.c | 30 +++++++++++++++++++++--------- > > 1 file changed, 21 insertions(+), 9 deletions(-) > > Are you able to create a test for this, e.g. in test/dm/core.c or test-fdt.c ? > > Some sandbox devices can be made to give an error, so the test can > check the logic. > > Strangely enough, this is actually a very big change, so we need to be careful. Right, I can have a look at doing some tests. Knowing what the problem is designig a test should not be too difficult. It does not make the change any smaller but it can at least prevent regressions. Not sure when I get to it, though. Thanks Michal > > > > > diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c > > index 08d9ed82de..ccf7d59141 100644 > > --- a/drivers/core/uclass.c > > +++ b/drivers/core/uclass.c > > @@ -574,16 +574,31 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, > > } > > #endif > > > > +/* Starting from the given device return first device in the uclass that probes successfully */ > > +static int __uclass_next_device(struct udevice *dev, int ret, struct udevice **devp) > > +{ > > + if (!dev) { > > + *devp = dev; > > + return 0; > > + } > > + while ((ret = uclass_get_device_tail(dev, ret, devp))) { > > + ret = uclass_find_next_device(&dev); > > + if (!dev) { > > + *devp = dev; > > + return 0; > > + } > > + } > > + > > + return ret; > > +} > > + > > int uclass_first_device(enum uclass_id id, struct udevice **devp) > > { > > - struct udevice *dev; > > + struct udevice *dev = NULL; > > int ret; > > > > - *devp = NULL; > > ret = uclass_find_first_device(id, &dev); > > - if (!dev) > > - return 0; > > - return uclass_get_device_tail(dev, ret, devp); > > + return __uclass_next_device(dev, ret, devp); > > } > > > > int uclass_first_device_err(enum uclass_id id, struct udevice **devp) > > @@ -604,11 +619,8 @@ int uclass_next_device(struct udevice **devp) > > struct udevice *dev = *devp; > > int ret; > > > > - *devp = NULL; > > ret = uclass_find_next_device(&dev); > > - if (!dev) > > - return 0; > > - return uclass_get_device_tail(dev, ret, devp); > > + return __uclass_next_device(dev, ret, devp); > > } > > > > int uclass_next_device_err(struct udevice **devp) > > -- > > 2.37.1 > > > > Regards, > Simon