lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Jul 2013 18:26:32 +0100
From:	Zubair Lutfullah <zubair.lutfullah@...il.com>
To:	jic23@....ac.uk
Cc:	linux-iio@...r.kernel.org, gregkh@...uxfoundation.org,
	linux-kernel@...r.kernel.org, koen@...inion.thruhere.net,
	zubair.lutfullah@...il.com
Subject: [PATCH 03/21] iio: ti_am335x_adc: Added iio_voltageX_scale

in_voltageX_scale is supposed to give scaled voltages. This was
missing in the driver and has been added.
Current patch is fixed to scale for 1.8V AVDD.

Signed-off-by: Zubair Lutfullah <zubair.lutfullah@...il.com>
---
 drivers/iio/adc/ti_am335x_adc.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 1f83cf7..8a63203 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -26,7 +26,7 @@
 #include <linux/of_device.h>
 #include <linux/iio/machine.h>
 #include <linux/iio/driver.h>
-
+#include <linux/math64.h>
 #include <linux/mfd/ti_am335x_tscadc.h>
 
 struct tiadc_device {
@@ -118,7 +118,8 @@ static int tiadc_channel_init(struct iio_dev *indio_dev, int channels)
 		chan->type = IIO_VOLTAGE;
 		chan->indexed = 1;
 		chan->channel = adc_dev->channel_line[i];
-		chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
+		chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+						BIT(IIO_CHAN_INFO_SCALE);
 		chan->datasheet_name = chan_name_ain[chan->channel];
 		chan->scan_type.sign = 'u';
 		chan->scan_type.realbits = 12;
@@ -190,6 +191,18 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 		}
 	}
 
+	switch (mask){
+		case IIO_CHAN_INFO_RAW : /*Do nothing. Above code works fine.*/
+					break;
+		case IIO_CHAN_INFO_SCALE : {
+			/*12 Bit adc. Scale value for 1800mV AVDD. Ideally
+			AVDD should come from DT.*/
+			*val = div_u64( (u64)(*val) * 1800 , 4096);
+			break;
+		}
+		default: break;
+	}
+
 	if (found == false)
 		return -EBUSY;
 	return IIO_VAL_INT;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ