2015-04-01 08:44:42

by Rodolfo Giometti

[permalink] [raw]
Subject: Re: [PATCH] pps: Add support for read operations and return a useful value in poll

On Tue, Mar 31, 2015 at 11:31:22PM +0200, Christian Riesch wrote:
> The PPS_FETCH ioctl in drivers/pps/pps.c blocks until a new PPS event
> occurs, then returns the time stamp data. While this is fine for
> lots of applications, sometimes it would be nice if the poll system
> call and a subsequent read could be used to obtain the pps data.

Nak. The read syscall can't be forced to return fix amount of
data.

Use a dedicated ioctl instead.

Ciao,

Rodolfo

--

HCE Engineering e-mail: [email protected]
GNU/Linux Solutions [email protected]
Linux Device Driver [email protected]
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti
Cosino Project - the quick prototyping embedded system - http://www.cosino.io
Freelance ICT Italia - Consulente ICT Italia - http://www.consulenti-ict.it


2015-04-01 11:56:38

by Christian Riesch

[permalink] [raw]
Subject: Re: [PATCH] pps: Add support for read operations and return a useful value in poll

Hi Rodolfo,

Thanks for your reply!

On Wed, Apr 1, 2015 at 10:11 AM, Rodolfo Giometti <[email protected]> wrote:
> On Tue, Mar 31, 2015 at 11:31:22PM +0200, Christian Riesch wrote:
>> The PPS_FETCH ioctl in drivers/pps/pps.c blocks until a new PPS event
>> occurs, then returns the time stamp data. While this is fine for
>> lots of applications, sometimes it would be nice if the poll system
>> call and a subsequent read could be used to obtain the pps data.
>
> Nak. The read syscall can't be forced to return fix amount of
> data.

I just copied/modified the behavior of ptp_read() in drivers/ptp/ptp_chardev.c:

if (cnt % sizeof(struct ptp_extts_event) != 0)
return -EINVAL;

There the amount of data is forced to be a multiple of sizeof(struct
ptp_extts_event). But if you prefer an ioctl, I can change that of
course.

>
> Use a dedicated ioctl instead.

Is it ok to pair POLLIN | POLLRDNORM in the poll function with an
ioctl? Or should returning POLLIN | POLLRDNORM mean that a read() will
not block? Should I use POLLPRI instead or something else?

Regards, Christian

2015-04-01 12:01:42

by Christian Riesch

[permalink] [raw]
Subject: Re: [PATCH] pps: Add support for read operations and return a useful value in poll

[sent again with Rodolfo in the list of recipients, something went
wrong, sorry!]

Hi Rodolfo,

Thanks for your reply!

On Wed, Apr 1, 2015 at 10:11 AM, Rodolfo Giometti <[email protected]> wrote:
> On Tue, Mar 31, 2015 at 11:31:22PM +0200, Christian Riesch wrote:
>> The PPS_FETCH ioctl in drivers/pps/pps.c blocks until a new PPS event
>> occurs, then returns the time stamp data. While this is fine for
>> lots of applications, sometimes it would be nice if the poll system
>> call and a subsequent read could be used to obtain the pps data.
>
> Nak. The read syscall can't be forced to return fix amount of
> data.

I just copied/modified the behavior of ptp_read() in drivers/ptp/ptp_chardev.c:

if (cnt % sizeof(struct ptp_extts_event) != 0)
return -EINVAL;

There the amount of data is forced to be a multiple of sizeof(struct
ptp_extts_event). But if you prefer an ioctl, I can change that of
course.

> Use a dedicated ioctl instead.

Is it ok to pair POLLIN | POLLRDNORM in the poll function with an
ioctl? Or should returning POLLIN | POLLRDNORM mean that a read() will
not block? Should I use POLLPRI instead or something else?

Regards, Christian