* [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract
@ 2022-05-30 18:09 Andy Shevchenko
2022-06-03 17:03 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-05-30 18:09 UTC (permalink / raw)
To: Jonathan Cameron, Cixi Geng, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen, Orson Zhai, Baolin Wang,
Chunyan Zhang, Andy Shevchenko
Instead of custom data type re-use generic struct u32_fract.
No changes intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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,
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract
2022-05-30 18:09 [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract Andy Shevchenko
@ 2022-06-03 17:03 ` Jonathan Cameron
2022-06-06 3:12 ` Cixi Geng
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2022-06-03 17:03 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, Cixi Geng, linux-iio, linux-kernel,
Lars-Peter Clausen, Orson Zhai, Baolin Wang, Chunyan Zhang
On Mon, 30 May 2022 21:09:10 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> 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 <andriy.shevchenko@linux.intel.com>
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,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract
2022-06-03 17:03 ` Jonathan Cameron
@ 2022-06-06 3:12 ` Cixi Geng
2022-06-12 9:08 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Cixi Geng @ 2022-06-06 3:12 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Andy Shevchenko, Jonathan Cameron, Cixi Geng, linux-iio,
linux-kernel, Lars-Peter Clausen, Orson Zhai, Baolin Wang,
Chunyan Zhang
Jonathan Cameron <jic23@kernel.org> 于2022年6月4日周六 01:44写道:
>
> On Mon, 30 May 2022 21:09:10 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> 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 <andriy.shevchenko@linux.intel.com>
> Given they have been active recently I'd ideally like Cixi Geng
> to take a quick glance at this before I apply it.
Acked-by: Cixi Geng <cixi.geng1@unisoc.com>
>
> 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,
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract
2022-06-06 3:12 ` Cixi Geng
@ 2022-06-12 9:08 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-06-12 9:08 UTC (permalink / raw)
To: Cixi Geng
Cc: Andy Shevchenko, Jonathan Cameron, Cixi Geng, linux-iio,
linux-kernel, Lars-Peter Clausen, Orson Zhai, Baolin Wang,
Chunyan Zhang
On Mon, 6 Jun 2022 11:12:15 +0800
Cixi Geng <gengcixi@gmail.com> wrote:
> Jonathan Cameron <jic23@kernel.org> 于2022年6月4日周六 01:44写道:
> >
> > On Mon, 30 May 2022 21:09:10 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> 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 <andriy.shevchenko@linux.intel.com>
> > Given they have been active recently I'd ideally like Cixi Geng
> > to take a quick glance at this before I apply it.
> Acked-by: Cixi Geng <cixi.geng1@unisoc.com>
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
> >
> > > ---
> > > 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,
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-12 9:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 18:09 [PATCH v1 1/1] iio: adc: sc27xx_adc: Re-use generic struct u32_fract Andy Shevchenko
2022-06-03 17:03 ` Jonathan Cameron
2022-06-06 3:12 ` Cixi Geng
2022-06-12 9:08 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.