Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp90764iof; Sun, 5 Jun 2022 22:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5BQKOx+2rQv6EZHluyDERGQeOUEsVJg48N4/9R51h9NlJsf0RjNVcLRD3WVdLgpLirKHh X-Received: by 2002:a65:6093:0:b0:373:9c75:19ec with SMTP id t19-20020a656093000000b003739c7519ecmr20066234pgu.539.1654491871815; Sun, 05 Jun 2022 22:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491871; cv=none; d=google.com; s=arc-20160816; b=mHWjhHLpSNvZYFwDgX6xzLjWkaIcn8gb63AilqfZPounL6uPLAekZaSVfPNUhYhpCG PrpNK5g2/AYSuFUxnZjTwLnoQd4U7MAyE5Sm0EYFB1QIHSvbifMnoLmgnphdJVrf7rsh diVPMVTvtloK95zq/XivdhQuzkWouc4ZKlP6PeddoRVRNjRxeVXGLtNDQ9WMSqF2a7U2 tXzEp9Y9HI19TN5lrV6r+qECFB8eft5g0LsDb9magQ9mqD6jRYG75DYRVVUZVLhJaecp j2984fU0KIBh94BdoOj7BP6dpRIr47NqJgnS71m5BQHfAicDHRW6WF+G/XKvAJexUhEi ajeA== 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=+rNG0lHitVZbfH22Bef1a48ybomxxdFROuJ2GDuKmz8=; b=N+cwZUvDh0by2WPXOPRzsZZ2cF4zaCrdhS2MWuFMnxId99ylz4QZVO0wlpbQvQ2ChA PoGv9Cyb06MDf/9RLLAJkrLqConDSxHEGky+l3RTJIH7e3jvNiD+jVpwMV62jiB7cKZm n4ziVDhzOGHLs14TJQK355xrNKiOabDOg9ZJI18E36nmbfctJR8n43gLgDN8A57r/uJd BryOBcT7X2ec5Zr6zkE+Z9Is2QA4AkQeAfmYVGTOwN88zIEjFfvDFCCLMyVJV4yFOmXM h1zAPhG5MtfeEVwinwPD6nkGUcoyxAw2kcE0rMG2c1qBVSWQzczNmIOYAQArSMSaUb8e wMrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f2bcnq/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 19-20020a170902e9d300b00158c8203fdfsi18006058plk.12.2022.06.05.22.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="f2bcnq/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C2A5113F81; Sun, 5 Jun 2022 21:13:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344133AbiFCQyz (ORCPT + 99 others); Fri, 3 Jun 2022 12:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344127AbiFCQyv (ORCPT ); Fri, 3 Jun 2022 12:54:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3A19517FC; Fri, 3 Jun 2022 09:54:49 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7EDCBB823A5; Fri, 3 Jun 2022 16:54:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04EDAC385A9; Fri, 3 Jun 2022 16:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654275287; bh=nJDlaPVv1/V2QMFRZSMeGdjlbru3qoJgFHs4acH/VCI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f2bcnq/dtEyqSfGKM9xkhsnsX9DRvo6Ajnnglt+DUCZX/6Ns/LUk8f/rWz8OeSX2p d6PRpAZPCZvw8NeCY77evHvySMWc8ACGZccTLlMfPDrrcx9fTTCwxEwcnsXRwK9JpF gMcRCX+RUn67t5PojSNveufivxFXuNrNBbVq7gIfbUPBpnMOxbCw1E1Z7OPfeTHkHG IrBltCOd0fRZCb2sAz2TtA6cUf6xRzW3e2GSBcYAc7TqYBbopkCB8YP0HwNOHZhF0x T45IjVEmnD1ID5xH4uDJT+Dy+gxX5F2PPmXs3RvO2TatxN8HnPheCl/oigj3sTxCFf 1UYIwRiZ/3KPQ== Date: Fri, 3 Jun 2022 18:03:47 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: Jonathan Cameron , Cixi Geng , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen , Orson Zhai , Baolin Wang , Chunyan Zhang Subject: Re: [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract Message-ID: <20220603180347.2b0d0f08@jic23-huawei> In-Reply-To: <20220530180910.2533-1-andriy.shevchenko@linux.intel.com> References: <20220530180910.2533-1-andriy.shevchenko@linux.intel.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; 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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, 30 May 2022 21:09:10 +0300 Andy Shevchenko wrote: > Instead of custom data type re-use generic struct u32_fract. There isn't a custom data type - I'll reword this whilst applying if there is no reason for a v2. > No changes intended. functional changes > > Signed-off-by: Andy Shevchenko Given they have been active recently I'd ideally like Cixi Geng to take a quick glance at this before I apply it. Thanks, Jonathan > --- > drivers/iio/adc/sc27xx_adc.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > index e9ff2d6a8a57..f8421cbba8fa 100644 > --- a/drivers/iio/adc/sc27xx_adc.c > +++ b/drivers/iio/adc/sc27xx_adc.c > @@ -579,15 +579,14 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > return ret; > } > > -static void sc27xx_adc_volt_ratio(struct sc27xx_adc_data *data, > - int channel, int scale, > - u32 *div_numerator, u32 *div_denominator) > +static void sc27xx_adc_volt_ratio(struct sc27xx_adc_data *data, int channel, int scale, > + struct u32_fract *fract) > { > u32 ratio; > > ratio = data->var_data->get_ratio(channel, scale); > - *div_numerator = ratio >> SC27XX_RATIO_NUMERATOR_OFFSET; > - *div_denominator = ratio & SC27XX_RATIO_DENOMINATOR_MASK; > + fract->numerator = ratio >> SC27XX_RATIO_NUMERATOR_OFFSET; > + fract->denominator = ratio & SC27XX_RATIO_DENOMINATOR_MASK; > } > > static int adc_to_volt(struct sc27xx_adc_linear_graph *graph, > @@ -615,7 +614,7 @@ static int sc27xx_adc_to_volt(struct sc27xx_adc_linear_graph *graph, > static int sc27xx_adc_convert_volt(struct sc27xx_adc_data *data, int channel, > int scale, int raw_adc) > { > - u32 numerator, denominator; > + struct u32_fract fract; > u32 volt; > > /* > @@ -637,9 +636,9 @@ static int sc27xx_adc_convert_volt(struct sc27xx_adc_data *data, int channel, > break; > } > > - sc27xx_adc_volt_ratio(data, channel, scale, &numerator, &denominator); > + sc27xx_adc_volt_ratio(data, channel, scale, &fract); > > - return DIV_ROUND_CLOSEST(volt * denominator, numerator); > + return DIV_ROUND_CLOSEST(volt * fract.denominator, fract.numerator); > } > > static int sc27xx_adc_read_processed(struct sc27xx_adc_data *data,