As Greg said, this is a traditional way. I'd maybe allow dummy reads/writes if 
permissions allow, but keep that logic in vfs by checking if the pointer is 
initialized. Then you don't need to provide the dummy implementation in every 
driver. 

Petro Karashchenko kirjoitti lauantai 2. huhtikuuta 2022:
> 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