Kaynağa Gözat

Staging: iio: accel: adis16201: Add comments about units in read_raw()

Clarify the conversion and formation of resultant data in the
adis16201_read_raw() with sufficient comments and remove the unnecessary
comments.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Himanshu Jha 7 yıl önce
ebeveyn
işleme
57f9386405
1 değiştirilmiş dosya ile 18 ekleme ve 9 silme
  1. 18 9
      drivers/staging/iio/accel/adis16201.c

+ 18 - 9
drivers/staging/iio/accel/adis16201.c

@@ -120,31 +120,43 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
 		switch (chan->type) {
 		switch (chan->type) {
 		case IIO_VOLTAGE:
 		case IIO_VOLTAGE:
 			if (chan->channel == 0) {
 			if (chan->channel == 0) {
+			/* Voltage base units are mV hence 1.22 mV */
 				*val = 1;
 				*val = 1;
-				*val2 = 220000; /* 1.22 mV */
+				*val2 = 220000;
 			} else {
 			} else {
+			/* Voltage base units are mV hence 0.61 mV */
 				*val = 0;
 				*val = 0;
-				*val2 = 610000; /* 0.610 mV */
+				*val2 = 610000;
 			}
 			}
 			return IIO_VAL_INT_PLUS_MICRO;
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_TEMP:
 		case IIO_TEMP:
-			*val = -470; /* 0.47 C */
+			*val = -470;
 			*val2 = 0;
 			*val2 = 0;
 			return IIO_VAL_INT_PLUS_MICRO;
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_ACCEL:
 		case IIO_ACCEL:
+			/*
+			 * IIO base unit for sensitivity of accelerometer
+			 * is milli g.
+			 * 1 LSB represents 0.244 mg.
+			 */
 			*val = 0;
 			*val = 0;
-			*val2 = IIO_G_TO_M_S_2(462400); /* 0.4624 mg */
+			*val2 = IIO_G_TO_M_S_2(462400);
 			return IIO_VAL_INT_PLUS_NANO;
 			return IIO_VAL_INT_PLUS_NANO;
 		case IIO_INCLI:
 		case IIO_INCLI:
 			*val = 0;
 			*val = 0;
-			*val2 = 100000; /* 0.1 degree */
+			*val2 = 100000;
 			return IIO_VAL_INT_PLUS_MICRO;
 			return IIO_VAL_INT_PLUS_MICRO;
 		default:
 		default:
 			return -EINVAL;
 			return -EINVAL;
 		}
 		}
 		break;
 		break;
 	case IIO_CHAN_INFO_OFFSET:
 	case IIO_CHAN_INFO_OFFSET:
-		*val = 25000 / -470 - 1278; /* 25 C = 1278 */
+		/*
+		 * The raw ADC value is 1278 when the temperature
+		 * is 25 degrees and the scale factor per milli
+		 * degree celcius is -470.
+		 */
+		*val = 25000 / -470 - 1278;
 		return IIO_VAL_INT;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_CALIBBIAS:
 	case IIO_CHAN_INFO_CALIBBIAS:
 		switch (chan->type) {
 		switch (chan->type) {
@@ -252,13 +264,11 @@ static int adis16201_probe(struct spi_device *spi)
 	struct adis *st;
 	struct adis *st;
 	struct iio_dev *indio_dev;
 	struct iio_dev *indio_dev;
 
 
-	/* setup the industrialio driver allocated elements */
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (!indio_dev)
 	if (!indio_dev)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	st = iio_priv(indio_dev);
 	st = iio_priv(indio_dev);
-	/* this is only used for removal purposes */
 	spi_set_drvdata(spi, indio_dev);
 	spi_set_drvdata(spi, indio_dev);
 
 
 	indio_dev->name = spi->dev.driver->name;
 	indio_dev->name = spi->dev.driver->name;
@@ -277,7 +287,6 @@ static int adis16201_probe(struct spi_device *spi)
 	if (ret)
 	if (ret)
 		return ret;
 		return ret;
 
 
-	/* Get the device into a sane initial state */
 	ret = adis_initial_startup(st);
 	ret = adis_initial_startup(st);
 	if (ret)
 	if (ret)
 		goto error_cleanup_buffer_trigger;
 		goto error_cleanup_buffer_trigger;