From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992795AbcBSQPO (ORCPT ); Fri, 19 Feb 2016 11:15:14 -0500 Received: from smtp73.iad3a.emailsrvr.com ([173.203.187.73]:47081 "EHLO smtp73.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1949076AbcBSQON (ORCPT ); Fri, 19 Feb 2016 11:14:13 -0500 X-Auth-ID: abbotti@mev.co.uk X-Sender-Id: abbotti@mev.co.uk From: Ian Abbott To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , linux-kernel@vger.kernel.org Subject: [PATCH 6/8] staging: comedi: COMEDI_BUFINFO: become non-busy even if bytes_read is 0 Date: Fri, 19 Feb 2016 16:13:55 +0000 Message-Id: <1455898437-4640-7-git-send-email-abbotti@mev.co.uk> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455898437-4640-1-git-send-email-abbotti@mev.co.uk> References: <1455898437-4640-1-git-send-email-abbotti@mev.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The `COMEDI_BUFINFO` ioctl is used to advance the current position in the buffer by a specified amount (which can be 0) and get the new position. On input, the `bytes_read` member of `struct comedi_bufinfo` specified the amount to advance the "read" position for an asynchronous command in the "read" direction. If the command has already stopped normally, and the "read" position has been advanced to the end of all available data, the command is terminated by calling `do_become_nonbusy()`. (That is not currently done if the command stopped with an error.) Currently, the command is only terminated if the user is trying to advance the "read" position by a non-zero amount. Change it to allow the command to be terminated even if the user is not trying to advance the "read" position. This is justifiable, as the only time a command stops without error is when it has been set up to read a finite amount of data. Signed-off-by: Ian Abbott --- drivers/staging/comedi/comedi_fops.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index a9fabf7..ffe58208 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1131,11 +1131,10 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (bi.bytes_read) { comedi_buf_read_alloc(s, bi.bytes_read); bi.bytes_read = comedi_buf_read_free(s, bi.bytes_read); - - if (comedi_is_subdevice_idle(s) && - comedi_buf_read_n_available(s) == 0) - become_nonbusy = true; } + if (comedi_is_subdevice_idle(s) && + comedi_buf_read_n_available(s) == 0) + become_nonbusy = true; bi.bytes_written = 0; } else { /* command was set up in "write" direction */ -- 2.7.0