From nobody Tue Feb 10 10:19:55 2026 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 91BC02C256D for ; Tue, 22 Apr 2025 22:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745359732; cv=none; b=RhTqlE8C143BhbR+l3oMyq2gele9o/fb9LHgv7quU88M0s66z2Dp8VbZlNMXLASYsaPUl9zQR7K5BnotFyDattfqJQ7yR9H6prY+FX552mPBrW6dD5f3EynTUpJ2MboamPFnjFKYIZa2yxCtI8y0rM0JFrfjLJ/lTajaOo6WSGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745359732; c=relaxed/simple; bh=COjNIZhPuNt4S3954Fn2UL7GTZFMh/VIXCBpDzwE6Cs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZQm3epvBLWwduiftZTBuTeKwyhGf2/vt3RPkb3LJ3f6H0obmivYS5v2/ppwVYPgyGnFHefb4xHi00795dhqv4vsWQ4bCS9az4XUlslubZsLnaHfuqhHWqQq6Lc/WEiPtMgBLftXfYSplP7w7duMP9Y3TgLwnb1ra0Nhy91CTDqM= 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ufPjDR1+; arc=none smtp.client-ip=209.85.210.45 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.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="ufPjDR1+" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7303d9d5edeso271004a34.1 for ; Tue, 22 Apr 2025 15:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1745359729; x=1745964529; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OxcllqlAxGqsvqgkY1jmnRBvrU6YNyliNCeWX4COibA=; b=ufPjDR1+ob53cWSzxml8+PuOWXQTC1OdmUiarUrYbaz46nW/M56/aL5CNN8WuXFD8s NB1aRvARtZnrRWelW9CmYxKVtNvncVaJsF8KzyE2Sjm0vOWObBMOVnn7x9U4+u8rkSef KXiIlj9SC659NZh4NWS8R6QoMN2A4FV5JxzqpmRnZwpcjBGn5Qv28ggpBGi0WGz3IPbF PLi80uteuyN+JF3GYfEquYFphJbfV5Gai1ZedMNcWCe06bZeyFa54BUUfsrZQZk+oUwN L52wrsjqew7wfVX/LtnvslgIWsMf717lQPrF6HhZBmHtybD3Hbw7tj4Et6xqBuSC9SH2 Lk2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745359729; x=1745964529; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OxcllqlAxGqsvqgkY1jmnRBvrU6YNyliNCeWX4COibA=; b=fK22OE4dBGP7uJ0SCan/3kO2yGuhZ1SEE0mq3KGM248n0dURJFsx9zP6ikEaZI64bu ar33XK4m3unkRrvbVxTf7duHBL7KPOvB0Hv5nWSFygOuJUCbaT2aCBBkj1NLKMMnXhi3 haaoVHxmlpfeQ/OV3unJA67m+YoSgb/hKERKMoTrr8ZCX2X83rxw39KPs76uYiPln+RE q6FJbFak0osWAJpmHmsp82O3M0nJ3JAKV5K8N5euvVB4LjYokpIA6JoxE/+su0nnE+iq qwqAWaf9HfRZ+oKOKIhttQ15VoecBRsf/xB0yR3pUkGPaoh+8aTfevRTuoLM2NmZavRK Nkfg== X-Forwarded-Encrypted: i=1; AJvYcCXjqv0PRV3URo3fDMUvjBb46Kjb4aipAkGs15c3Oo0Y3ngK9UGIPYWGkBXyYNAw7csYNLMg5d0sFTpic1A=@vger.kernel.org X-Gm-Message-State: AOJu0YxesV1MIXOvrok6j7m32sbVp7qiaZzo0lGfEccPV9mjHbYmv1Q3 DHeuzdsNiu5LMpuA+IxzX+vSdbCoJ5D91lP8ZwXytFXib9msMeE/LrflyLZkvbU= X-Gm-Gg: ASbGnctCLH9h8IjrJHVZvNhZpugPxdhBay4WARlWmy2QA1DoD5sIMk89lgBOPo3cMAx k8hYZQJP88KDei2fxjTi+Ne0slqJzXVb2ryl4dM2B+v3PFnUsgqGzLecIF/KVuEacNdUzzJo1vh Y5cTCeezNTHdQAkfUobD9PaOT/C24MABLx8cNoxM9n6jtO8+YoevaZQrt6yQGCBE0YUOeRnJpOO mvoDctzt8O5efoROYQ6kzE2EB8i3zcLkqu9URj+pXQJSlroeBufPgYGk5lR5YgYhSp9uL46IP0g n3fgO0VRVYkNxV7+6YP1huKO47tMEObBZjkdN0395IyeIgA= X-Google-Smtp-Source: AGHT+IEHQ1xlklPGq2GZ44BS1JT8PZ0bjGyLk9c5dWYPUyG84Suj7pcBUnv1TneF5QAxVGuSMQf2Hg== X-Received: by 2002:a05:6830:264b:b0:72b:9993:118e with SMTP id 46e09a7af769-730062f8177mr11792393a34.22.1745359729568; Tue, 22 Apr 2025 15:08:49 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:c8d1:e0ed:ce8b:96a3]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-730048848dfsm2265938a34.52.2025.04.22.15.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 15:08:49 -0700 (PDT) From: David Lechner Date: Tue, 22 Apr 2025 17:07:50 -0500 Subject: [PATCH v2 5/6] iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS 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-Transfer-Encoding: quoted-printable Message-Id: <20250422-iio-introduce-iio_declare_buffer_with_ts-v2-5-3fd36475c706@baylibre.com> References: <20250422-iio-introduce-iio_declare_buffer_with_ts-v2-0-3fd36475c706@baylibre.com> In-Reply-To: <20250422-iio-introduce-iio_declare_buffer_with_ts-v2-0-3fd36475c706@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2978; i=dlechner@baylibre.com; h=from:subject:message-id; bh=COjNIZhPuNt4S3954Fn2UL7GTZFMh/VIXCBpDzwE6Cs=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoCBNbRITiIrOuOBiNd6+w5vU0Q+H8NcTHgrQrU wLSWJRb19CJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaAgTWwAKCRDCzCAB/wGP wBTnB/9W3nNh7c5a7hXZRRRgX27QxylG6YYb6ppn7Xw65rFs9kwK77c2XZJ0mvMb2GtkwdRJTi/ gl3MYrnC4UO8Fa0QYFI86FvSwrL/Csc0KUdtxnoLwen4TidL0q/LrDC5juRb6mA15H4PxMU/7tV exHDy6eWEe4Mcr0HAkaWXpjKFp+uPdkC4fo+O+Z8mgP/68Yh5bRqYXoI7J/w/apXcV288ZzZjqv Rn9UvvZhMoS3u5jPkZKIoGhf2P8H3oPLCsresOruS7yjQ90ZC+hgnfSN7PTSd8X2QS/ldSmhabx 4oGYoytUtH0tST5kio2IoJVgt8p121obveXOAH7573ErgxVp X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use IIO_DECLARE_BUFFER_WITH_TS to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Signed-off-by: David Lechner --- This is an alternative to [1]. Also, this serves as a test to see if we can get a rule of thumb to decide how much is too much to put on the stack vs. needing to put the buffer in a static struct. SCA3300_SCAN_MAX is 7, so this add a bit over 64 bytes to the stack, make the stack now roughly double what it was before. [1]: https://lore.kernel.org/linux-iio/20250418-iio-prefer-aligned_s64-time= stamp-v1-1-4c6080710516@baylibre.com/ --- drivers/iio/accel/sca3300.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 1132bbaba75bcca525fac2f3e19f63546380fd4f..67416a406e2f43e4e4172104109= 04d44c93111d2 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -58,15 +58,6 @@ enum sca3300_scan_indexes { SCA3300_SCAN_MAX }; =20 -/* - * Buffer size max case: - * Three accel channels, two bytes per channel. - * Temperature channel, two bytes. - * Three incli channels, two bytes per channel. - * Timestamp channel, eight bytes. - */ -#define SCA3300_MAX_BUFFER_SIZE (ALIGN(sizeof(s16) * SCA3300_SCAN_MAX, siz= eof(s64)) + sizeof(s64)) - #define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \ .type =3D IIO_ACCEL, \ .address =3D reg, \ @@ -193,9 +184,6 @@ struct sca3300_chip_info { * @spi: SPI device structure * @lock: Data buffer lock * @chip: Sensor chip specific information - * @buffer: Triggered buffer: - * -SCA3300: 4 channel 16-bit data + 64-bit timestamp - * -SCL3300: 7 channel 16-bit data + 64-bit timestamp * @txbuf: Transmit buffer * @rxbuf: Receive buffer */ @@ -203,7 +191,6 @@ struct sca3300_data { struct spi_device *spi; struct mutex lock; const struct sca3300_chip_info *chip; - u8 buffer[SCA3300_MAX_BUFFER_SIZE] __aligned(sizeof(s64)); u8 txbuf[4] __aligned(IIO_DMA_MINALIGN); u8 rxbuf[4]; }; @@ -492,7 +479,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, voi= d *p) struct iio_dev *indio_dev =3D pf->indio_dev; struct sca3300_data *data =3D iio_priv(indio_dev); int bit, ret, val, i =3D 0; - s16 *channels =3D (s16 *)data->buffer; + IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX); =20 iio_for_each_active_channel(indio_dev, bit) { ret =3D sca3300_read_reg(data, indio_dev->channels[bit].address, &val); @@ -505,8 +492,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, voi= d *p) channels[i++] =3D val; } =20 - iio_push_to_buffers_with_ts(indio_dev, data->buffer, - sizeof(data->buffer), + iio_push_to_buffers_with_ts(indio_dev, channels, sizeof(channels), iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); --=20 2.43.0