From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 839B43F1650 for ; Mon, 20 Jul 2026 11:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784545634; cv=none; b=pJCCvedvQTWdBpBUB7Uls/+CxEX9fqvJJaaLcC3tvL3jaME7ySLgrlnJyISHDF20zZWLVhnYL4nqfIjEyGJStuJ02FdbCtSC/AoDF/NbIaCWCwOfEJi8o7LP0f+9PHY5TihlKCmJ1qS6DEdtiOH4EK4ClXJBpgSu1RI3q/XqG74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784545634; c=relaxed/simple; bh=WWAuBpJuM1odnG65HUT646N/thKeCcHH8xjoUDAj8b4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A0MI+Fwt14mOm9YzLPepth5X5RUz8prZ965YXE1mSG3O1z5Rlt4NSXXwaV74z0eLm0FuXkCgDrI18RS4KiiurGHF6c8oFpyYbdVGHWYje6nyIcNeOZ3bP4RzwvewY/4bSSfy8GaZ/yGtsUuAGM/EQ2IA+5VmSeMWeTSBtX0qwb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZCbhVijI; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZCbhVijI" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-475417f010dso5501762f8f.2 for ; Mon, 20 Jul 2026 04:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784545631; x=1785150431; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=/zgIrLwdkZiGqMFiiLYoRASN/eMBGS8ykh70vVqSw+I=; b=ZCbhVijIqPdnXWMEbgRzyuwyK9KXSl5zkQb0/xvr4KtcQrC6ja4oMTKdRe68HAWEuT OEBLAcaDETwGm255bOqmaBjlVBtuxWrLJIM0sXff4y+awWf0aDVJihX1fHk5etPbEBuy 3z8N5qFk51hLjlYVhd4rnnGI5WYvUQoE3rgEVOaI6V/8tQ8Nm2+erNz14Ugx/Gd88CiN C+Up42QS8DYveWQkJyL7FYDo3xVI4ix10yqmO4qBPLbR4ITdJy5Wbk+zZFmqa4i95dHZ eD5Pji9tcFXrP2zMN9rxIGqQLXXoY8oDD5WB4ISb11uvWUW9ayFYvIBlxxvGfnUvhZeZ mTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784545631; x=1785150431; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=/zgIrLwdkZiGqMFiiLYoRASN/eMBGS8ykh70vVqSw+I=; b=OXI/BFFcdg7jwzbgC9QsL4YGAHL3c+XbRLJnhHvEPdW2Z9xf9mLtM2CkHIluN8MjiO AbtZ59JXJR+kvENM6ahYYk4XWa6mJTJXxFegJ5X5AKqr9vQIOPn6WjRz27UZ/GjBVjV5 uzZnx/IdvdjFUGgsvcgOyqJlcxjD5GGmvkyUghw7mt4APTW4kgmBL0b/hkq+xIGNySre YRB8fZvkY3KcZN4fOY9/fE5jA15Z7332gMcbyb69yXWd9sigyzVkn9Yg/mOu0bROlVWF fqG4v6RPAdDSzjNIvIftDH1A5DQM89sdsqt8ek0aThDlTSl3OKC5xiedDG/qbhvsHyR7 kEPQ== X-Forwarded-Encrypted: i=1; AHgh+Ro5lcHwkPFIUCMVGgJb7nRE4sntMq1JsTqDYqBF5VGXQEtzV8aVE3Xysg3V9sODQMunSF/qfmultwn5UOw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx44s9JosWgEBaaG/tgC8bnwKd/L6lmE2FF707gRLXvUbI9DL1R qFFCOkIHX9EDrcc/TiQndRcCAEUW/RnYsqGkUDO03ttLPGTMCLEgoPYK X-Gm-Gg: AR+sD10tLaM1uVyxwmR2e6EUK/oBgHBab3a6EFEVNJLWW3nnRQ8TW16F815qwufiOQ8 WVLYFawaTOYKWpya3k4fNQxtNa1UDS/WYaIxIf5eBwts2l3/TFCcAICD8zVqH4f9w+rl6Y+kZLN rRJCEW5mqw4FkSiHk7XsnSkwLN1b4nJnSfD2+2w6tA8JadKO9pLLUb2LXtubBJLrkeqAA5CtD3B zKEv84E8XcvSpo0XOj4tUaTj3PghNwc65jJwhVFnHXbWNyXmC/kPrgPppKDWSgEC2TS8qGojlKn z092OEChMVbIesIE1Q9oThIHy6jSxJE6XnlPzvaY+pN5ZL2qUdr5mTuKVGntA8oXZndd/K6vGji rfyVs88ExWncrfTdKJ0o1/jtzTM0OT71nwX9wLDHzz5aJF+dhl+2pzc75VySaJYgy6JJe1PHxAG OXOxA3 X-Received: by 2002:a05:6000:298f:10b0:47f:6609:c60a with SMTP id ffacd0b85a97d-47f6609c66bmr10493764f8f.35.1784545630478; Mon, 20 Jul 2026 04:07:10 -0700 (PDT) Received: from nsa ([148.63.225.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63e49acesm28009004f8f.6.2026.07.20.04.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 04:07:10 -0700 (PDT) Date: Mon, 20 Jul 2026 12:08:16 +0100 From: Nuno =?utf-8?B?U8Oh?= To: Jonathan Cameron Cc: Stefan Popa , linux-iio@vger.kernel.org, Andy Shevchenko , David Lechner , Nuno Sa , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Siratul Islam , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Ciprian Hegbeli , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] iio: adc: add MAX40080 current-sense amplifier driver Message-ID: References: <20260715063652.368501-1-stefan.popa@analog.com> <20260715063652.368501-3-stefan.popa@analog.com> <20260718004145.079c5262@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260718004145.079c5262@jic23-huawei> On Sat, Jul 18, 2026 at 12:41:57AM +0100, Jonathan Cameron wrote: > On Wed, 15 Jul 2026 16:23:11 +0200 > Nuno Sá wrote: > > > Hi Stefan, > > > > Some comments from me > > > > On Wed, Jul 15, 2026 at 09:36:17AM +0300, Stefan Popa wrote: > > > The MAX40080 is a bidirectional current-sense amplifier with an > > > integrated 12-bit ADC and an I2C/SMBus interface. It measures the > > > voltage across an external shunt resistor and the input bus voltage, > > > storing the results in an internal FIFO. > > > > > > No existing IIO driver covers this device or a register-compatible part. > > > The closest relatives target different silicon with incompatible register > > > maps and feature sets: max9611 is a unidirectional high-side sensor with a > > > die-temperature channel and MUX-selected gain and no FIFO/PEC, while > > > max34408 is an 8-bit multi-channel current monitor. The MAX40080 has a > > > device-specific register map with bidirectional 13-bit current, a 64-entry > > > FIFO, PEC, a single-measurement mode triggered by an SMBus Quick Command, > > > and two selectable input ranges, so it warrants its own driver. > > > > > > Add a direct-mode IIO driver exposing the current and voltage channels > > > with raw and scale attributes, a configurable oversampling (digital > > > averaging) ratio, and PEC-protected register access. The two selectable > > > current-sense ranges are exposed through scale/scale_available; the > > > current scale is derived from the shunt-resistor-micro-ohms device-tree > > > property. > > > > > > Link: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX40080.pdf > > > > > > Co-developed-by: Ciprian Hegbeli > > > Signed-off-by: Ciprian Hegbeli > > > Signed-off-by: Stefan Popa > > A couple of follow ups even though v4 is on list. > > That should indicate clearly why you should slow down and let people > get to earlier versions. > > Jonathan > > > > diff --git a/drivers/iio/adc/max40080.c b/drivers/iio/adc/max40080.c > > > new file mode 100644 > > > index 0000000000000..a0c1144cfda7c > > > --- /dev/null > > > +++ b/drivers/iio/adc/max40080.c > > > @@ -0,0 +1,630 @@ > > > +// SPDX-License-Identifier: GPL-2.0+ > > > +/* > > > + * MAX40080 Digital Current-Sense Amplifier driver > > > + * > > > + * Copyright 2026 Analog Devices, Inc. > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > > Typically I would say you're missing mod_devicetable.h but now we have: > > > > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/linux/device-id > > > > You might need to base your series on linux-next though. > > I merged rc2 into the IIO togreg (and so testing as well) branches to resolve > merge conflicts with that series. Upshot is just don't bother > including mod_devicetable.h in any new code. Also don't worry > about including any of the linux/device-id headers unless you don't > get them via i2c.h, spi.h etc > > > > > > +#include > > > +#include > > > +#include > > > +#include > > > +static int max40080_read_iv_once(struct max40080_state *st, u32 *iv) > > > +{ > > > + u8 buf[4]; > > > + int ret; > > > + > > > + ret = i2c_smbus_read_i2c_block_data(st->client, MAX40080_REG_IV, > > > + sizeof(buf), buf); > > > > It's not clear to me that i2c will use safe buffer all the time (from a > > quick look). So I would say to make this DMA safe the usual way we do in > > IIO. > > I2c always bounces unless you use specific dmasafe functions to indicate > that your particular buffer is DMA safe. To me it was not clear because of: https://elixir.bootlin.com/linux/v7.2-rc3/source/drivers/i2c/i2c-core-smbus.c#L604 In the above case it looks like the buffer is just passed to the controller and it won't fallback for the emaluted case where i2c_smbus_try_get_dmabuf() seems to be always called. Having said the above and looking (briefly) at the .smbus_xfer_atomic() users, not sure it will be such an issue. - Nuno Sá > > > > > > + if (ret < 0) > > > + return ret; > > > + if (ret != sizeof(buf)) > > > + return -EIO; > > > + > > > + *iv = get_unaligned_le32(buf); > > > + > > > + return 0; > > > +} > > > +