[LinuxPPS] [PATCH] PPS: Add a read() method

Bernhard Schiffner bernhard at schiffner-limbach.de
Mon Feb 9 16:49:44 CET 2009


On Monday 09 February 2009 15:16:21 George Spelvin wrote:
Hi,
...
>
> Okay, here's a first draft.  The locking is stolen from fs/sysfs/file.c,
> because it appears that multiple threads can call a ->read method in
> parallel.  The same applies to unlocked_ioctl, AFAICT, so maybe we need
> something there, too.
Better this way.
...
> +		/* At most 6+1+10+1+20+1+9+1 = 49 bytes */
> +		data->len = sprintf(data->buf, "%s %u %lld.%09d\n",
> +				which ? "clear" : "assert",
> +				(unsigned)seq[which],
> +				(long long)tu[which].sec, tu[which].nsec);
> +		data->pos = 0;
> +		BUG_ON(data->len > PPS_LINE_SIZE);
...
That's what I want to see!
cat /dev/pps* is by far the easiest method for checking pps-functionality 
working. The RCF is IHMO not clear in this case.
Please try to get it "available" (better in).

I didn't read the code very careful but is it guaranteed, that multiple reads 
will get the same data until a new event is registered?
(reading /dev/ttyS* the data gone after the first read...)

Thanks!

Bernhard

PS:
+               case PPS_CAPTUREBOTH:
+                       /* Select the earlier timestamp */
+                       if (tu[0].sec != tu[1].sec)
+                               which = tu[0].sec > tu[1].sec;
+                       else
+                               which = tu[0].nsec > tu[1].nsec;
+                       break;
You use the var which here to determine if the output is marked clear or 
assert.
Are you _sure_ that this is bound to the first in order here? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ml.enneenne.com/pipermail/linuxpps/attachments/20090209/1d4a97e3/attachment.htm 


More information about the LinuxPPS mailing list