Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: dln2-adc: zero full struct instead of just the padding

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>
Link: https://patch.msgid.link/20241214191421.94172-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Vasileios Amoiridis and committed by
Jonathan Cameron
6fcabe62 88ff5304

+2 -19
+2 -19
drivers/iio/adc/dln2-adc.c
··· 66 66 /* Demux table */ 67 67 unsigned int demux_count; 68 68 struct dln2_adc_demux_table demux[DLN2_ADC_MAX_CHANNELS]; 69 - /* Precomputed timestamp padding offset and length */ 70 - unsigned int ts_pad_offset, ts_pad_length; 71 69 }; 72 70 73 71 struct dln2_adc_port_chan { ··· 109 111 if (iio_get_masklength(indio_dev) && 110 112 (*indio_dev->active_scan_mask & 0xff) == 0xff) { 111 113 dln2_adc_add_demux(dln2, 0, 0, 16); 112 - dln2->ts_pad_offset = 0; 113 - dln2->ts_pad_length = 0; 114 114 return; 115 115 } 116 116 ··· 122 126 dln2_adc_add_demux(dln2, in_loc, out_loc, 2); 123 127 out_loc += 2; 124 128 in_loc += 2; 125 - } 126 - 127 - if (indio_dev->scan_timestamp) { 128 - size_t ts_offset = indio_dev->scan_bytes / sizeof(int64_t) - 1; 129 - 130 - dln2->ts_pad_offset = out_loc; 131 - dln2->ts_pad_length = ts_offset * sizeof(int64_t) - out_loc; 132 - } else { 133 - dln2->ts_pad_offset = 0; 134 - dln2->ts_pad_length = 0; 135 129 } 136 130 } 137 131 ··· 480 494 if (ret < 0) 481 495 goto done; 482 496 497 + memset(&data, 0, sizeof(data)); 498 + 483 499 /* Demux operation */ 484 500 for (i = 0; i < dln2->demux_count; ++i) { 485 501 t = &dln2->demux[i]; 486 502 memcpy((void *)data.values + t->to, 487 503 (void *)dev_data.values + t->from, t->length); 488 504 } 489 - 490 - /* Zero padding space between values and timestamp */ 491 - if (dln2->ts_pad_length) 492 - memset((void *)data.values + dln2->ts_pad_offset, 493 - 0, dln2->ts_pad_length); 494 505 495 506 iio_push_to_buffers_with_timestamp(indio_dev, &data, 496 507 iio_get_time_ns(indio_dev));