lkml.org 
[lkml]   [2020]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 4/5] docs: counter: Document character device interface
On Thu, Oct 08, 2020 at 10:09:09AM +0200, Pavel Machek wrote:
> Hi!
>
> > + int main(void)
> > + {
> > + struct pollfd pfd = { .events = POLLIN };
> > + struct counter_event event_data[2];
> > +
> > + pfd.fd = open("/dev/counter0", O_RDWR);
> > +
> > + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches);
> > + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches + 1);
> > + ioctl(pfd.fd, COUNTER_LOAD_WATCHES_IOCTL);
> > +
> > + for (;;) {
> > + poll(&pfd, 1, -1);
>
> Why do poll, when you are doing blocking read?
>
> > + read(pfd.fd, event_data, sizeof(event_data));
>
> Does your new chrdev always guarantee returning complete buffer?
>
> If so, should it behave like that?
>
> Best regards,
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

I suppose you're right: a poll() should be redundant now with this
version of the character device implementation because buffers will
always return complete; so a blocking read() should achieve the same
behavior that a poll() with read() would.

I'll give some more time for additional feedback to come in for this
version of the patchset, and then likely remove support for poll() in
the v6 submission.

William Breathitt Gray
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-10-08 14:30    [W:0.090 / U:4.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site