Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4278851pxb; Tue, 31 Aug 2021 00:53:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDvWpOjQQbJVwp05+cHIFsaQHJGcqMAJGjbh34OHstfGImQl1/e6OhTisQu89SRMwg3HH3 X-Received: by 2002:a05:6e02:1d05:: with SMTP id i5mr9018296ila.245.1630396397299; Tue, 31 Aug 2021 00:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630396397; cv=none; d=google.com; s=arc-20160816; b=e8Dd3udygyw43b2rYqz9sDVDkjWXm3YPGMR5mccJkuU3m0w1DBPkBpy4HbmEJpY4cT vlfkbC90FRKhj9tjC4xz9v+KBS+xKnZ5SJ1LIqOq/YnKUHQnTy1BkcONKIyPLg+vfBwZ 4cTemIPnpMFFKFEnSKdzFLUt1/LSjICV19zWG2Dk7yjSvOGiBRvye2KxGPP8XObf/o8j 7ISWaIuk9fPbnRZqPBV1bBRnLA7T5e1IzAQHMysuCtauML3A/sEg3ULe8OeabwcdpV3z 3Q8khAefl3TICHZYfveFfXXON/aTWCKfLL/L5WrTuhOQIcNRGddCy49hRYJijVKTLI4Y P07Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=Fp7IvmH3Xfsr59aA81HAGklc64bN7o/rs8tkXRmY3J4=; b=hmml4eMIsVVMoPMqUt1BgNbgi3KIq77NSS+VpNW2+e93SmsaZJu5xlJbwF3WNJ0Wzu SGXPQRLBBAqpu6u5EEzGSUa8NdQGCRsonvbUIivdbGD6CWeL1yWrLTeh2RZuewzsT7LM FytWu6j/w06eACIyrGXYaWlrTAgLkeisprgcfAEFW/1sGDTGQCZ9sFl0N/H7GyUkKTL2 UDxuMaYrb4hjGfeR26LM53jC/NPtJUAu44E9HuezAiydvrIPJ4yG63wjKeaDeVJnVZz/ dO26WdN/7pZIcpztXZq07at8uzO/J2MzEBibDzm6fZ5FMjwtwM9fSkg5oXbD4knUPx6F MMBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si16108959ils.116.2021.08.31.00.53.05; Tue, 31 Aug 2021 00:53:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240041AbhHaHwp convert rfc822-to-8bit (ORCPT + 99 others); Tue, 31 Aug 2021 03:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239865AbhHaHwo (ORCPT ); Tue, 31 Aug 2021 03:52:44 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FCB7C061575 for ; Tue, 31 Aug 2021 00:51:50 -0700 (PDT) Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mKyYK-0005uf-BA; Tue, 31 Aug 2021 09:51:28 +0200 Received: from pza by lupine with local (Exim 4.92) (envelope-from ) id 1mKyYF-0002yy-JK; Tue, 31 Aug 2021 09:51:23 +0200 Message-ID: <4bc2bf196efd540933e6a781a44af20142e3d5d3.camel@pengutronix.de> Subject: Re: [v5 09/15] iio: adc: aspeed: Use devm_add_action_or_reset. From: Philipp Zabel To: Billy Tsai , jic23@kernel.org, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, joel@jms.id.au, andrew@aj.id.au, lgirdwood@gmail.com, broonie@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: BMC-SW@aspeedtech.com Date: Tue, 31 Aug 2021 09:51:23 +0200 In-Reply-To: <20210831071458.2334-10-billy_tsai@aspeedtech.com> References: <20210831071458.2334-1-billy_tsai@aspeedtech.com> <20210831071458.2334-10-billy_tsai@aspeedtech.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Billy, On Tue, 2021-08-31 at 15:14 +0800, Billy Tsai wrote: > This patch use devm_add_action_or_reset to handle the error in probe > phase. > > Signed-off-by: Billy Tsai > --- > drivers/iio/adc/aspeed_adc.c | 112 +++++++++++++++++++++-------------- > 1 file changed, 66 insertions(+), 46 deletions(-) > > diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c > index e53d1541ad1d..af00d9752c1e 100644 > --- a/drivers/iio/adc/aspeed_adc.c > +++ b/drivers/iio/adc/aspeed_adc.c [...] > @@ -242,6 +271,11 @@ static int aspeed_adc_probe(struct platform_device *pdev) > &data->clk_lock); > if (IS_ERR(data->clk_prescaler)) > return PTR_ERR(data->clk_prescaler); > + ret = devm_add_action_or_reset(data->dev, > + aspeed_adc_unregister_divider, > + data->clk_prescaler); > + if (ret) > + return ret; I think here you could switch to devm_clk_hw_register_divider() instead. > snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), > clk_name); > scaler_flags = CLK_SET_RATE_PARENT; > @@ -256,23 +290,30 @@ static int aspeed_adc_probe(struct platform_device *pdev) > &pdev->dev, clk_name, clk_parent_name, scaler_flags, > data->base + ASPEED_REG_CLOCK_CONTROL, 0, > data->model_data->scaler_bit_width, 0, &data->clk_lock); > - if (IS_ERR(data->clk_scaler)) { > - ret = PTR_ERR(data->clk_scaler); > - goto scaler_error; > - } > + if (IS_ERR(data->clk_scaler)) > + return PTR_ERR(data->clk_scaler); > + > + ret = devm_add_action_or_reset(data->dev, aspeed_adc_unregister_divider, > + data->clk_scaler); > + if (ret) > + return ret; Same as above. [...] > @@ -281,6 +322,10 @@ static int aspeed_adc_probe(struct platform_device *pdev) > ASPEED_ADC_ENGINE_ENABLE, > data->base + ASPEED_REG_ENGINE_CONTROL); > > + ret = devm_add_action_or_reset(data->dev, aspeed_adc_power_down, > + data); > + if (ret) > + return ret; > /* Wait for initial sequence complete. */ > ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL, > adc_engine_control_reg_val, [...] > @@ -303,6 +354,11 @@ static int aspeed_adc_probe(struct platform_device *pdev) > ASPEED_ADC_ENGINE_ENABLE; > writel(adc_engine_control_reg_val, > data->base + ASPEED_REG_ENGINE_CONTROL); > + ret = devm_add_action_or_reset(data->dev, > + aspeed_adc_power_down, > + data); > + if (ret) > + return ret; Should this be if (!model_dta->wait_init_sequence) ? Otherwise it looks like you've already registered the same aspeed_adc_power_down action above. regards Philipp