From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753565AbbDAMBm (ORCPT ); Wed, 1 Apr 2015 08:01:42 -0400 Received: from mail-ob0-f182.google.com ([209.85.214.182]:32839 "EHLO mail-ob0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753029AbbDAMBh (ORCPT ); Wed, 1 Apr 2015 08:01:37 -0400 MIME-Version: 1.0 In-Reply-To: <20150401081133.GA4384@enneenne.com> References: <1427837482-2841-1-git-send-email-christian.riesch@omicron.at> <20150401081133.GA4384@enneenne.com> Date: Wed, 1 Apr 2015 14:01:36 +0200 X-Google-Sender-Auth: JIx1UlZJK20WN5xih26aN2eZ85Y Message-ID: Subject: Re: [PATCH] pps: Add support for read operations and return a useful value in poll From: Christian Riesch To: "linux-kernel@vger.kernel.org" , Rodolfo Giometti Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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 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