From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (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 B80A8220687 for ; Tue, 2 Dec 2025 14:39:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764686379; cv=none; b=NoPgo9tifYrPWZNa62fL7f8Fu2YAd0INewgG77JgwO8vPlaNtRgzWGjyH4FOg1XGmtloyeNBReaUrrk/Ut/40yYIe9G1dMCduVf7BiJc2RghVgu0pFZ/QGlcFu8AgPPJeAN8hfyEzx9EU5+qzo5KYbSwBOOqdWX/J1yOBj9U17g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764686379; c=relaxed/simple; bh=aZx/6i4PV+XSZWPyBpQN9uU0i2DnHJsbJX8XUXQmjsg=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=OWxWah/zRVYhDIaHH6F/CWO0Fv6tabbaiIGcCiARK6uLILH8azoZ5ZZT6vXPTG0Qa4b2ZzOYckKe7yS1rId482q04TLs9uuCDTLQ5Hoxh4Z6CE1uYrRLLF7SSaJwyelqKgEW72VHfCi1kazrLyShSVQVW4NLi/X6efMb4FuCyI8= 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=A4Em8LyT; arc=none smtp.client-ip=209.85.221.171 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="A4Em8LyT" Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-55b26461e78so1544838e0c.3 for ; Tue, 02 Dec 2025 06:39:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764686377; x=1765291177; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UK6PHMqiItEJvhsik8lYBdE/HTgsHGok25qu5RzZyyg=; b=A4Em8LyTxXRZkA8vPrjnj/+gB32pHy4oFk3p5hdC3lJo1Pjw7BCZ7IgBveoUSwjbW+ GA6h3xnGA1RgifvWZ7TRtfNvkuinlBvvsf8fOS9DEiVRpW2GBT+3Ctx/8Xqme88p7Ab6 Ur5OgGdck9Yc4ngVEqCM19zkzzvNeK1wZ6LpjZCEn3ZJOB9dm/wX9ZG1cgkoJdCzLizu R29qYOhRQVJAhcXSg1iWGzWu7awr6dX+j7WFuPd0tj0iCUy9Vy9Wylr9pht+RrS5apgr 9PgYsDkQApmGMkuIlmqTw6SwAjoWArxT+AkiHmIrv3G4f7DM2hLQCgNgdL4N8qjXOLiW Re+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764686377; x=1765291177; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UK6PHMqiItEJvhsik8lYBdE/HTgsHGok25qu5RzZyyg=; b=jhOYNyug8iHpWB/sWt/YbHQuNBA3czDhHdQ7uSJelAC1RdUqk0vsyMYhyIA4nIRR4t svzwwBZDFW5tse9jLo1Q7WPhla+vm0IxBFPyglUrTp29Umqp0j76s1h/IdA2MGr05Yxh tSl+Yzk76ZurEQN6+gEVHsDgELRgog50bSOPZqqy2lrCgPILI6Z3OFuX8mU4Eale4cTu uw4igPMv5s5+eVyt6tgpXm5tUunhKrUbDU65czDVUmOddBp/HSGmIeBPkoXZfpB7kSP6 bX7iOrtizT6n0ezbKoZak52XQflPCIclgjr5dR8d6otQoD8y6cm71KAaG24Y6uMkbq6W Cojg== X-Forwarded-Encrypted: i=1; AJvYcCWeK1+LyP4XncUZc8hY/O0BytcMC0JPFVU30W1ILTc6SVARh7GsTh3iZqUUrCizl4QEaCBEyAOpe3SapY4=@vger.kernel.org X-Gm-Message-State: AOJu0YyeiTCBeWGje4MJoCv1clf/WKOBwETSFb6X6iHC/WOD2/zTgde+ PCGfvxV2OIpR2HLqGlL4Ta+TXauRDHlf4HGD7/ChLLpOWjFmbojG2Abd X-Gm-Gg: ASbGncs755Aa2Uy5OwVY1DM+aco1xTtCBzZ7i+wLiCSImT9L+bDfZOjhDu+Cv7HcKEP XcmFyy9mk6iiHYzPw/xRFAductf6/fCME1ckTBuZHPxdMtRdTFeQJIIQdxB2EgbW8ZaEkhKB4i3 EdYul9ctTF2Y59WT/VdpHxALqSOxqJLcrb8E2RZZLRNyZZIIASqFFUH3RS/Xo77L5BDeI7o5zLj fDNu1neYZKYXPOHzFilE1e6POhk0lP5MFASERbg4XIV66HQAeJ1hl1X0uq2g96hUjnGxNMHw3yi 5rzIdNrj1D3bxz+52gRlGAnRJTa71KH99WJZSvFto3SiF7EhDKKlNYB5zVdbPKlSAr7hHFSJjiG 83gBppKRe6FTXS7qqlJj7igCaY/n+unZZKfTWwUbE6NmO1DsRmzE/GzY52/oyrWlSFrQBh1eXgu Xrof4= X-Google-Smtp-Source: AGHT+IEISvZCykKFgKYrPaXC1owxjpY8fdWxMIYnIe0MU5C3tFhzQXFuARyvpNPLVGZ8ihlVpV/rRQ== X-Received: by 2002:a05:6122:3a14:b0:559:6d5c:9722 with SMTP id 71dfb90a1353d-55b8eb1f6ebmr15630558e0c.0.1764686376558; Tue, 02 Dec 2025 06:39:36 -0800 (PST) Received: from localhost ([2800:bf0:82:3d2:875c:6c76:e06b:3095]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-55cf516ba51sm6569243e0c.15.2025.12.02.06.39.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Dec 2025 06:39:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 02 Dec 2025 09:39:34 -0500 Message-Id: Cc: =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , , , , "Jonathan Cameron" Subject: Re: [PATCH v3 2/2] iio: adc: Add ti-ads1018 driver From: "Kurt Borja" To: "David Lechner" , "Kurt Borja" , "Jonathan Cameron" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Tobias Sperling" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20251128-ads1x18-v3-0-a6ebab815b2d@gmail.com> <20251128-ads1x18-v3-2-a6ebab815b2d@gmail.com> In-Reply-To: On Mon Dec 1, 2025 at 6:09 PM -05, David Lechner wrote: ... >> +#define ADS1018_CFG_DEFAULT 0x058b > > Would be nice to use the macros below to define this value so that we > know what it is actually doing. I will drop this on the next version. More on it bellow. ... >> +static int ads1018_read_unlocked(struct ads1018 *ads1018, __be16 *cnv, = bool hold_cs) > > It is a bit odd to me to call this "unlocked" and then call > "spi_synced_locked()". It sounds like we are using opposite words > to mean the same thing. Yes, that's true. I will revert this back to "locked", to match the SPI naming. ... > Do we actually need to transmit two words to trigger a conversion? > > It looks like there is a "16-Bit Data Transmission Cycle" for when > we don't need to read the config register back. Yes, we don't need the config readback anymore. I will convert everything to 16-bit transmission. ... >> +static int >> +ads1018_read_raw_unlocked(struct iio_dev *indio_dev, struct iio_chan_sp= ec const *chan, > > Saying "ulocked" here is a bit confusing since the previous "unlocked" ha= d > to do with SPI bus lock rather than iio_device_claim_direct(). I agree, this naming is a bit confusing. Andy, are you okay if I revert this back to __ads1018_read_raw()? I can add a comment on context. ... >> +static int ads1018_buffer_preenable(struct iio_dev *indio_dev) >> +{ >> + struct ads1018 *ads1018 =3D iio_priv(indio_dev); >> + const struct ads1018_chip_info *chip_info =3D ads1018->chip_info; >> + unsigned int pga, drate, addr; >> + u16 cfg; >> + >> + addr =3D find_first_bit(indio_dev->active_scan_mask, iio_get_masklengt= h(indio_dev)); >> + pga =3D ads1018_get_pga_mode(ads1018, addr); >> + drate =3D ads1018_get_data_rate_mode(ads1018, addr); >> + >> + cfg =3D ADS1018_CFG_VALID; >> + cfg |=3D FIELD_PREP(ADS1018_CFG_MUX_MASK, addr); >> + cfg |=3D FIELD_PREP(ADS1018_CFG_PGA_MASK, pga); >> + cfg |=3D FIELD_PREP(ADS1018_CFG_MODE_MASK, ADS1018_MODE_CONTINUOUS); >> + cfg |=3D FIELD_PREP(ADS1018_CFG_DRATE_MASK, drate); >> + >> + if (chip_info->channels[addr].type =3D=3D IIO_TEMP) >> + cfg |=3D ADS1018_CFG_TS_MODE_EN; >> + >> + ads1018->tx_buf[0] =3D cpu_to_be16(cfg); >> + ads1018->tx_buf[1] =3D 0; > > Seems like we could use 16-bit cycles here too? > >> + >> + return spi_write(ads1018->spi, ads1018->tx_buf, sizeof(ads1018->tx_buf= )); > > Hmmm... In the case where the trigger is not the DRDY signal (i.e. hritme= r or > sysfs), it seems like we would want to defer this until we actually recei= ve > a trigger. Otherwise, if the trigger is not already enabled and it is a w= hile > before the trigger is enabled, then the first data value will be quite st= ale > compared to the others since the conversion was done when the buffer was = enabled > rather than when the trigger fired. Because this is configured as ADS1018_MODE_CONTINUOUS, every time a conversion is completed, it automatically refreshes the last conversion on the register, so it is never stale (Section 8.4.2.2). > >> +} >> + >> +static int ads1018_buffer_postdisable(struct iio_dev *indio_dev) >> +{ >> + struct ads1018 *ads1018 =3D iio_priv(indio_dev); >> + >> + ads1018->tx_buf[0] =3D cpu_to_be16(ADS1018_CFG_DEFAULT); > > Changing DEFAULT to a more descritive name (e.g. SINGLE_SHOT_MODE) would = make > this more clear that the purpose of doing this is to take it out of conve= rsion > mode. Otherwise, a comment would be helpful here. I think it's better to just construct a minimal config with ADS1018_MODE_ONESHOT here. Ack to everything else. Thanks, David. --=20 ~ Kurt