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 6D3BDC678DB for ; Sat, 4 Mar 2023 20:47:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 331C685A5F; Sat, 4 Mar 2023 21:47:05 +0100 (CET) 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="pjG7wEEI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="heU1zKRF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09737859A9; Sat, 4 Mar 2023 21:47:04 +0100 (CET) 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 72559859A9 for ; Sat, 4 Mar 2023 21:47:01 +0100 (CET) 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 43AF021E83; Sat, 4 Mar 2023 20:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1677962821; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wBjeNBx5ue6opXr4LFJfsUjks3/Cl2VPjrpPWbD4Am0=; b=pjG7wEEId1hW5BRvJaDWPfLZTyo8J0W3Z9q+V0HF5hXY2XH0+2XNoSE28IDQB8Ip5P2Xmg 8/ORkrqFPwL94LpcY/1KHwuTUJgSd/vXkoLuPVKJS0QLskTxjDbePnc6/B6DNX5sYXlGEi C4bmlCBX4ta23gc17g3z9STzvnjc26E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1677962821; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wBjeNBx5ue6opXr4LFJfsUjks3/Cl2VPjrpPWbD4Am0=; b=heU1zKRFHq5K/J9lYjbT7n3OXv1xhCext1Vof19BehEWli/NqZqgNWaACWJzB/RP0X2jlB Tr2+dzpPKIA+z6Bg== 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 07A5F2C141; Sat, 4 Mar 2023 20:47:01 +0000 (UTC) Date: Sat, 4 Mar 2023 21:46:59 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Samuel Holland Cc: Lukasz Majewski , Sean Anderson , Simon Glass , Dario Binacchi , Jean-Jacques Hiblot , Neil Armstrong , Peng Fan , u-boot@lists.denx.de Subject: Re: [PATCH 3/6] clk: Fix error handling in clk_get_parent() Message-ID: <20230304204659.GK19419@kitsune.suse.cz> References: <20230220055940.41890-1-samuel@sholland.org> <20230220055940.41890-4-samuel@sholland.org> <20230220103922.GI19419@kitsune.suse.cz> <833442aa-f3c2-7f67-985d-a47184d01880@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <833442aa-f3c2-7f67-985d-a47184d01880@sholland.org> 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 Sat, Mar 04, 2023 at 01:58:17PM -0600, Samuel Holland wrote: > On 2/20/23 04:39, Michal Suchánek wrote: > > On Sun, Feb 19, 2023 at 11:59:36PM -0600, Samuel Holland wrote: > >> Do not return both NULL and error pointers. The function is only > >> documented as returning error pointers. > >> > >> Fixes: 8a1661f20e6c ("drivers: clk: Handle gracefully NULL pointers") > >> Signed-off-by: Samuel Holland > >> --- > >> > >> drivers/clk/clk-uclass.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c > >> index 78299dbceb2..5bce976b060 100644 > >> --- a/drivers/clk/clk-uclass.c > >> +++ b/drivers/clk/clk-uclass.c > >> @@ -490,7 +490,7 @@ struct clk *clk_get_parent(struct clk *clk) > >> > >> debug("%s(clk=%p)\n", __func__, clk); > >> if (!clk_valid(clk)) > >> - return NULL; > >> + return ERR_PTR(-ENODEV); > >> > >> pdev = dev_get_parent(clk->dev); > >> if (!pdev) > > > > Do we really need this? > > > > Who cares about the distinction? > > > > Just returning NULL on any error makes the code so much simpler and > > easier to understand. > > I'm fine with returning only NULL, or only ERR_PTR(-ENODEV) as done > later in the function, but returning both makes the error handling in > callers more complicated for no benefit. It sounds like you would prefer > I change the later ERR_PTR(-ENODEV) to NULL instead of this change? I > can do that for v2. I think NULL is easier to check, and so long as there is no meaningful distinction between ERR_PTR and NULL we should converge towards NULL as the single error return value. Thanks Michal