Skip to contentSkip to conversation

drivers/iio/light/apds9999.c:201:undefined reference to `__umoddi3'

PATCH kernel test robot 2 participants 2 messages May 30

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
head:   7b84b1e9dd850a5c9b55e27daa4ecdc2dd5b3431
commit: a67c818e7a5ce49e141f0d73f8330026e82bcc31 [240/253] iio: light: add support for APDS9999 sensor
config: i386-randconfig-r071-20260529 (https://download.01.org/0day-ci/archive/20260530/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9185-gbcc58b9c
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260530/[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 >>):

ld: drivers/iio/light/apds9999.o: in function `apds9999_read_raw':

>> drivers/iio/light/apds9999.c:201:(.text+0x1cf): undefined reference to `__umoddi3'

vim +201 drivers/iio/light/apds9999.c

166
167 static int apds9999_read_raw(struct iio_dev *indio_dev,
168 struct iio_chan_spec const *chan,
169 int *val, int *val2, long mask)
170 {
171 struct apds9999_data *data = iio_priv(indio_dev);
172 int gain, itime_us;
173 u64 scale_nano;
174 u32 counts;
175 int ret;
176
177 switch (mask) {
178 case IIO_CHAN_INFO_RAW:
179 ret = apds9999_read_channel(data, chan->address, &counts);
180 if (ret)
181 return ret;
182 *val = (int)counts;
183 return IIO_VAL_INT;
184
185 case IIO_CHAN_INFO_SCALE:
186 /*
187 * Scale (lux per count) = 54 / (gain * integration_time_ms)
188 *
189 * The constant 54 is derived from the datasheet table:
190 * at gain = 3x, itime = 100 ms -> 0.180 lux/count
191 * -> C = 0.180 * 3 * 100 = 54
192 *
193 * Expressed as IIO_VAL_INT_PLUS_NANO.
194 */
195 gain = apds9999_gains[data->als_gain_idx];
196 itime_us = apds9999_itimes_us[data->als_res];
197
198 /* scale_nano = 54 * 1e12 / (gain * itime_us) nano-lux/count */
199 scale_nano = div_u64(54ULL * NSEC_PER_SEC * USEC_PER_MSEC, (u32)(gain * itime_us));
200 *val = (int)div_u64(scale_nano, NSEC_PER_SEC);

 > 201			*val2 = (int)(scale_nano % NSEC_PER_SEC);

202 return IIO_VAL_INT_PLUS_NANO;
203
204 case IIO_CHAN_INFO_INT_TIME:
205 *val = 0;
206 *val2 = apds9999_itimes_us[data->als_res];
207 return IIO_VAL_INT_PLUS_MICRO;
208
209 default:
210 return -EINVAL;
211 }
212 }
213

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

maintainer
#1 lore raw
Quoted 8 lines · On Sat, 30 May 2026 12:38:47 +0800 kernel test robot <[email protected]> wrote:
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
head:   7b84b1e9dd850a5c9b55e27daa4ecdc2dd5b3431
commit: a67c818e7a5ce49e141f0d73f8330026e82bcc31 [240/253] iio: light: add support for APDS9999 sensor
config: i386-randconfig-r071-20260529 (https://download.01.org/0day-ci/archive/20260530/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9185-gbcc58b9c
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260530/[email protected]/reproduce)
Quoted 11 lines

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 >>):

   ld: drivers/iio/light/apds9999.o: in function `apds9999_read_raw':
Quoted 1 line
Quoted 1 line

drivers/iio/light/apds9999.c:201:(.text+0x1cf): undefined reference to `__umoddi3'

I was clearly half asleep whilst trying previous fix and failed to notice the line after was bad as well. Anyhow, trying again. Squashing this on top.

drivers/iio/light/apds9999.c +6 -4
index 5285d148fbb5..7a0df5252078 100644
@@ -182,7 +182,9 @@ static int apds9999_read_raw(struct iio_dev *indio_dev,
                *val = (int)counts;
                return IIO_VAL_INT;
 
-       case IIO_CHAN_INFO_SCALE:
+       case IIO_CHAN_INFO_SCALE: {
+               u32 remainder;
+
                /*
                 * Scale (lux per count) = 54 / (gain * integration_time_ms)
                 *
@@ -197,10 +199,10 @@ static int apds9999_read_raw(struct iio_dev *indio_dev,
 
                /* scale_nano = 54 * 1e12 / (gain * itime_us) nano-lux/count */
                scale_nano = div_u64(54ULL * NSEC_PER_SEC * USEC_PER_MSEC, (u32)(gain * itime_us));
-               *val = (int)div_u64(scale_nano, NSEC_PER_SEC);
-               *val2 = (int)(scale_nano % NSEC_PER_SEC);
+               *val = (int)div_u64_rem(scale_nano, NSEC_PER_SEC, &remainder);
+               *val2 = (int)remainder;
                return IIO_VAL_INT_PLUS_NANO;
-
+       }
        case IIO_CHAN_INFO_INT_TIME:
                *val = 0;
                *val2 = apds9999_itimes_us[data->als_res];
Quoted 54 lines

vim +201 drivers/iio/light/apds9999.c

   166	
   167	static int apds9999_read_raw(struct iio_dev *indio_dev,
   168				     struct iio_chan_spec const *chan,
   169				     int *val, int *val2, long mask)
   170	{
   171		struct apds9999_data *data = iio_priv(indio_dev);
   172		int gain, itime_us;
   173		u64 scale_nano;
   174		u32 counts;
   175		int ret;
   176	
   177		switch (mask) {
   178		case IIO_CHAN_INFO_RAW:
   179			ret = apds9999_read_channel(data, chan->address, &counts);
   180			if (ret)
   181				return ret;
   182			*val = (int)counts;
   183			return IIO_VAL_INT;
   184	
   185		case IIO_CHAN_INFO_SCALE:
   186			/*
   187			 * Scale (lux per count) = 54 / (gain * integration_time_ms)
   188			 *
   189			 * The constant 54 is derived from the datasheet table:
   190			 *   at gain = 3x, itime = 100 ms -> 0.180 lux/count
   191			 *   -> C = 0.180 * 3 * 100 = 54
   192			 *
   193			 * Expressed as IIO_VAL_INT_PLUS_NANO.
   194			 */
   195			gain = apds9999_gains[data->als_gain_idx];
   196			itime_us = apds9999_itimes_us[data->als_res];
   197	
   198			/* scale_nano = 54 * 1e12 / (gain * itime_us) nano-lux/count */
   199			scale_nano = div_u64(54ULL * NSEC_PER_SEC * USEC_PER_MSEC, (u32)(gain * itime_us));
   200			*val = (int)div_u64(scale_nano, NSEC_PER_SEC);
Quoted 1 line

201 *val2 = (int)(scale_nano % NSEC_PER_SEC);

   202			return IIO_VAL_INT_PLUS_NANO;
   203	
   204		case IIO_CHAN_INFO_INT_TIME:
   205			*val = 0;
   206			*val2 = apds9999_itimes_us[data->als_res];
   207			return IIO_VAL_INT_PLUS_MICRO;
   208	
   209		default:
   210			return -EINVAL;
   211		}
   212	}
   213	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki