Hello Gregory,

Do you recommend not to allow registration of a driver that does not have
read method and make a requirement for the driver to provide at least dummy
read?

Best regards,
Petro

On Fri, Apr 1, 2022, 9:48 PM Gregory Nutt <[email protected]> wrote:

>
> > One option, conforming standard, would be that you just always give
> O_RDWR (same flags as what linux devices have), but then when calling
> read/write you check if the pointer is non-null. If the driver doesn't
> define read or write, those operations are allowed on the device, but act
> as no-op.
>
> If you can't think of anything useful to do with read() or write(),
> thenthis has been historically handled is by including a dummy read
> method in the driver that just returns zero (EOF).  For example, the
> loop driver:
>
>
> /****************************************************************************
>   * Name: loop_read
>
>   
> ****************************************************************************/
>
> static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
>                           size_t len)
> {
>    return 0; /* Return EOF */
> }
> *
> *
>

Reply via email to