Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3460722pxb; Mon, 30 Aug 2021 02:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvCyZg0RBCRP9K4Etg1oVVJKnH1is0Sw9lg4yUfc8NiyeAoQ6GmeWwEZy18boFF2TwRUWX X-Received: by 2002:a92:7a11:: with SMTP id v17mr15769499ilc.217.1630317081935; Mon, 30 Aug 2021 02:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630317081; cv=none; d=google.com; s=arc-20160816; b=SZWgRpF2O94b9NZtlJnnk9kuZZ7Cmrs+ssSKgFMQ3hgB7hp8uew3XgDdAb5+b9w4pP 4nORNnqT+T/pKdwcE3NQ3B0Xvf8MDo9+P045yR/xFbnVD/7DYC2rSJgbCyJPQchCBNNV d46ZB8INF3MDlmd9wJwf1hXEjdVNCCsgMC4odJTlN9OKAZ6zWND8qmZUFhrybDgvS8pZ KY9wt9S04SPB8MZunNy7FpeaPusebua4KXyxHtF7nslOm1B26idDHWF5Q+CtcNSQvHMe sHDZfMfwYm/KOuNHoePGLekLjLWRlHzgb51be1z9qFe4WHGtwlWhEH8mhpXtiMCwl1sV vAhw== 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; bh=Zralfx0m0ZZz9bjh7i6RSHYpuVWwp2bMsF+W6vwX9fo=; b=Ne3qOKZ0srVm/XGoUM02pzcEUF5FGsPApkSyBWKD6po+QKRNolUoumjsgrTtyCYIIO MVMLgAzfNKuIWR1OfI9gVWQQZXXh53RS2II5/WiqWRJpIwmaM4vQzMvdc0YmcEb2xcHH tYqW1Qlx9s/ee7acIuXq4EDutpEmi81psXa6c/Y5pZvG/PSFcZ3xz1y2vLZIB/cNu+KY kVIlFHBjAnXqKb6Zb5iSpuJVLM8axhXgAEJc/JL1EUNMW1eK9sKQP6pg/9QaiQSOG8Zv fp00qHT2mH7aR3UN/tcKbmH/ERST7ZePK/XNc43MiA3+tmPA8SPLaY3L1GIw6FpTTYGt c3LQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k22si15809639jak.36.2021.08.30.02.51.11; Mon, 30 Aug 2021 02:51:21 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236288AbhH3JuA (ORCPT + 99 others); Mon, 30 Aug 2021 05:50:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:45894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236269AbhH3Jt7 (ORCPT ); Mon, 30 Aug 2021 05:49:59 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7F406103D; Mon, 30 Aug 2021 09:49:01 +0000 (UTC) Date: Mon, 30 Aug 2021 10:52:13 +0100 From: Jonathan Cameron To: Billy Tsai Cc: "lars@metafoo.de" , "pmeerw@pmeerw.net" , "robh+dt@kernel.org" , "joel@jms.id.au" , "andrew@aj.id.au" , "p.zabel@pengutronix.de" , "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" , BMC-SW Subject: Re: [RESEND v4 12/15] iio: adc: aspeed: Add func to set sampling rate. Message-ID: <20210830105213.25ee20a2@jic23-huawei> In-Reply-To: References: <20210824091243.9393-1-billy_tsai@aspeedtech.com> <202108250003.17P03KRU092474@twspam01.aspeedtech.com> <20210829163659.2f7f5974@jic23-huawei> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Aug 2021 08:35:53 +0000 Billy Tsai wrote: > Hi Jonathan, > > On 2021/8/29, 11:33 PM, "Jonathan Cameron" wrote: > > On Tue, 24 Aug 2021 17:12:40 +0800 > Billy Tsai wrote: > > >> Add the function to set the sampling rate and keep the sampling period > >> for a driver used to wait the lastest value. > >> > >> Signed-off-by: Billy Tsai > > > Why move the code as well as factoring out the setter function? > > I doubt it does any harm, but I'd like to understand why you did it. > > > Jonathan > > >> + ret = clk_prepare_enable(data->clk_scaler->clk); > >> + if (ret) > >> + return ret; > >> + > >> + ret = devm_add_action_or_reset(data->dev, > >> + aspeed_adc_clk_disable_unprepare, > >> + data->clk_scaler->clk); > >> + if (ret) > >> + return ret; > >> + > >> + ret = aspeed_adc_set_sampling_rate(indio_dev, ASPEED_ADC_DEF_SAMPLING_RATE); > >> + if (ret) > >> + return ret; > >> + > >> ret = aspeed_adc_vref_config(indio_dev); > >> if (ret) > >> return ret; > >> @@ -413,16 +445,6 @@ static int aspeed_adc_probe(struct platform_device *pdev) > >> } > >> > >> /* Start all channels in normal mode. */ > > > Why move this code up? > > Because the ADC clock is required when initializing the ADC device. > In our system, the clock is always on. Thus, the legacy driver won't encounter any issues. > I move the clk_prepare_enable ahead of initializing phase for making the driver probe logically closer to the hardware. Thanks. Please add something to the patch description to say this. Jonathan > > >> - ret = clk_prepare_enable(data->clk_scaler->clk); > >> - if (ret) > >> - return ret; > >> - > >> - ret = devm_add_action_or_reset(data->dev, > >> - aspeed_adc_clk_disable_unprepare, > >> - data->clk_scaler->clk); > >> - if (ret) > >> - return ret; > >> - > >> adc_engine_control_reg_val = > >> readl(data->base + ASPEED_REG_ENGINE_CONTROL); > >> adc_engine_control_reg_val |= > > > Best Regards, > Billy Tsai >