• Alexandru Ardelean's avatar
    iio: core: wrap IIO device into an iio_dev_opaque object · 6d4ebd56
    Alexandru Ardelean authored
    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: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
    Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    6d4ebd56
industrialio-core.c 46.4 KB