* [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
@ 2026-10-23 9:08 Andy Shevchenko
2026-10-23 9:21 ` Andy Shevchenko
2026-10-25 20:41 ` kernel test robot
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-10-23 9:08 UTC (permalink / raw)
To: Andy Shevchenko, Jonathan Cameron, Nikhil Gautam, linux-iio,
linux-kernel
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Jesper X Nilsson
Instead of custom data type re-use generic struct s32_fract.
No functional changes intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/light/opt4001.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c
index aa3d87995b7c..b2e7abc22434 100644
--- a/drivers/iio/light/opt4001.c
+++ b/drivers/iio/light/opt4001.c
@@ -75,8 +75,7 @@
* lux values.
*/
struct opt4001_chip_info {
- int mul;
- int div;
+ struct s32_fract ratio;
const char *name;
};
@@ -88,14 +87,12 @@ struct opt4001_chip {
};
static const struct opt4001_chip_info opt4001_sot_5x3_info = {
- .mul = 4375,
- .div = 10000000,
+ ,ratio = { .numerator = 4375, .denominator = 10000000 },
.name = "opt4001-sot-5x3"
};
static const struct opt4001_chip_info opt4001_picostar_info = {
- .mul = 3125,
- .div = 10000000,
+ ,ratio = { .numerator = 3125, .denominator = 10000000 },
.name = "opt4001-picostar"
};
@@ -199,8 +196,8 @@ static int opt4001_read_lux_value(struct iio_dev *indio_dev,
return -EIO;
lux_raw = lux_raw << exp;
- lux_raw = lux_raw * chip->chip_info->mul;
- *val = div_u64_rem(lux_raw, chip->chip_info->div, &rem);
+ lux_raw = lux_raw * chip->chip_info->ratio.numerator;
+ *val = div_u64_rem(lux_raw, chip->chip_info->ratio.denominator, &rem);
*val2 = rem * 100;
return IIO_VAL_INT_PLUS_NANO;
--
2.50.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
2026-10-23 9:08 [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract Andy Shevchenko
@ 2026-10-23 9:21 ` Andy Shevchenko
2026-10-23 10:02 ` Jesper X Nilsson
2026-10-25 20:41 ` kernel test robot
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-10-23 9:21 UTC (permalink / raw)
To: Jonathan Cameron, Nikhil Gautam, linux-iio, linux-kernel
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Jesper X Nilsson
On Fri, Oct 23, 2026 at 11:08:02AM +0200, Andy Shevchenko wrote:
> Instead of custom data type re-use generic struct s32_fract.
> No functional changes intended.
...
> static const struct opt4001_chip_info opt4001_sot_5x3_info = {
> - .mul = 4375,
> - .div = 10000000,
> + ,ratio = { .numerator = 4375, .denominator = 10000000 },
Oh, I should have compiled it, but I missed. Should start with a period, of
course.
> .name = "opt4001-sot-5x3"
> };
> static const struct opt4001_chip_info opt4001_picostar_info = {
> - .mul = 3125,
> - .div = 10000000,
> + ,ratio = { .numerator = 3125, .denominator = 10000000 },
> .name = "opt4001-picostar"
> };
Ditto.
...
Jesper, please take this patch into your series, but also fix those typos.
Or if you are busy, I can do it after my lunch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
2026-10-23 9:21 ` Andy Shevchenko
@ 2026-10-23 10:02 ` Jesper X Nilsson
0 siblings, 0 replies; 4+ messages in thread
From: Jesper X Nilsson @ 2026-10-23 10:02 UTC (permalink / raw)
To: Andy Shevchenko, Jonathan Cameron, Nikhil Gautam, linux-iio,
linux-kernel
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Jesper X Nilsson
On 10/23/26 11:21, Andy Shevchenko wrote:
> On Fri, Oct 23, 2026 at 11:08:02AM +0200, Andy Shevchenko wrote:
>> Instead of custom data type re-use generic struct s32_fract.
>> No functional changes intended.
>
> ...
>
>> static const struct opt4001_chip_info opt4001_sot_5x3_info = {
>> - .mul = 4375,
>> - .div = 10000000,
>> + ,ratio = { .numerator = 4375, .denominator = 10000000 },
>
> Oh, I should have compiled it, but I missed. Should start with a period, of
> course.
>
>> .name = "opt4001-sot-5x3"
>> };
>
>> static const struct opt4001_chip_info opt4001_picostar_info = {
>> - .mul = 3125,
>> - .div = 10000000,
>> + ,ratio = { .numerator = 3125, .denominator = 10000000 },
>> .name = "opt4001-picostar"
>> };
>
> Ditto.
>
> ...
>
> Jesper, please take this patch into your series, but also fix those typos.
> Or if you are busy, I can do it after my lunch.
>
I will add it to my series and fix the typos.
Best regards,
Jesper
> --
> With Best Regards,
> Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
2026-10-23 9:08 [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract Andy Shevchenko
2026-10-23 9:21 ` Andy Shevchenko
@ 2026-10-25 20:41 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-25 20:41 UTC (permalink / raw)
To: Andy Shevchenko, Jonathan Cameron, Nikhil Gautam, linux-iio,
linux-kernel
Cc: llvm, oe-kbuild-all, David Lechner, Nuno Sá, Jesper X Nilsson
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on linus/master v7.3 next-20261023]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/iio-light-opt4001-Re-use-generic-struct-s32_fract/20261023-110802
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20261023090802.1957593-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20261026/202610260406.ghXhpqoZ-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 186e70f4e6a1521991d2340d3d49b23b1beff11f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261026/202610260406.ghXhpqoZ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610260406.ghXhpqoZ-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/iio/light/opt4001.c:90:2: error: expected expression
90 | ,ratio = { .numerator = 4375, .denominator = 10000000 },
| ^
>> drivers/iio/light/opt4001.c:90:3: error: use of undeclared identifier 'ratio'
90 | ,ratio = { .numerator = 4375, .denominator = 10000000 },
| ^~~~~
drivers/iio/light/opt4001.c:90:11: error: expected expression
90 | ,ratio = { .numerator = 4375, .denominator = 10000000 },
| ^
drivers/iio/light/opt4001.c:95:2: error: expected expression
95 | ,ratio = { .numerator = 3125, .denominator = 10000000 },
| ^
drivers/iio/light/opt4001.c:95:3: error: use of undeclared identifier 'ratio'
95 | ,ratio = { .numerator = 3125, .denominator = 10000000 },
| ^~~~~
drivers/iio/light/opt4001.c:95:11: error: expected expression
95 | ,ratio = { .numerator = 3125, .denominator = 10000000 },
| ^
6 errors generated.
vim +90 drivers/iio/light/opt4001.c
88
89 static const struct opt4001_chip_info opt4001_sot_5x3_info = {
> 90 ,ratio = { .numerator = 4375, .denominator = 10000000 },
91 .name = "opt4001-sot-5x3"
92 };
93
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-25 20:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 9:08 [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract Andy Shevchenko
2026-10-23 9:21 ` Andy Shevchenko
2026-10-23 10:02 ` Jesper X Nilsson
2026-10-25 20:41 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®