Re: [PATCH v2] iio: core: register chardev only if needed

From: Andy Shevchenko
Date: Wed Dec 09 2020 - 10:19:33 EST


On Thu, Dec 3, 2020 at 11:55 AM Alexandru Ardelean
<alexandru.ardelean@xxxxxxxxxx> wrote:
>
> We only need a chardev if we need to support buffers and/or events.
>
> With this change, a chardev will be created only if an IIO buffer is
> attached OR an event_interface is configured.
>
> Otherwise, no chardev will be created, and the IIO device will get
> registered with the 'device_add()' call.
>
> Quite a lot of IIO devices don't really need a chardev, so this is a minor
> improvement to the IIO core, as the IIO device will take up (slightly)
> fewer resources.
>
> In order to not create a chardev, we mostly just need to not initialize the
> indio_dev->dev.devt field. If that is un-initialized, cdev_device_add()

un-initialized -> uninitialized

> behaves like device_add().

Are you sure there is no user space application that doesn't rely on
character device to be always present?

--
With Best Regards,
Andy Shevchenko