Linux IIO development
 help / color / mirror / Atom feed
From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: jic23@kernel.org, lars@metafoo.de
Cc: krzysztof.kozlowski@linaro.org, nuno.sa@analog.com,
	u.kleine-koenig@baylibre.com, abhashkumarjha123@gmail.com,
	jstephan@baylibre.com, dlechner@baylibre.com,
	jackoalan@gmail.com, k.wrona@samsung.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	vassilisamir@gmail.com
Subject: [PATCH v2 1/4] iio: adc: dln2-adc: zero full struct instead of just the padding
Date: Sat, 14 Dec 2024 20:14:18 +0100	[thread overview]
Message-ID: <20241214191421.94172-2-vassilisamir@gmail.com> (raw)
In-Reply-To: <20241214191421.94172-1-vassilisamir@gmail.com>

Drop a minor optimization of zeroing the padding between data and
timestamp and zero the whole structure. This is done in favor of
simpler code, and in order to drop the usage of the internal private
variable "scan_timestamp" of the struct iio_dev.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
 drivers/iio/adc/dln2-adc.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c
index 30328626d9be..221a5fdc1eaa 100644
--- a/drivers/iio/adc/dln2-adc.c
+++ b/drivers/iio/adc/dln2-adc.c
@@ -66,8 +66,6 @@ struct dln2_adc {
 	/* Demux table */
 	unsigned int demux_count;
 	struct dln2_adc_demux_table demux[DLN2_ADC_MAX_CHANNELS];
-	/* Precomputed timestamp padding offset and length */
-	unsigned int ts_pad_offset, ts_pad_length;
 };
 
 struct dln2_adc_port_chan {
@@ -111,8 +109,6 @@ static void dln2_adc_update_demux(struct dln2_adc *dln2)
 	if (iio_get_masklength(indio_dev) &&
 	    (*indio_dev->active_scan_mask & 0xff) == 0xff) {
 		dln2_adc_add_demux(dln2, 0, 0, 16);
-		dln2->ts_pad_offset = 0;
-		dln2->ts_pad_length = 0;
 		return;
 	}
 
@@ -127,16 +123,6 @@ static void dln2_adc_update_demux(struct dln2_adc *dln2)
 		out_loc += 2;
 		in_loc += 2;
 	}
-
-	if (indio_dev->scan_timestamp) {
-		size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1;
-
-		dln2->ts_pad_offset = out_loc;
-		dln2->ts_pad_length = ts_offset * sizeof(int64_t) - out_loc;
-	} else {
-		dln2->ts_pad_offset = 0;
-		dln2->ts_pad_length = 0;
-	}
 }
 
 static int dln2_adc_get_chan_count(struct dln2_adc *dln2)
@@ -494,6 +480,8 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p)
 	if (ret < 0)
 		goto done;
 
+	memset(&data, 0, sizeof(data));
+
 	/* Demux operation */
 	for (i = 0; i < dln2->demux_count; ++i) {
 		t = &dln2->demux[i];
@@ -501,11 +489,6 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p)
 		       (void *)dev_data.values + t->from, t->length);
 	}
 
-	/* Zero padding space between values and timestamp */
-	if (dln2->ts_pad_length)
-		memset((void *)data.values + dln2->ts_pad_offset,
-		       0, dln2->ts_pad_length);
-
 	iio_push_to_buffers_with_timestamp(indio_dev, &data,
 					   iio_get_time_ns(indio_dev));
 
-- 
2.43.0


  reply	other threads:[~2024-12-14 19:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-14 19:14 [PATCH v2 0/4] iio: mark scan_timestamp as __private Vasileios Amoiridis
2024-12-14 19:14 ` Vasileios Amoiridis [this message]
2024-12-19 17:41   ` [PATCH v2 1/4] iio: adc: dln2-adc: zero full struct instead of just the padding Jonathan Cameron
2024-12-14 19:14 ` [PATCH v2 2/4] iio: adc: max1363: make use of iio_is_soft_ts_enabled() Vasileios Amoiridis
2024-12-19 17:45   ` Jonathan Cameron
2024-12-14 19:14 ` [PATCH v2 3/4] iio: common: ssp_sensors: drop conditional optimization for simplicity Vasileios Amoiridis
2024-12-16 21:57   ` David Lechner
2024-12-17 23:41     ` Vasileios Amoiridis
2024-12-18 15:17       ` David Lechner
2024-12-18 21:13         ` Vasileios Amoiridis
2024-12-19 17:47           ` Jonathan Cameron
2024-12-14 19:14 ` [PATCH v2 4/4] iio: core: mark scan_timestamp as __private Vasileios Amoiridis
2024-12-19 17:49   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241214191421.94172-2-vassilisamir@gmail.com \
    --to=vassilisamir@gmail.com \
    --cc=abhashkumarjha123@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jackoalan@gmail.com \
    --cc=jic23@kernel.org \
    --cc=jstephan@baylibre.com \
    --cc=k.wrona@samsung.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox