Re: [PATCH 34/47 v2] staging: comedi: icp_multi: use comedi_timeout()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 10, 2014 at 11:49:33AM -0700, H Hartley Sweeten wrote:
> Use comedi_timeout() to wait for the analog input and output end-of-
> conversion.
> 
> Use break to exit the loop when a timeout occurs during the analog
> input read so that common code can be used to disable the device.
> 
> Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
> Cc: Ian Abbott <abbotti@xxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/staging/comedi/drivers/icp_multi.c | 104 +++++++++++++++--------------
>  1 file changed, 54 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c
> index 19c586b..7fb6ca0 100644
> --- a/drivers/staging/comedi/drivers/icp_multi.c
> +++ b/drivers/staging/comedi/drivers/icp_multi.c
> @@ -171,12 +171,27 @@ static void setup_channel_list(struct comedi_device *dev,
>  	}
>  }
>  
> +static int icp_multi_ai_eoc(struct comedi_device *dev,
> +			    struct comedi_subdevice *s,
> +			    struct comedi_insn *insn,
> +			    unsigned long context)
> +{
> +	struct icp_multi_private *devpriv = dev->private;
> +	unsigned int status;
> +
> +	status = readw(devpriv->io_addr + ICP_MULTI_ADC_CSR);
> +	if ((status & ADC_BSY) == 0)
> +		return 0;
> +	return -EBUSY;
> +}
> +
>  static int icp_multi_insn_read_ai(struct comedi_device *dev,
>  				  struct comedi_subdevice *s,
>  				  struct comedi_insn *insn, unsigned int *data)
>  {
>  	struct icp_multi_private *devpriv = dev->private;
> -	int n, timeout;
> +	int ret = 0;
> +	int n;
>  
>  	/*  Disable A/D conversion ready interrupt */
>  	devpriv->IntEnable &= ~ADC_READY;
> @@ -199,33 +214,14 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev,
>  		udelay(1);
>  
>  		/*  Wait for conversion to complete, or get fed up waiting */
> -		timeout = 100;
> -		while (timeout--) {
> -			if (!(readw(devpriv->io_addr +
> -				    ICP_MULTI_ADC_CSR) & ADC_BSY))
> -				goto conv_finish;
> -
> -			udelay(1);
> +		ret = comedi_timeout(dev, s, insn, icp_multi_ai_eoc, 0);
> +		if (ret) {
> +			comedi_error(dev, "A/D insn timeout");
> +			/*  Clear data received */
> +			data[n] = 0;
> +			break;
>  		}
>  
> -		/*  If we reach here, a timeout has occurred */
> -		comedi_error(dev, "A/D insn timeout");
> -
> -		/*  Disable interrupt */
> -		devpriv->IntEnable &= ~ADC_READY;
> -		writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN);
> -
> -		/*  Clear interrupt status */
> -		devpriv->IntStatus |= ADC_READY;
> -		writew(devpriv->IntStatus,
> -		       devpriv->io_addr + ICP_MULTI_INT_STAT);
> -

How come these writew() calls are removed?  Don't we still need to do
them in failure mode?

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux