From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 7E662340285 for ; Fri, 10 Apr 2026 20:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775854004; cv=none; b=CNHuv/4X9M3cFxNismaIItoPS6U+XJ5kxkc0ucPqsU6oFepAO/TjrFkQV0pEdvUX5og9cv8dyPfDvViq93hvyUoFNkITPinF/oNOJ6u2K+zmozl1YIpMjeqM44MZSMu18/DDQqV2j6D+OdNKnSNaGNnvhf3FeQQxyHnBVVjZsps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775854004; c=relaxed/simple; bh=HgJlDciSQOJkjPYMFiEeV5PqKaSjuxwAnLaENFbkQ2M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CQsy6MjiFdIbboQbe5l72LviKI3VzHv0PyX1CGktEnJGRxG/FPBDKAQfDZA+aaj69cZPPkdsIQdNIaWiMTEjtWslgqq0r00qlcPyoZBL+Rq7e7OUZqtS+Oa9ReLa0GqeRuC9PGsEWEtxh9wArY5fsTVdH9+FW4ST2R++HsLB/jc= 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.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b=SSXXPTeU; arc=none smtp.client-ip=209.85.210.48 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.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b="SSXXPTeU" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7dbff06e4a6so2361273a34.1 for ; Fri, 10 Apr 2026 13:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1775854000; x=1776458800; 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=MBpd+T8YvVMEln4nst2HllR/pz5g067Ap3lkXU/baHU=; b=SSXXPTeUQiGcPrLOlslscjIjBqIb/CoeAjzlc8XFGUpaWLHeXIAqj7EjK0KzK+04eh NRF9vZxeO79fiozCFkpmFQ+dmv+EQimJ+YWUoHnCiHHhYKssCUFdLccV0F1wCbeWPqdr B0+/oYek4duFyafbrOY7PyJocwpKCr2nHXtntjZhoFYH61fhQnAp6RMfPUaL+dMYMwxu sDO+hYxUINlRDbGmovVFcKtLPzydclkrIAhw9hZWieKnkzy+fVbO+OsfM+RMVwQS4izp tWdITiArNxuW9QChVdfkLpVHiIPAv8InLrhyDYCijkcNf1+Bmkf1nEFl5BUqfYOaG8WU HcuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775854000; x=1776458800; 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=MBpd+T8YvVMEln4nst2HllR/pz5g067Ap3lkXU/baHU=; b=EJzezZJ4iZFLcqyA9TJ+Vm58xkmUtuucNLsiYIuFmp36pkX30DSdYQjAE9jWPlzaj1 8ItSK0YixC1pcMZiEQXkK+t0iHVLbD0MKOD1mj5EWllcf1QYVq+YiQal0hK9P/YtJqF6 fSAi6gZgnoBfVn5/8n46Zqcddpqby67zR2njC6hfPTHGc+7MAvYLtsyg9RyChHI0LgHb y09FGhZyKVpEjKHx+/gVRGTYCoQ4/FitD4RJauKx1YifGjBYAUD8SalEWHOdf70WyiNt DYAypP4gX8Po474Tj824ZpEGFyOjPRC+xhOF5NZOmp86ykMlI1MjG9V5leGrz3+Lzl5D JTHg== X-Forwarded-Encrypted: i=1; AJvYcCUXRG9V8BHZUq0AVn9GatCFh1U4OU24zNvTblR0joU60yUsmpZlygClqAOD+IEdGCdKw4jycIg1uGl1ibc=@vger.kernel.org X-Gm-Message-State: AOJu0YzmTW4PGMqmTOUdKAxpu9haCXo6SzPAfKtSJz/+2LwcV7v6BwpM Dz0IhLQlznFuAb0dSg45Atu0oNwScvQ9UUP+okjciCh6uGF37eSkzhdPImd1QJ5MGDQ= X-Gm-Gg: AeBDievVuPUXyUtGcv979c6ZsEhZLEuXiVNghHUJJn5Lc1yU7Yqqrg2J5XlsJqSkHBi ebaaJ37GYwQPFPjoEYsrh2L8a1zH8Vx8k2auRugeRVJJSZqKvdmN0I9WrxuTVkbZ6PxkX4IgjZV +ALtJgeggf3njo2b8t7nDVp318Y2+okPRRCKqNzassC2IEwF9tbSDaf6RJZRbnjxAG1KfnNy+9K vf/tJLkt9rK/CH5UWCPwFWG02iKJ6RHalDNJV+4EUqV7rweknLo21H61tlQs9gaMIz/SXiZQyTL OCTqjFYtZk+Qk6nz+tWvrfYiWB1O3TZwAv8wEXN8CYY5C3elQTSX09wjrzA3LIeeN645x5pt76X pOX1iZyFgw4rDY/wTuok0Nv6owrNiA+lt5y6oDIiHAofPGSZO88gstlCJ5op+4FG9lck83GibXu ym/Yz5ZCH+r1fEOLpcOM5IKVRx2nhhRpwe6KnOeCi2tzP/Es2It8RlrnVDWrv00Fy2NNJVbenYW Db/vkRrBSbe X-Received: by 2002:a05:6830:6684:b0:7d7:faa4:6c2b with SMTP id 46e09a7af769-7dc27cc0028mr3047317a34.9.1775854000316; Fri, 10 Apr 2026 13:46:40 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:b75d:2440:dc10:808b? ([2600:8803:e7e4:500:b75d:2440:dc10:808b]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7dc269402b9sm2527358a34.20.2026.04.10.13.46.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Apr 2026 13:46:38 -0700 (PDT) Message-ID: <0f05add7-96c0-4eee-b396-d6e1be904c09@baylibre.com> Date: Fri, 10 Apr 2026 15:46:36 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 3/6] iio: adc: ad4691: add triggered buffer support To: radu.sabau@analog.com, Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , 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: <20260409-ad4692-multichannel-sar-adc-driver-v7-0-be375d4df2c5@analog.com> <20260409-ad4692-multichannel-sar-adc-driver-v7-3-be375d4df2c5@analog.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260409-ad4692-multichannel-sar-adc-driver-v7-3-be375d4df2c5@analog.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/9/26 10:28 AM, Radu Sabau via B4 Relay wrote: > From: Radu Sabau > > Add buffered capture support using the IIO triggered buffer framework. > ... > @@ -201,8 +245,45 @@ struct ad4691_state { > * atomicity of consecutive SPI operations. > */ > struct mutex lock; > + /* > + * Per-buffer-enable lifetime resources: > + * Manual Mode - a pre-built SPI message that clocks out N+1 > + * transfers in one go. > + * CNV Burst Mode - a pre-built SPI message that clocks out 2*N > + * transfers in one go. > + */ > + struct spi_message scan_msg; > + /* max 16 + 1 NOOP (manual) or 2*16 + 2 (CNV burst). */ > + struct spi_transfer scan_xfers[34]; > + /* > + * CNV burst: 16 AVG_IN addresses + state-reset address + state-reset > + * value = 18. Manual: 16 channel cmds + 1 NOOP = 17. > + */ > + __be16 scan_tx[18]; Needs __aligned(IIO_DMA_MINALIGN) since it is used with SPI. > + /* Scan buffer: one BE16 slot per channel (rx'd directly), plus timestamp */ > + struct { > + __be16 vals[16]; > + aligned_s64 ts; > + } scan; Unless it is required that all channels are always enabled: IIO_DECLARE_BUFFER_WITH_TS(__be16, scan_rx, 16); In any case, needs to be DMA-safe for SPI. > }; > > +static int ad4691_cnv_burst_buffer_preenable(struct iio_dev *indio_dev) > +{ > + struct ad4691_state *st = iio_priv(indio_dev); > + unsigned int n_active; > + unsigned int k, i; > + int ret; > + > + n_active = bitmap_weight(indio_dev->active_scan_mask, iio_get_masklength(indio_dev)); > + > + memset(st->scan_xfers, 0, (2 * n_active + 2) * sizeof(st->scan_xfers[0])); > + memset(st->scan_tx, 0, (n_active + 2) * sizeof(st->scan_tx[0])); Maybe simpler to just clear the whole thing? (same with other preenable) > + > + spi_message_init(&st->scan_msg); > +