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=1795914391; b=1QfaGm0Kluhn9r8ssSNcK1m67bZXEoe5cEsXfW/JSH8qVR2vQL4tz91zkVyPWqeMyk3d lHBNa45NEKTHl++i05bEyjNw+8VoH1bZ6RliwjNpMCsMijaT94bjH1goYiNdSp+p9KUd/ Sjgf5v6iOs25Vehw3AUK+h60AJpXQr3sBt7No2NbiC79FYU/3ubwsE9TrZIHJuat3Biua dfYtFdDhxpEHBChkjpfa308NHDJDBWCQnhyoFlNcE/Y5jJGFYJAQHHBajCfQgios9a3IR pnnGhAsZ+1kDB2J771aOOMyo8al3K63MZy2IG3fhzJmRjAvUJkUbdwaPOGGqAO9F8bw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795914391; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=Gp7EDdAHvOLOs/6fA2rYwHmYzeTrDy2Fa08/wzb6Tf0=; b=UWgYO8iiC8Up5sMM893/s2kyX+P/l2DdTB/1c+Xl0bi+2eZ39FSqq8FWEuOz5Ee2HLd5 gmSLAKKqPLtVLJaWz02HSsbluiLVxSL1Zq3azZtWLRhL2N6YrtOr47tnvXcLPGOrDnwME UgWEGDakt6YDbPaeNVAzyfiD/EXonxM/+xlSBclJVRCMm/6jhZDSL+yIg2A7GOEmFH00L fx1gI3mwqwuT4RIXBC13JLfsTtUeTIwSNugEXZKi9hX9nynBW8jw0Obq94yMqZ0z4GqPq wTjrRp3Hzwj7OWkemTrBpFMgkWG+pzKwrVU6FxEzWIliKR00+3bPbFE9/p+eIqtuS7g== 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=B5luIL9M; 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 3EBCD606A31C; Sun, 29 Nov 2026 01:06:30 +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=B5luIL9M Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D2D21F00897; Sun, 29 Nov 2026 01:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795914390; bh=Gp7EDdAHvOLOs/6fA2rYwHmYzeTrDy2Fa08/wzb6Tf0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=B5luIL9MccsvI1XDjOs4Ce+ueCDMt5Vh3Rfdg/vvYsjcxin0S+7+tu+v5KIcDcdHn +TBoAQByL0WPh87ZWmFiuoOzGi+lkpI95QeaRqOqbV7YwVW7+06Q7m2RO71BfxrEI3 JfTnQrD49PTW+j0SIREamwkYVWUVZClGumYC1HXbQzPEhTNCQzxYpWSz1Ix33GTTjP dkRDTuOy74RzTBfhj19iG3PxzTVmw2R06gSH+b1KWXLZTE9XhC5CJTrCexQ02ePHWb 28rsWg+g86U5kWFKXicbTzoPECRRG6pgZi35gRJ/wdk1U8aBUrJHhDAH63DK1lJn5O 8wyYnBtA5ENEg== Date: Sun, 29 Nov 2026 01:06:22 +0000 From: Jonathan Cameron To: John Erasmus Mari Geronimo Cc: , , , , , , , , , , Guenter Roeck , Subject: Re: [PATCH v7 0/2] Add support for Analog Devices MAX30210 Message-ID: <20261129010622.1ccb0b2e@jic23-hlaptop> In-Reply-To: <20261125025425.1176-1-johnerasmusmari.geronimo@analog.com> References: <20261125025425.1176-1-johnerasmusmari.geronimo@analog.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 25 Nov 2026 10:54:23 +0800 John Erasmus Mari Geronimo wrote: > This series adds support for the Analog Devices MAX30210 I2C > temperature sensor. >=20 > Datasheet: https://www.analog.com/media/en/technical-documentation/data-s= heets/max30210.pdf >=20 > The device provides a 16-bit temperature output and includes > features such as a hardware FIFO, programmable sampling rate, > threshold alarms, and interrupt support. The FIFO is exposed as an > IIO buffered capture (kfifo buffer, fed from the FIFO watermark > interrupt) and the threshold alarms as IIO events. As far as I can > tell hwmon has no equivalent for streaming samples out of a hardware > FIFO, and the related MAX30208 is an IIO driver as well. >=20 > Although the MAX30210 belongs to the same device family as the > MAX30208, it is implemented as a separate driver. The MAX30210 has > a significantly different feature set, including a 64-sample hardware > FIFO with configurable watermark interrupts, programmable sampling > rates, and event support. These features require buffered operation > and IRQ-driven data handling which are not present in the MAX30208 > driver (which talks to the device directly via i2c_smbus_*() calls > with no regmap, and has no IIO buffer or event interface at all). >=20 > In addition, the MAX30210 uses a different register map and a more > flexible I2C address selection scheme. Supporting both devices in a > single driver would introduce substantial conditional logic, so a > separate driver keeps the implementation simpler and easier to > maintain. >=20 > Patch 1 adds the devicetree binding (unchanged since v5). > Patch 2 adds the IIO driver implementation. >=20 > Changes since v6: > https://lore.kernel.org/all/20261110021442.410-1-johnerasmusmari.geronimo= @analog.com/ > - Request the interrupt before devm_iio_device_register(), after the > quiesce action is registered. Jonathan asked for this on v4 and I > refused it on v5 and v6 because I believed the event interface was > freed on unregister. That was wrong: iio_device_unregister_eventset() > is only called from iio_dev_release(), which runs after all other > devm actions, so the order is safe. Removal is now: unregister > (predisable() synchronizes a live interrupt), free the interrupt, > quiesce, power down. The interrupt handler returns IRQ_NONE while > INT_EN is 0, so requesting it early is harmless. Sorry about that, > and thanks to Jonathan and sashiko for not letting it go. Great. I hadn't caught up with your v6 because I wanted to look into what races we had around this in more detail. Now I can park this for a while at least. I'm less than confident that we are race free but at least seems we are ok for the case that was concerning you. Thanks for digging into it. I'm snowed under with all the bugs that shook out in a refactor of some of the trigger handling (hopefully post a bunch of those in next few days) and events was after that! Jonathan > - postenable(): only read STATUS to drop a stale A_FULL when no > autonomous conversion user (threshold event) exists, and do it > before the conversion is started. Otherwise the clear-on-read could > swallow a pending TEMP_HI/TEMP_LO flag of an armed event (sashiko). > With events armed a stale A_FULL may remain and fifo_read() skips > the invalid samples. > - Rate-limit the error messages in the interrupt handler and in > max30210_fifo_read(). > - Style cleanups from Andy: multi-line comment in autoconv_put(), an > index variable in max30210_fifo_read(), local regmap and > m/v variables with field_prep() in max30210_write_raw(), clamp the > watermark before checking it for zero, "5 =C2=B5s" in the comment. > - Rebased on the current iio togreg. >=20 > Tested on real MAX30210 hardware (Raspberry Pi 4) with a 6.12 based > vendor kernel, which has no KASAN or lockdep; this version is only > build-tested against mainline (W=3D1, checkpatch --strict and > dt_binding_check are clean). Re-run on this version: the sysfs scale > against the raw reading, FIFO streaming with a fresh first sample, the > watermark clamp, threshold events with the buffer off, disabled events > staying silent while the FIFO interrupt runs, 50 buffer > enable/disable cycles, the buffer enabled with events already armed > and the other way round, 80 rmmod/insmod cycles (20 with interrupts > firing and 60 timed to land within about 250 ms of live interrupt > traffic), 60 more rmmod cycles with the buffer and events active, > the no-interrupt and the no-powerdown-GPIO configurations, and the > INT_EN/TEMP_CONV state the chip is left in after removal (checked > against a driver without the quiesce action, which fails the check). >=20 > Changes since v5: > https://lore.kernel.org/all/20261023080623.1830-1-johnerasmusmari.geronim= o@analog.com/ > - Fix the temperature scale: one LSB is 5 milli degrees Celsius, so > report 5 (IIO_VAL_INT) instead of 5/1000. > - Mask the interrupt status with the enabled interrupts, so threshold > events and the FIFO that are not enabled are not serviced. > - Start the FIFO interrupt and the autonomous conversion in > postenable(), after the watermark has been set, and stop them in > predisable() followed by synchronize_irq(). This also removes the > goto from preenable(), which mixed a guard with a goto. > - Read STATUS before enabling the FIFO interrupt so a stale A_FULL > flag does not fire on the freshly flushed FIFO. > - Clamp the hardware FIFO watermark to the FIFO size instead of > failing. > - Mark SYS_CONF_REG volatile (its reset bit is self-clearing). > - Use gpiod_set_value_cansleep() for the powerdown GPIO. > - Keep the powerdown GPIO asserted for 10 us before deasserting it, > the datasheet lists a CVT/PDB input low-pulse width of 5 us. > - Do not expose the threshold events when there is no interrupt. > - Review cleanups: check the event type first, use a local regmap > variable, regmap_test_bits(), simpler set/clear handling in > write_event_config(), a logical split of the poll call, and rename > the sampling frequency index to freq_idx. > - Not changed: autoconv_put() still drops its reference when the > register write fails (a later direct read rewrites TEMP_CONV_REG > without AUTO, which stops it). > - Cover letter: removed the incorrect statement about hwmon and > interrupts, thanks to Guenter for pointing it out.