[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1394093630.59639.YahooMailNeo@web164001.mail.gq1.yahoo.com>
Date: Thu, 6 Mar 2014 00:13:50 -0800 (PST)
From: Chase Southwood <chase.southwood@...oo.com>
To: Ian Abbott <abbotti@....co.uk>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Cc: Ian Abbott <ian.abbott@....co.uk>,
"hsweeten@...ionengravers.com" <hsweeten@...ionengravers.com>,
"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] Staging: comedi: convert while loops to timeouts in s626.c
>On Wednesday, March 5, 2014 6:10 AM, Ian Abbott <abbotti@....co.uk> wrote:
>>On 2014-03-04 08:43, Chase Southwood wrote:
>>This patch changes a handful of while loops to timeouts to prevent
>>infinite looping on hardware failure. A couple such loops are in a
>>function (s626_debi_transfer()) which is called from critical sections,
>>so comedi_timeout() is unusable for them, and an iterative timeout is
>>used instead. For the while loops in a context where comedi_timeout() is
>>allowed, a new callback function, s626_send_dac_eoc(), has been defined
>>to evaluate the conditions that the while loops are testing. The new
>>callback employs a switch statement based on the register offset values
>>that the status is to be checked from, as this information is enough to
>>recreate the entire readl() call, and is passed in the 'context'
>>parameter. A couple of additional macros have been defined where this
>>method is not completely sufficient. The proper comedi_timeout() calls
>>are then used.
>>
>>Signed-off-by: Chase Southwood <chase.southwood@...oo.com>
>>---
>>Ian, my idea for the callback function here is a bit iffy, I'd love to
>>hear your feedback. I've created the ret variable because patch 2/2
>>propogates all errors upwards.
>>
>>2: Now using comedi_timeout() where allowable.
[snip]
>Rather than switching on a value that is either a register offset or
>some special value, it might be better to use an enum to define the
>context values you are switching on, e.g.:
>
>enum {
> s626_send_dac_wait_not_mc1_a2out,
> s626_send_dac_wait_ssr_af2_out,
> s626_send_dac_wait_fb_buffer2_msb_00,
> s626_send_dac_wait_fb_buffer2_msb_ff
>};
>
>Alternatively, different callback functions could be used for each case.
Ian,
Ah yes...this is much smarter than what I was trying before. I've made
up a patch using this enum, and tomorrow I will get PATCH 2/2 rebased
and get a v2 of this patchset sent out.
Thanks,
Chase
>One slight oddity about the original code that waits for the MSB of FB
>BUFFER2 to go from 0x00 to 0xFF is that it actually waits for it to
>become non-zero. I'm presuming the intermediate values between 0x00 and
>0xFF are never seen. (There is a non-Comedi, GPL'ed, Linux driver
>available from Sensoray that makes the same assumption, but I think the
>Comedi driver was derived from it.)
>
[snip]
>--
>-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@....co.uk> )=-
>-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
>--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists