iio: light: opt4001: Re-use generic struct s32_fract
PATCH 1/1 iio: light: opt4001: Re-use generic struct s32_fract
Instead of custom data type re-use generic struct s32_fract. No functional changes intended.
--- drivers/iio/light/opt4001.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/iio/light/opt4001.c +5 -8
@@ -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 ;
Signature · 1 line
2.50.1
Quoted 2 lines · Andy Shevchenko
Instead of custom data type re-use generic struct
s32_fract. No functional changes intended.
...
drivers/iio/light/opt4001.c struct opt4001_chip { · line 90
Quoted 4 lines
static const struct
opt4001_chip_infoopt4001_sot_5x3_info= {drivers/iio/light/opt4001.c +1
-2- .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.
drivers/iio/light/opt4001.c struct opt4001_chip { · line 97
Quoted 9 lines
drivers/iio/light/opt4001.c +1
-2.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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 24 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Instead of custom data type re-use generic struct
s32_fract. No functional changes intended....
drivers/iio/light/opt4001.c struct opt4001_chip { · line 90
Quoted 4 lines
static const struct opt4001_chip_info opt4001_sot_5x3_info = {drivers/iio/light/opt4001.c +1
-2- .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.
drivers/iio/light/opt4001.c struct opt4001_chip { · line 97
Quoted 9 lines
.name = "opt4001-sot-5x3"};
static const struct opt4001_chip_info opt4001_picostar_info = {drivers/iio/light/opt4001.c +1
-2- .mul = 3125, - .div = 10000000, + ,ratio = { .numerator = 3125, .denominator = 10000000 }, .name = "opt4001-picostar" };
Quoted 7 lines
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
Quoted 3 lines
--
With Best Regards,
Andy Shevchenko
kernel test robot
build botkernel test robot noticed the following build errors:
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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