Thread (23 messages) 23 messages, 3 authors, 2013-08-20

Re: [PATCH 4/4] iio: ti_am335x_adc: Add continuous sampling and trigger support

flat view

From: Sebastian Andrzej Siewior <hidden>
Date: 2013-08-16 13:25:55
Also in: linux-iio, lkml

* Zubair Lutfullah | 2013-08-13 21:05:03 [+0100]:
quoted hunk ↗ jump to hunk
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 3ceac3e..0d7e313 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -141,58 +350,51 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
{
…
quoted hunk ↗ jump to hunk
+	if (iio_buffer_enabled(indio_dev))
+		return -EBUSY;
+	else {
You can drop else so you lose one ident level.
+		unsigned long timeout = jiffies + usecs_to_jiffies
+					(IDLE_TIMEOUT * adc_dev->channels);
What computing this once? ->channels is assigned at probe time.
quoted hunk ↗ jump to hunk
+		step_en = get_adc_step_mask(adc_dev);
+		am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
+
+		/* Wait for ADC sequencer to complete sampling */
+		while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) {
+			if (time_after(jiffies, timeout))
+				return -EAGAIN;
You should check the condition after the timeout occured once again. It
is possible that the task performing the read has been pushed away by a
higher prio task (or preempted incase this sounds like a bully) and
after it got back on the cpu the timeout occured but the condition is
valid and no reason for -EAGAIN.
+			}
and the bracket needs to left by one tab.

Sebastian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help