]> git.baikalelectronics.ru Git - kernel.git/commit
iio: core: wrap IIO device into an iio_dev_opaque object
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Tue, 30 Jun 2020 04:57:03 +0000 (07:57 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 7 Jul 2020 19:24:06 +0000 (20:24 +0100)
commit590ddb1a0e4eea2c6a663bdf0bc2c581a648c273
treea5bedce338cf3988968f094b718b98ba0c8c419d
parent1668d20d9df25c3c9265350df94031c0dad4ea4c
iio: core: wrap IIO device into an iio_dev_opaque object

There are plenty of bad designs we want to discourage or not have to review
manually usually about accessing private (marked as [INTERN]) fields of
'struct iio_dev'.

Sometimes users copy drivers that are not always the best examples.

A better idea is to hide those fields into the framework.
For 'struct iio_dev' this is a 'struct iio_dev_opaque' which wraps a public
'struct iio_dev' object.

In the next series, some fields will be moved to this new struct, each with
it's own rework.

This rework will not be complete-able for a while, as many fields need some
drivers to be reworked in order to finalize them (e.g. 'indio_dev->mlock').

But some fields can already be moved, and in time, all of them may get
there (in the 'struct iio_dev_opaque' object).

Since a lot of drivers also call 'iio_priv()', in order to preserve
fast-paths (where this matters), the public iio_dev object will have a
'priv' field that will have the pointer to the private information already
computed. The reference returned by this field should be guaranteed to be
cacheline aligned.

The opaque parts will be moved into the 'include/linux/iio/iio-opaque.h'
header. Should the hidden information be required for some debugging or
some special needs, it can be made available via this header.
Otherwise, only the IIO core files should include this file.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-core.c
include/linux/iio/iio-opaque.h [new file with mode: 0644]
include/linux/iio/iio.h