Patch "misc: ioc4: simplify wave period measurement in clock_calibrate" has been added to the 3.18-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
misc: ioc4: simplify wave period measurement in clock_calibrate
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
misc-ioc4-simplify-wave-period-measurement-in-clock_calibrate.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
769105aa740dc0428f2585ec99c457d30aaab364Mon Sep 17 00:00:00 2001
From: Richard Leitner <[email protected]>
Date: Mon, 8 Dec 2014 16:28:10 +0100
Subject: misc: ioc4: simplify wave period measurement in clock_calibrate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Richard Leitner <[email protected]>
commit 769105aa740dc0428f2585ec99c457d30aaab364 upstream.
The loop for measuring the square wave periods over some cycles is refactored to be more easily readable. This includes avoiding a "by-hand-implemented" for loop with a "real" one and adding some comments.
Furthermore the following compiler warning is avoided by this patch:drivers/misc/ioc4.c: In function ‘ioc4_probe’:drivers/misc/ioc4.c:194:16: warning: ‘start’ may be used uninitialized in this function [-Wmaybe-uninitialized]
period = (end - start) /
^
drivers/misc/ioc4.c:148:11: note: ‘start’ was declared here
uint64_t start, end, period;
^--- drivers/misc/ioc4.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/misc/ioc4.c +16 -15
@@ -144,9 +144,9 @@ ioc4_clock_calibrate(struct ioc4_driver_ {union ioc4_int_out int_out;union ioc4_gpcr gpcr; -unsigned int state, last_state =1 ; +unsigned int state, last_state;uint64_t start, end, period; -unsigned int count =0 ; +unsigned int count;/* Enable output */ gpcr.raw =0 ;
@@ -167,19 +167,20 @@ ioc4_clock_calibrate(struct ioc4_driver_mmiowb ();/* Check square wave period averaged over some number of cycles */ -do { - int_out.raw =readl (&idd->idd_misc_regs->int_out.raw); - state = int_out.fields.int_out; -if (!last_state && state) { - count++; -if (count ==IOC4_CALIBRATE_END ) { - end =ktime_get_ns (); -break ; - }else if (count ==IOC4_CALIBRATE_DISCARD ) - start =ktime_get_ns (); - } - last_state = state; - }while (1 ); + start =ktime_get_ns (); + state =1 ;/* make sure the first read isn't a rising edge */ +for (count =0 ; count <=IOC4_CALIBRATE_END ; count++) { +do {/* wait for a rising edge */ + last_state = state; + int_out.raw =readl (&idd->idd_misc_regs->int_out.raw); + state = int_out.fields.int_out; + }while (last_state || !state); + +/* discard the first few cycles */ +if (count ==IOC4_CALIBRATE_DISCARD ) + start =ktime_get_ns (); + } + end =ktime_get_ns ();/* Calculation rearranged to preserve intermediate precision. * Logically:
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/misc-ioc4-simplify-wave-period-measurement-in-clock_calibrate.patch