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 0D2CAC00140 for ; Thu, 18 Aug 2022 19:46:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8DD0F848CD; Thu, 18 Aug 2022 21:46:46 +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="BYTKSVF5"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Zu6n605/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B45BB84917; Thu, 18 Aug 2022 21:46:44 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 5634E8487B for ; Thu, 18 Aug 2022 21:46:42 +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-out2.suse.de (Postfix) with ESMTP id 20B645C30C; Thu, 18 Aug 2022 19:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1660852002; 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=u8nL4Ia+b7LPeLp2+5pl9Cy1H/SijlrsuCOYnPkiuBA=; b=BYTKSVF5aaOTGFk2hMGQimrDp4WsToWMuNhz5XQ+wO54Wt9zPFcJlbdCjLaXLGqSFTmzbS KC/cjqV52WXWPmZItb43aDvl9ddnF8bv/QBB/bM3CZgiAVGrRFEEw1UCR71RVaZC+yfHEn oHvBGhdmhP1f4PryXOCmI7jUsB7SmnY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1660852002; 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=u8nL4Ia+b7LPeLp2+5pl9Cy1H/SijlrsuCOYnPkiuBA=; b=Zu6n605/7f0yS50KkBOmf56/LP4w4B/bO4KcitZWTmORf9k247w+Yk6WysNniy5iZQQm9i Nu8pOqnrBT1P0iAg== 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 F08842C184; Thu, 18 Aug 2022 19:46:41 +0000 (UTC) Date: Thu, 18 Aug 2022 21:46:40 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Simon Glass Cc: U-Boot Mailing List , Tomas Hlavacek , Marek Vasut , Viktor =?utf-8?B?S8WZaXbDoWs=?= , Pavel Herrmann Subject: Re: [PATCH v2] dm: core: Do not stop uclass iteration on error. Message-ID: <20220818194640.GC28810@kitsune.suse.cz> References: <20220817082752.12160-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 On Thu, Aug 18, 2022 at 11:49:53AM -0600, Simon Glass wrote: > Hi Michal, > > On Wed, 17 Aug 2022 at 02:28, 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 > > --- > > v2: Fix up tests > > > > Note: there is seemingly bogus repeated device_remove(parent, > DM_REMOVE_NORMAL); > > but I have no idea what the intent was, and fixing that is out of the > > scope of this patch anyway. > > This is to remove child devices that have been probed, so that we get back > to the original state. Thanks, it makes sense now. > > > > drivers/core/uclass.c | 30 +++++++++++++++++++++--------- > > test/dm/test-fdt.c | 20 ++++++++++++++++---- > > 2 files changed, 37 insertions(+), 13 deletions(-) > > > > 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) > > Can you avoid __ as this is reserved for compiler. Perhaps use a single > underscore? > > Please check 80cols whatever > > +{ > > + if (!dev) { > > + *devp = dev; > > + return 0; > > + } > > Is this for people that call next after they shouldn't? This is for the case if there is nothing. > > + 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; > > Can you drop the NULL assignment? uclass_find_first_device() sets dev to > NULL anyway, as a first step. > > > int ret; > > > > - *devp = NULL; > > Is this safe to remove? If there is nothing, then it's the same as uclass_next_device() on the last device. > > > 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); > > } > > This is a major change in behaviour, so please do update the API docs at > dm/uclass.h Yes, those need updating as well. Thanks Michal