lkml.org 
[lkml]   [2014]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 2/2] Staging: comedi: propagate timeout errors in s626.c
Date
This patch for s626.c propagates the errors from the newly introduced
calls to comedi_timeout() as far as possible.

Signed-off-by: Chase Southwood <chase.southwood@yahoo.com>
---
Compile tested only.

drivers/staging/comedi/drivers/s626.c | 63 +++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 5a7e1c0..c6486b0 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -406,7 +406,7 @@ static int s626_send_dac_eoc(struct comedi_device *dev,
* channel 2. Assumes: (1) TSL2 slot records initialized, and (2)
* dacpol contains valid target image.
*/
-static void s626_send_dac(struct comedi_device *dev, uint32_t val)
+static int s626_send_dac(struct comedi_device *dev, uint32_t val)
{
struct s626_private *devpriv = dev->private;
int ret;
@@ -456,8 +456,10 @@ static void s626_send_dac(struct comedi_device *dev, uint32_t val)
* cleared when the transfer has finished.
*/
ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc, S626_P_MC1);
- if (ret)
+ if (ret) {
comedi_error(dev, "DMA transfer timeout.");
+ return ret;
+ }

/* START THE OUTPUT STREAM TO THE TARGET DAC -------------------- */

@@ -478,8 +480,10 @@ static void s626_send_dac(struct comedi_device *dev, uint32_t val)
* to the output buffer register.
*/
ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc, S626_P_SSR);
- if (ret)
+ if (ret) {
comedi_error(dev, "TSL timeout waiting for slot 1 to execute.");
+ return ret;
+ }

/*
* Set up to trap execution at slot 0 when the TSL sequencer cycles
@@ -521,8 +525,10 @@ static void s626_send_dac(struct comedi_device *dev, uint32_t val)
*/
ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
S626_P_FB_BUFFER2_MSB_00);
- if (ret)
+ if (ret) {
comedi_error(dev, "TSL timeout waiting for slot 0 to execute.");
+ return ret;
+ }
}
/*
* Either (1) we were too late setting the slot 0 trap; the TSL
@@ -543,14 +549,17 @@ static void s626_send_dac(struct comedi_device *dev, uint32_t val)
*/
ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
S626_P_FB_BUFFER2_MSB_FF);
- if (ret)
+ if (ret) {
comedi_error(dev, "TSL timeout waiting for slot 0 to execute.");
+ return ret;
+ }
+ return 0;
}

/*
* Private helper function: Write setpoint to an application DAC channel.
*/
-static void s626_set_dac(struct comedi_device *dev, uint16_t chan,
+static int s626_set_dac(struct comedi_device *dev, uint16_t chan,
int16_t dacdata)
{
struct s626_private *devpriv = dev->private;
@@ -613,10 +622,10 @@ static void s626_set_dac(struct comedi_device *dev, uint16_t chan,
val |= ((uint32_t)(chan & 1) << 15); /* Address the DAC channel
* within the device. */
val |= (uint32_t)dacdata; /* Include DAC setpoint data. */
- s626_send_dac(dev, val);
+ return s626_send_dac(dev, val);
}

-static void s626_write_trim_dac(struct comedi_device *dev, uint8_t logical_chan,
+static int s626_write_trim_dac(struct comedi_device *dev, uint8_t logical_chan,
uint8_t dac_data)
{
struct s626_private *devpriv = dev->private;
@@ -663,17 +672,22 @@ static void s626_write_trim_dac(struct comedi_device *dev, uint8_t logical_chan,
* Address the DAC channel within the trimdac device.
* Include DAC setpoint data.
*/
- s626_send_dac(dev, (chan << 8) | dac_data);
+ return s626_send_dac(dev, (chan << 8) | dac_data);
}

-static void s626_load_trim_dacs(struct comedi_device *dev)
+static int s626_load_trim_dacs(struct comedi_device *dev)
{
uint8_t i;
+ int ret;

/* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
- for (i = 0; i < ARRAY_SIZE(s626_trimchan); i++)
- s626_write_trim_dac(dev, i,
+ for (i = 0; i < ARRAY_SIZE(s626_trimchan); i++) {
+ ret = s626_write_trim_dac(dev, i,
s626_i2c_read(dev, s626_trimadrs[i]));
+ if (ret)
+ return ret;
+ }
+ return 0;
}

/* ****** COUNTER FUNCTIONS ******* */
@@ -2372,6 +2386,7 @@ static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
{
struct s626_private *devpriv = dev->private;
int i;
+ int ret;
uint16_t chan = CR_CHAN(insn->chanspec);
int16_t dacdata;

@@ -2380,7 +2395,9 @@ static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->ao_readback[CR_CHAN(insn->chanspec)] = data[i];
dacdata -= (0x1fff);

- s626_set_dac(dev, chan, dacdata);
+ ret = s626_set_dac(dev, chan, dacdata);
+ if (ret)
+ return ret;
}

return i;
@@ -2616,12 +2633,13 @@ static int s626_allocate_dma_buffers(struct comedi_device *dev)
return 0;
}

-static void s626_initialize(struct comedi_device *dev)
+static int s626_initialize(struct comedi_device *dev)
{
struct s626_private *devpriv = dev->private;
dma_addr_t phys_buf;
uint16_t chan;
int i;
+ int ret;

/* Enable DEBI and audio pins, enable I2C interface */
s626_mc_enable(dev, S626_MC1_DEBI | S626_MC1_AUDIO | S626_MC1_I2C,
@@ -2822,7 +2840,9 @@ static void s626_initialize(struct comedi_device *dev)
* sometimes causes the first few TrimDAC writes to malfunction.
*/
s626_load_trim_dacs(dev);
- s626_load_trim_dacs(dev);
+ ret = s626_load_trim_dacs(dev);
+ if (ret)
+ return ret;

/*
* Manually init all gate array hardware in case this is a soft
@@ -2836,8 +2856,11 @@ static void s626_initialize(struct comedi_device *dev)
* Init all DAC outputs to 0V and init all DAC setpoint and
* polarity images.
*/
- for (chan = 0; chan < S626_DAC_CHANNELS; chan++)
- s626_set_dac(dev, chan, 0);
+ for (chan = 0; chan < S626_DAC_CHANNELS; chan++) {
+ ret = s626_set_dac(dev, chan, 0);
+ if (ret)
+ return ret;
+ }

/* Init counters */
s626_counters_init(dev);
@@ -2853,6 +2876,8 @@ static void s626_initialize(struct comedi_device *dev)

/* Initialize the digital I/O subsystem */
s626_dio_init(dev);
+
+ return 0;
}

static int s626_auto_attach(struct comedi_device *dev,
@@ -2973,7 +2998,9 @@ static int s626_auto_attach(struct comedi_device *dev,
s->insn_read = s626_enc_insn_read;
s->insn_write = s626_enc_insn_write;

- s626_initialize(dev);
+ ret = s626_initialize(dev);
+ if (ret)
+ return ret;

return 0;
}
--
1.8.5.3


\
 
 \ /
  Last update: 2014-03-04 10:21    [W:0.218 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site