From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057021; b=RMP8J8lvgwCeLvnS/Ty7/GjaU29wuaHGzDG0yo9y2lAxF3I/q37cchc6w68SUJClJwH2 JWpX2bTT2l7805FofVTl0dl6ljT6EjtEfj57YCwe0GYDEvEJBQvNZzvRCzhW/NGNqrMwk ZEIVMPjtxaAnoI2YRbhNVr4FzRNTs5D6k1XNIDxoSQAfb7f6VYHC5u1W37j1PUr8tswlg cuS1V6PfBte4zRxK9XSUXcQZ+PDQV7mJP+osgfTPkCLbJuXFe40uGOpX5hUzNVIuh/ZVg 9chBeta8DxlkOIl1ybHclQnXdFpzxH2xhIXPipgJFs9qQyXK75ukc9VdqC71K0EcUfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057021; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8szzZI16nrAI5I4OmK5ARn0zGpAvCbfgKr1lAuWhAuk=; b=RGMBesD1fTOxnM0uWoHHyfH7WyBP4W76fN7JnqezaXHUBiHuz8fDtQ4yPe//LYl4tyK4 xldEV8ZpcdFopPRB0hmrGmYutRhS1pN4fFizxYl8vz1HYSGKDF9fMDzpB0GPRDpsW8LFh ZeDEyuLWr0VCwZtOM+3XdX9AnQ707QW8Z5vWZB10h6o4jhoWn5KhfeXjp0lFtCJKlhIPc orU0VeWxnf1qijRkoNdaLuxU6ds89DSVt6oG7+z8E/zClBjZT5gTymr15r6WWcBOxzv9K q7VeLzp+SrgY9QcVx1qdCBbyutHPkCVT2BNxwxx8nO8uOMAUHGyF4AusD6o1n/sR5MA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RnnfCVMd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B99F606A32A for ; Mon, 30 Nov 2026 16:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RnnfCVMd Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5F141F000C1; Mon, 30 Nov 2026 16:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796057020; bh=8szzZI16nrAI5I4OmK5ARn0zGpAvCbfgKr1lAuWhAuk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RnnfCVMdTXgRDH0mC9wLmQi4AR5tgxrR6LEb18o8cBisJ11bSpqFE01bTYbdPwOUM p1xbl7pI19BEDG9CNWSnWDmXamPVzUapCgTs15A3/lup0zU/32il90Ab5x3WCFKzGH /PF/jPtTGaNyBFXNRwjML1QgRCIdC93KwjvsBikXq4aiguLRJloBZgN2e+ecpwOOEY Znvev2NsIOq/XYQ4M/qXtttZEdEuMsS4yP3Bz9QXj1BNqIiTrjBk5vx7HCuzGM3VcQ mlwKDPSsnorwJ9umsJY1b6+68fEuPY8hua8tR+9tBfcnxNp5Yu5gZz2ofmB+Ohviqq yRWCd79QTMZJA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 4/5] iio: adc: add driver for the MAX34417 Four-Channel High Dynamic Range Power Accumulator Reply-To: sashiko-reviews@lists.linux.dev To: "Neil Armstrong" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261130-topic-sm8x50-iio-max34417-adc-v8-4-6efef2782816@linaro.org> References: <20261130-topic-sm8x50-iio-max34417-adc-v8-0-6efef2782816@linaro.org> <20261130-topic-sm8x50-iio-max34417-adc-v8-4-6efef2782816@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 16:43:40 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] iio: adc: max34417: missing hardware OVF recovery in max34417_read_voltage() - [Low] iio: adc: max34417: integer truncation in max34417_calc_input_correction() -- commit 9ace5564b012f4fd085ba7d50f6b5c2ae73e3e15 Author: Neil Armstrong iio: adc: add driver for the MAX34417 Four-Channel High Dynamic Range Power= Accumulator This commit adds an IIO ADC driver for the Analog Devices MAX34417 four-channel current and voltage monitor, supporting voltage, power, and continuous energy accumulation over I2C/SMBus. > diff --git a/drivers/iio/adc/max34417.c b/drivers/iio/adc/max34417.c > new file mode 100644 > index 0000000000000..71a24d62c59c1 > --- /dev/null > +++ b/drivers/iio/adc/max34417.c [ ... ] > +static int max34417_read_voltage(struct max34417_data *max34417, > + const struct iio_chan_spec *chan, int *val) > +{ > + struct regmap *map =3D max34417->regmap; > + u8 buf[MAX34417_VOLTAGE_READ_LENGTH]; > + s64 delta_us; > + int rc; [ ... ] > + /* > + * Move the new UPDATE data into the SMBus read registers. > + * This will also reset the accumulators, returning the power accumulat= ed > + * since the last UPDATE. > + */ > + rc =3D regmap_write(map, MAX34417_UPDATE_REG, 1); > + if (rc) > + return rc; > + > + /* Save the timestamp for the next read */ > + max34417->last_update =3D ktime_get(); > + > + /* Continue reading voltage even if local accumulation overflows */ > + if (max34417->cam_mode && !max34417->overflow) { > + /* Retrieve all channels to avoid missing data for other channels */ > + rc =3D max34417_save_accumulators(max34417); > + if (rc && rc !=3D -EOVERFLOW) > + return rc; > + } [Severity: Low] Does skipping max34417_save_accumulators() when max34417->overflow is set also skip max34417_check_ovf()? If a hardware accumulator later saturates while in Continuous Accumulation Mode, MAX34417_CONTROL_OVF is never cleared and the device stops measuring, so subsequent voltage reads return stale values. Calling max34417_check_ovf() when max34417->overflow is true would keep voltage measurements running. [ ... ] > + case IIO_CHAN_INFO_SCALE: > + switch (chan->type) { > + case IIO_VOLTAGE: > + /* Scale to mV */ > + *val =3D MAX34417_VOLTAGE_CORRECTION_SCALE * MILLI; > + *val2 =3D MAX34417_VOLTAGE_FULL_SCALE_BITS; > + > + return IIO_VAL_FRACTIONAL_LOG2; > + case IIO_POWER: > + /* > + * Scale to mW > + * (1000 * (Power Accumulation / Counter) * Correction) / 2^30 > + */ > + *val =3D max34417->input_correction[chan->channel] * MILLIWATT_PER_WA= TT; > + *val2 =3D MAX34417_PWR_AVG_FULL_SCALE_BITS; > + > + return IIO_VAL_FRACTIONAL_LOG2; > + case IIO_ENERGY: > + /* > + * Scale to Joules > + * P=3D((Power Accumulation / Counter) * Correction) / 2^30 > + * t=3D(Counter / Samples per Second) > + * E=3D(P * t) > + * Can be simplified to: > + * (Power Accumulation * Correction) / (2^30 * SPS) > + * And scale expressed in Femto (10^-15 precision): > + * S=3D(Correction * 10^15) / (2^30 * SPS) > + * With the maximum input_correction of 2400, it fits in 64bits > + */ > + num =3D (u64)max34417->input_correction[chan->channel] * FEMTO; > + den =3D (u64)MAX34417_FAST_SPS_CAM << MAX34417_PWR_AVG_FULL_SCALE_BIT= S; > + scale =3D div64_u64(num, den); > + iio_val_s64_decompose(scale, val, val2); > + > + return IIO_VAL_DECIMAL64_FEMTO; [ ... ] > +static u32 max34417_calc_input_correction(u32 rsense_uOhm) > +{ > + /* Derived from Table 14. Correction Factors for Various Current-Sense = Resistor Values */ > + return (MAX34417_MAX_RSENSE_uOhm * MAX34417_PWR_CORRECTION_SCALE) / rse= nse_uOhm; > +} [Severity: Low] Does integer division in max34417_calc_input_correction() truncate the correction factor to whole Watts before max34417_read_raw() scales it to mW or femtoJoules? For a shunt-resistor-micro-ohms value that does not evenly divide 2400000, such as 33000 uOhm, 2400000 / 33000 truncates 72.727 to 72, giving a power scale numerator of 72000 mW instead of 72727 mW. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-topic-sm8x= 50-iio-max34417-adc-v8-0-6efef2782816@linaro.org?part=3D4