Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1114510iol; Sun, 12 Jun 2022 06:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKNbQlzwZf47xRrVo1OzVDV2hcYlA599cn5jJwlQBd1q1Ow6Z5teVhxw0XMGnInM1o1JIe X-Received: by 2002:a05:6402:1692:b0:42d:e291:67f3 with SMTP id a18-20020a056402169200b0042de29167f3mr59509736edv.392.1655040833154; Sun, 12 Jun 2022 06:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655040833; cv=none; d=google.com; s=arc-20160816; b=AlMHVySFwWHw+N99hsnry2OOXAZYmoByg2xGm839qawSMS0NshYuqcTqULgPx/CF7D F9EAcuBlmYcKO0gr9XtwSXYHcBrP/XLnwfmudX43FZVqAl2LJo2uO6YaC3oeqvYXdF/9 Ig46xyEycwPy1vQgMu0LqyY41BzdRJ/v87z0PQqM0WPvmP3ndRPrk1BUs3DHeJNb5Rkw AsbCWqYEHEAr7eGFkkgUx2vIbt6phWfX8RfmkG3jfQgJM8Hbe8yrdDZJuR6H0YMjkjQ0 H9GVMuCWjtNGAGs7Hx0it6PUk1RjqFg+V6309qL4EfwZZ3QHJvFgez/AIZ8LDSDSVJeW HDuQ== 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=TMef5HGCd1pGAPWMKGimS+Gh1eSMEGC+++3KVfnXNMg=; b=uaQmaI3r+YSzH7pNc5duBKwEUCVeTEmPQeBkIzuCkANDfWWC7RhDeNQs+ObVYwPbXU DGdL6BQPM2SZjmb6aEZCWjJeY+3x7puuFeuHNoQ7JAvTe3FlFVqj9eEAQjt/UMxU281S H4lUtLKVeZKj+c0WulkOhwCKVA+XdaX52eKLdXHyWvpudrM1UszU/xI4oBVvUg9PFHab GQXnEFiVYjyz808V6Lmolo/NUqaV3FeyQTrFLfeDixxDO5FfxXL0AsuH1vuNd/TEFJiU 7zAzvnCmgGGDM/aWKjDBEe7+nBVUoo8kP/JdeS1UHaBWkE44oOI2LHlz3bS/J6pF4FZi 2ZNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gr6stL0v; 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 qb27-20020a1709077e9b00b007136091f4a5si5579911ejc.929.2022.06.12.06.33.27; Sun, 12 Jun 2022 06:33:53 -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=Gr6stL0v; 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 S235170AbiFLJAA (ORCPT + 99 others); Sun, 12 Jun 2022 05:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235156AbiFLI77 (ORCPT ); Sun, 12 Jun 2022 04:59:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF6050003; Sun, 12 Jun 2022 01:59:57 -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 7D17AB80B49; Sun, 12 Jun 2022 08:59:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11EDBC34115; Sun, 12 Jun 2022 08:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655024395; bh=2uqxVJ6jg6AwdHG0+C7+HQBXmirKuPi56pYKZPGKkCU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Gr6stL0vss5dlzJyCOgtqr6VGyPaDsNrheFDEXSHs4p0Y/J51CfagmXK44//qr6DU pp3e8S/1AaBzYzeChlGrrUH1/YCxJ1kTIJG2Bau2VTAZRLfgISEEvcHjq62AUQLuif aDahCJU85DqqJ8YCKrZbLG6fzfXDLslBJz7rUv0JLavzErW48xbQF/mE/cZpZt6Y3L faECM0YTXIRSYqhUfaLwB+Glon1bsXQ2pTU7iJJK1wvTYFRZvb/PW4PVc0YEn4zaQm jrrnue0D2aYHK0Hk8gHvo8LQrTQEXoZ5Pivq5uioAo7f6QGUrJFMn+lyI8Mpxl084u DK8h2a1MntWFg== Date: Sun, 12 Jun 2022 10:08:54 +0100 From: Jonathan Cameron To: Cixi Geng Cc: Andy Shevchenko , 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: <20220612100854.22e2c441@jic23-huawei> In-Reply-To: References: <20220530180910.2533-1-andriy.shevchenko@linux.intel.com> <20220603180347.2b0d0f08@jic23-huawei> 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=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Mon, 6 Jun 2022 11:12:15 +0800 Cixi Geng wrote: > Jonathan Cameron =E4=BA=8E2022=E5=B9=B46=E6=9C=884=E6= =97=A5=E5=91=A8=E5=85=AD 01:44=E5=86=99=E9=81=93=EF=BC=9A > > > > On Mon, 30 May 2022 21:09:10 +0300 > > Andy Shevchenko wrote: > > =20 > > > Instead of custom data type re-use generic struct u32_fract. =20 > > > > There isn't a custom data type - I'll reword this whilst applying > > if there is no reason for a v2. > > =20 > > > No changes intended. =20 > > > > functional changes > > =20 > > > > > > Signed-off-by: Andy Shevchenko =20 > > Given they have been active recently I'd ideally like Cixi Geng > > to take a quick glance at this before I apply it. =20 > Acked-by: Cixi Geng Applied to the togreg branch of iio.git and will be pushed out initially as testing for 0-day to take a look. Thanks, Jonathan > > > > Thanks, > > > > Jonathan > > =20 > > > --- > > > 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_ad= c.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_da= ta *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_denomina= tor) > > > +static void sc27xx_adc_volt_ratio(struct sc27xx_adc_data *data, int = channel, int scale, > > > + struct u32_fract *fract) > > > { > > > u32 ratio; > > > > > > ratio =3D data->var_data->get_ratio(channel, scale); > > > - *div_numerator =3D ratio >> SC27XX_RATIO_NUMERATOR_OFFSET; > > > - *div_denominator =3D ratio & SC27XX_RATIO_DENOMINATOR_MASK; > > > + fract->numerator =3D ratio >> SC27XX_RATIO_NUMERATOR_OFFSET; > > > + fract->denominator =3D 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_l= inear_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, &denomi= nator); > > > + sc27xx_adc_volt_ratio(data, channel, scale, &fract); > > > > > > - return DIV_ROUND_CLOSEST(volt * denominator, numerator); > > > + return DIV_ROUND_CLOSEST(volt * fract.denominator, fract.numera= tor); > > > } > > > > > > static int sc27xx_adc_read_processed(struct sc27xx_adc_data *data, = =20 > > =20