Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp930705rwd; Sat, 20 May 2023 09:10:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62MIEaY7sheYF+tCt3Z9iY258GZSrWoZW7neJ5AN32vKC5VxqTYF9htOxKVFp8IPTLhzjS X-Received: by 2002:a05:6a20:72a0:b0:100:a201:83dc with SMTP id o32-20020a056a2072a000b00100a20183dcmr6367427pzk.35.1684599010894; Sat, 20 May 2023 09:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684599010; cv=none; d=google.com; s=arc-20160816; b=dmNrNf9NcBWvldIVXXoA6a9hRx2VnQ10sDTeLPNLJV0bmZdEJ8mV6IlIHNT8+iytbG z7gE1eQLNPj6YtIuFaUozXFti2yUGsPYp3hq2bKTpeeAFxqQCbPA+ObJrh9VcEcWyQzF LuFipo3BTtLtlPrpdsfTuk5XCxHa3P2HIBJhZcYFc+WXsnf6IddNz0/lfd2GYi3I+qDo h6VjUEehbHi+70A/LonXLs948lHIdfMyg54q3sNA+vQJ+oEpDoP7ZxC8t7ESMTRvirB3 SVPquexTlvoCdyfPGIgHSLkObEvxND58Z+R9ttUDSI3fT96yx+etjpDlnbJVAL+KStsi 8lfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=lG6hK8eGsW6zEuGOWbtiKjUK/YZ3nRewgUYE44c9bkg=; b=CLAvVmAhCR7YqMbOHDGPDGa0kr5M+Qh8ORhZgghki4vDK0TK6LoXz+1WWOMINBs5+Y 7cGCMc0GF2chxVUqbp759TqgLxIio2dGpr72UdxwtM1Buj6khFXqvcLuoL/phpV5DbAH WM/RC9jX3SJ6I3X579tISYxhza3OyQwH09lyRPEXvI7PW/NEeUqn+I5PXkTSdZ3PbMjV EWzx3r14Q4wnq8mt/jFAoe1iAkZulQ10Jx4hj6N2p3jf23i//Jar1/cHHrCQ/0osuym+ I2MCSiVamLAhJ8/mtCTdL725V8gUHZUeT982f1bedOJRyQC9OD11BAgZTsGDm7chA3kZ XqaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=saGd+R5Y; 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 c30-20020a63725e000000b0053007fe33aasi1112474pgn.425.2023.05.20.09.09.56; Sat, 20 May 2023 09:10:10 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=saGd+R5Y; 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 S231784AbjETPda (ORCPT + 99 others); Sat, 20 May 2023 11:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbjETPd3 (ORCPT ); Sat, 20 May 2023 11:33:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3CD103; Sat, 20 May 2023 08:33:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C51D860B04; Sat, 20 May 2023 15:33:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90740C433D2; Sat, 20 May 2023 15:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684596807; bh=v2J4QcmeQzjUO1CUDFFKdSrX6QMMRgCiCMtenkolPlU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=saGd+R5YIQWo5HvkhlsM7ywmRukcLhf2Kgb3vtXaUdjya86Ia9ulrRP1ID2G0lpwp jehUTPp1qXNEbMKx7JiO6CykDrQ9H9M5VZ71ADjTAG+F4eUXuw/ap6KYpDWkfjBOMw KSPFG2/zqDGKLlBYCi0Hi6qCFSg3mTaJ6UeHvR8/KytNG7jC3eU8DZwW+9tu5+gRLN fmOsfadxDhg2lWgAfVNJwG2dvOMWjQXnLdVKqXueEq7KN73EzCTygK0zjvcTS+4O5i 1gqlyTL3zMgLkEV+tJGSAkWlCnzivD2vSi5GnZs6qqFSqOcTNBsSGhr1GS0Iq65zlN iZV2/2HrJVO9A== Date: Sat, 20 May 2023 16:49:35 +0100 From: Jonathan Cameron To: AngeloGioacchino Del Regno Cc: Shreeya Patel , lars@metafoo.de, heiko@sntech.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, sebastian.reichel@collabora.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, gustavo.padovan@collabora.com, serge.broslavsky@collabora.com Subject: Re: [PATCH 5/7] iio: adc: rockchip_saradc: Use dev_err_probe Message-ID: <20230520164935.70094206@jic23-huawei> In-Reply-To: References: <20230516230051.14846-1-shreeya.patel@collabora.com> <20230516230051.14846-6-shreeya.patel@collabora.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Wed, 17 May 2023 12:40:37 +0200 AngeloGioacchino Del Regno wrote: > Il 17/05/23 01:00, Shreeya Patel ha scritto: > > Use dev_err_probe instead of dev_err in probe function, > > which simplifies code a little bit and prints the error > > code. > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/iio/adc/rockchip_saradc.c | 45 ++++++++++++++----------------- > > 1 file changed, 20 insertions(+), 25 deletions(-) > > > > diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c > > index 5e1e8575bc76..a52021fd477d 100644 > > --- a/drivers/iio/adc/rockchip_saradc.c > > +++ b/drivers/iio/adc/rockchip_saradc.c > > ..snip.. > > > @@ -494,23 +492,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev) > > * This may become user-configurable in the future. > > */ > > ret = clk_set_rate(info->clk, info->data->clk_rate); > > - if (ret < 0) { > > - dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret); > > - return ret; > > - } > > + if (ret < 0) > > + return dev_err_probe(&pdev->dev, ret, > > + "failed to set adc clk rate\n"); > > > > ret = regulator_enable(info->vref); > > - if (ret < 0) { > > - dev_err(&pdev->dev, "failed to enable vref regulator\n"); > > - return ret; > > - } > > + if (ret < 0) > > + return dev_err_probe(&pdev->dev, ret, > > + "failed to enable vref regulator\n"); > > + > > ret = devm_add_action_or_reset(&pdev->dev, > > rockchip_saradc_regulator_disable, info); > > - if (ret) { > > - dev_err(&pdev->dev, "failed to register devm action, %d\n", > > - ret); > > - return ret; > > - } > > + if (ret) > > + return dev_err_probe(&pdev->dev, ret, > > + "failed to register devm action\n"); > > It's not your fault - and it's about a pre-existing issue, but there's that: > you're returning an error if devm_add_action_or_reset() fails (which is highly > unlikely), but you're leaving the regulator enabled! Which regulator? The _or_reset() part means that the callback is called if the devm_add_action_or_reset is going to return an error. So in the path you talk about rockchip_saradc_regulator_disable() is called and disables vref > > As for how to proceed here, I would suggest to fix this issue in a separated > commit (before the dev_err_probe() conversion); it'd look like... > > if (ret) { > regulator_disable(info->vref); > dev_err( .... blurb ); > return ret; > } > > and after the conversion it'd look like... > > if (ret) { > regulator_disable(info->vref); > return dev_err_probe( ... blurb ); > } > > Cheers, > Angelo > > > > > ret = regulator_get_voltage(info->vref); > > if (ret < 0) >