[PATCH 01/18] staging: comedi: comedidev.h: add 'scans_done' member to comedi_async
Hartley Sweeten
HartleyS at visionengravers.com
Wed Nov 5 16:31:17 UTC 2014
On Wednesday, November 05, 2014 4:25 AM, Ian Abbott wrote:
> On 04/11/14 16:50, H Hartley Sweeten wrote:
>> Introduce a new member to comedi_async to count the number of scans completed.
>> This member is cleared by comedi_buf_reset() along with the other comedi_async
>> members. It is incremented in comedi_inc_scan_progress() when the end of scan
>> is detected.
>>
>> This member will be used to clean up the scan counting in the comedi drivers.
>>
>> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
>> Cc: Ian Abbott <abbotti at mev.co.uk>
>> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
>> ---
>> drivers/staging/comedi/comedi_buf.c | 1 +
>> drivers/staging/comedi/comedidev.h | 2 ++
>> drivers/staging/comedi/drivers.c | 1 +
>> 3 files changed, 4 insertions(+)
[snip]
>> diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
>> index 9a8c5fc..4fc992b 100644
>> --- a/drivers/staging/comedi/drivers.c
>> +++ b/drivers/staging/comedi/drivers.c
>> @@ -352,6 +352,7 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s,
>>
>> async->scan_progress += num_bytes;
>> if (async->scan_progress >= scan_length) {
>> + async->scans_done += async->scan_progress / scan_length;
>> async->scan_progress %= scan_length;
>> async->events |= COMEDI_CB_EOS;
>> }
>>
>
> The patch is fine, but as a follow-up patch, async->scans_done could be
> clamped to UINT_MAX (or possibly async->cmd.stop_arg, but UINT_MAX is
> easier), e.g.:
>
> unsigned int scans = async->scan_progress / scan_length;
>
> if (async->scans_done < UINT_MAX - scans)
> async->scans_done += scans;
> else
> async->scans_done = UINT_MAX;
> async->scan_progress -= scans * scan_length;
> async->events |= COMEDI_CB_EOS;
Ian,
As you pointed out, I need to fix patch 12 so I will also update this one for
the v2 series.
Thanks,
Hartley
More information about the devel
mailing list