From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 A7120262FFC for ; Mon, 18 May 2026 15:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779117404; cv=none; b=V5Kal5D/E6SHuhQSg6+jY9M3BT2rtmNWIsKRIQeikcnNBzfGM0ZyCjq4058dnUCkC6bzExD0cT8CxiSMzT0nSJA6KoIsutUC8j9RT71YbJQA2WligPuuocI6jrq5Bpo5dJJfpdiF9tKFDrY34LcM1f9xgr4nWu/PPl702VmMUeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779117404; c=relaxed/simple; bh=WIuBIRVBEY5UXNn0IA/SjRUP6qFVmbXEj3WzcJbGoMk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Vhw70SkRNuESHrAwdSl69zLPZLfnvyg0U+WX4Xx9UiluX55x1LiNqPskXdX1stsC0CvTpT7UvDmTNsQfNQXF3d7JKhalc4iCCasDfWwSaVp1OKL5RnlVl2pXGywnrgevn5lWayBVD6MbMe4n1Eoyg7ZDx4n2GgHRqwai+wGdkEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=fx/mFa8o; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="fx/mFa8o" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-47c35be02fdso810432b6e.3 for ; Mon, 18 May 2026 08:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1779117400; x=1779722200; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HnVPqvj+TB5ocpICaZUeUZprZClJ7W/n+a216rMOu9M=; b=fx/mFa8oJCpZrYpv/yxn9pTqx3cTqQQ1BTSB5AfnFgQDxZGKK3TFfV5NES+7elzVUc 9MIuAl+HxR1Az3RAdp9BI0w9s5uDlXxoQ8NfYpHfU1rMTAPfHNg7kcWqYvV4vBKAEn9I bsvtzjhpmaWkx48dIv62huk811hak3h4JRv49YiZNIPFS+q9nZVIY3rOVMnDPS6i5Et0 gjbPUiKq92AakMhTyXByaKrBBMqBi0TziWoayMzXkp3dzlzQzgRVbSyv/PwMy4fFGhym Z3hFESLMH9B/bZcxVD9JJixqKn8OJTOMjylkysqk4hzhRuPCK4gRIFiLb2OY4LF/Kra8 mjuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779117400; x=1779722200; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HnVPqvj+TB5ocpICaZUeUZprZClJ7W/n+a216rMOu9M=; b=iUuazjnzdyD3rRdTmqsjsOt3CZ97qlOQ7xRF5pXll8reM0tuhA/yMlGuVT0livePjB hF70ticUYZA7HdrvVAUoiZcAIv4e+VaAMyMnO5YHzMf1Mtnho6LDg8uz79xWLwnXSTRd ra9dbiktKqGJPfbD9GoViJ24tXlan9RKUsDkLXjZAyzY3NNWMe9RtRw2QlEZYWhbJKr2 WSTmkNNcAsk0U+/FLr9imJcKcbWuCEe4IduBDA0314K3rSN18UjeKeYZ048HT41j18N6 EVaFO97Y2HCkyCSjL9bIQpQMFZncOqhUwzUq5s1SVKb2hS7vz6B3i/lucG8gm9hKPR/9 MY8g== X-Forwarded-Encrypted: i=1; AFNElJ8dV2W8ykXdFJHz1cZcknGpY3EsCxArEyWPFbbthlE9v9edr/8NpwRxcOFZweXvDxeTpt28bTuWXpg=@vger.kernel.org X-Gm-Message-State: AOJu0YzkEf5O796F9KwmeQLR34f2aD75092DH9jAvArLpRnWVsBDhCM5 hddebdSj9fOaD5M/ZiMaM+1bdfKucx2dCMmLrG5+GEQYoGsGUZ1d7iNlhl4LVBXyxao= X-Gm-Gg: Acq92OFpngMB9v9Hf7TRLfmH+7EeEqFu/umC+Jp5b3jA5SvldXDh1YdPhZzWxVDijns QyQEzHCY4ycLCdzbgFOVKlnKGx+DZweUH/nmLtQ6xqa++X4isAc2HjfhoPlNheZixSNnMoWBbKn jFpC8adVRXn6uEURpMboElhHyufqRk1APfVVJE5vWizELHdtjjvcvgSaCiwvPVVUt3piNaQwXYM i7lBIrWi9rYOHQTBKXuIXP2Fu7OYSd9EKsErjQGTXRq0/StwjMQwvwPFvnQN1L/2GiRjY9B3ekl 5Duq5ZaMHUDm1xuwgTCqIFzkdxb51eKuLh8KMDvWMWQ6RW82bZb2A7Y6kBC6n08JdgAMVMN3w+Y /7R6gfeXh0MwJu/UH2phmbQvDhp1kzVcKVJazaA1ctWQTdqZdKi9sVPG7OylWwohGr8+yikTcxl IEkHJ/UJK99NJ23uevVFyohubWOSqVIj1jU3+F3rzlyH6E+BT7g93zGIKN+I8PSwInZIgTlJV9b g== X-Received: by 2002:a05:6808:11c1:b0:467:2652:b29d with SMTP id 5614622812f47-482e55e64damr9452991b6e.8.1779117399487; Mon, 18 May 2026 08:16:39 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:3be6:1187:fed4:378b? ([2600:8803:e7e4:500:3be6:1187:fed4:378b]) by smtp.gmail.com with ESMTPSA id 5614622812f47-482ee0999f3sm5028432b6e.0.2026.05.18.08.16.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 May 2026 08:16:39 -0700 (PDT) Message-ID: <60d66897-41cc-4f3f-afd2-64e49f0bb55e@baylibre.com> Date: Mon, 18 May 2026 10:16:38 -0500 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 4/6] iio: adc: ad4691: add SPI offload support To: "Sabau, Radu bogdan" , Lars-Peter Clausen , "Hennerich, Michael" , Jonathan Cameron , "Sa, Nuno" , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , Liam Girdwood , Mark Brown , Linus Walleij , Bartosz Golaszewski , Philipp Zabel , Jonathan Corbet , Shuah Khan Cc: "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-pwm@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "linux-doc@vger.kernel.org" References: <20260515-ad4692-multichannel-sar-adc-driver-v11-0-eab27d852ac2@analog.com> <20260515-ad4692-multichannel-sar-adc-driver-v11-4-eab27d852ac2@analog.com> <80f61c0b-1f36-4fee-9f76-b93f63b87abe@baylibre.com> Content-Language: en-US From: David Lechner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/18/26 10:14 AM, Sabau, Radu bogdan wrote: >> -----Original Message----- >> From: David Lechner >> Sent: Saturday, May 16, 2026 8:53 PM > > ... > >>> static ssize_t sampling_frequency_show(struct device *dev, >>> struct device_attribute *attr, >>> char *buf) >>> @@ -880,6 +1229,9 @@ static ssize_t sampling_frequency_show(struct >> device *dev, >>> struct iio_dev *indio_dev = dev_to_iio_dev(dev); >>> struct ad4691_state *st = iio_priv(indio_dev); >>> >>> + if (st->manual_mode && st->offload) >>> + return sysfs_emit(buf, "%llu\n", READ_ONCE(st->offload- >>> trigger_hz)); >> >> Why do we need READ_ONCE? >> > > trigger_hz is u64 and if the target is 32-bit, a 64-bit access compiles to two 32-bit > instructions, so show() reading it without a lock and store() writing it concurrently > can produce a torn value at the compiler level. READ_ONCE/WRITE_ONCE suppress > the compiler transformations that would allow that splitting or caching. We could > have st->lock in show() instead, but that felt heavier than necessary for a single > scalar where a transiently stale-but-whole read is fine. > I would go with the mutex. It will be easier for people to understand.