public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Sanity-check available_scan_masks array
@ 2023-10-16 11:04 Matti Vaittinen
  2023-10-16 11:04 ` [PATCH v2 1/2] iio: sanity check " Matti Vaittinen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Matti Vaittinen @ 2023-10-16 11:04 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]

Sanity-check available_scan_masks array

The available_scan_masks is an array of bitmasks representing the
channels which can be simultaneously(*) scanned by a driver from the
device. Following special characteristics apply:

- When IIO is scanning through the array it will use the first mask
  which can be used to scan all enabled channels. This means drivers
  should order the array in the order of the preference. This does also
  mean that a mask which is a subset of a mask located earler in array
  will never be used because the earlier one will be picked by the core.
- Masks wider than size of long are supported only to some extent. The
  code scanning through the array will interpret the first mask with
  first long zeroed as end-of-array terminator. Changing this behaviour
  would make mask-arrays for multi-long masks to be terminated by more
  than one zero long. Failure to do so would result kernel to read
  beyond the array generating a potentially hazardous bug.

Add a sanity-check to IIO-device registration emitting a warning if
available_scan_mask array is misordered or if mask width is larger than
a long while available_scan_mask-array is populated. Currently there
should be no in-tree drivers with available_scan_mask populated and mask
wider than a long.

Revision history:
v1 => v2:
	- Add patch 2/2 documenting why iio_scan_mask_match() checks only
	  a long worth of bits while searching for the end of the
	  available_scan_mask-array.
	- Styling of patch 1/2 as per comments from Jonathan
	v1 and related discussion here:
	https://lore.kernel.org/lkml/ZRvjuZaQWdZw1U1I@dc78bmyyyyyyyyyyyyydt-3.rev.dnainternet.fi/

Matti Vaittinen (2):
  iio: sanity check available_scan_masks array
  iio: buffer: document known issue

 drivers/iio/industrialio-buffer.c | 16 ++++++++
 drivers/iio/industrialio-core.c   | 63 +++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

-- 
2.41.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-10-29 15:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-16 11:04 [PATCH v2 0/2] Sanity-check available_scan_masks array Matti Vaittinen
2023-10-16 11:04 ` [PATCH v2 1/2] iio: sanity check " Matti Vaittinen
2023-10-16 11:04 ` [PATCH v2 2/2] iio: buffer: document known issue Matti Vaittinen
2023-10-21 15:55 ` [PATCH v2 0/2] Sanity-check available_scan_masks array Jonathan Cameron
2023-10-21 16:03   ` Matti Vaittinen
2023-10-28 16:32     ` Jonathan Cameron
2023-10-29 15:28       ` Matti Vaittinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox