Re: [PATCH 23/29] iio: adc: max1027: Move claim of direct mode up one level and use guard()

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

 



>  
> @@ -382,37 +374,33 @@ static int max1027_read_raw(struct iio_dev *indio_dev,
>  	int ret = 0;
>  	struct max1027_state *st = iio_priv(indio_dev);
>  
> -	mutex_lock(&st->lock);
> +	guard(mutex)(&st->lock);
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
> +		ret = iio_device_claim_direct_mode(indio_dev);
> +		if (ret)
> +			return ret
Naughty me. I clearly didn't build test between this patch and next one.

Fixed up to maintain bisectability.

> +
>  		ret = max1027_read_single_value(indio_dev, chan, val);
> -		break;
> +		iio_device_release_direct_mode(indio_dev);
> +		return ret;
>  	case IIO_CHAN_INFO_SCALE:
>  		switch (chan->type) {
>  		case IIO_TEMP:
>  			*val = 1;
>  			*val2 = 8;
> -			ret = IIO_VAL_FRACTIONAL;
> -			break;
> +			return IIO_VAL_FRACTIONAL;
>  		case IIO_VOLTAGE:
>  			*val = 2500;
>  			*val2 = chan->scan_type.realbits;
> -			ret = IIO_VAL_FRACTIONAL_LOG2;
> -			break;
> +			return IIO_VAL_FRACTIONAL_LOG2;
>  		default:
> -			ret = -EINVAL;
> -			break;
> +			return -EINVAL;
>  		}
> -		break;
>  	default:
> -		ret = -EINVAL;
> -		break;
> +		return -EINVAL;
>  	}
> -
> -	mutex_unlock(&st->lock);
> -
> -	return ret;
>  }
>  
>  static int max1027_debugfs_reg_access(struct iio_dev *indio_dev,





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux