aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adcxx.c
diff options
context:
space:
mode:
authorJosé Miguel Gonçalves <jose.goncalves@inov.pt>2010-03-05 16:43:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 14:26:45 -0500
commit5748150eabdacd3f870c311b63d32f5e312bf624 (patch)
treede0aa06ad69a2ff2f9896ce4d8523ee84d699555 /drivers/hwmon/adcxx.c
parent4cae787840ae82aa02649f45c46839b349034435 (diff)
drivers/hwmon/adcxx.c: fix for single-channel ADCs
While testing an ADC121S021 in an embedded board with a S3C2142 SoC (ARM core), I have found that the 'adcxx' driver does not handle correctly single channel ADCs from this chip family. For single channel chips you must only issue one read transfer for correct measurement. Signed-off-by: Jose Miguel Goncalves <jose.goncalves@inov.pt> Cc: Marc Pignat <marc.pignat@hevs.ch> Cc: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/adcxx.c')
-rw-r--r--drivers/hwmon/adcxx.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index 5e9e095f113..74d9c5195e4 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -62,18 +62,23 @@ static ssize_t adcxx_read(struct device *dev,
62 struct spi_device *spi = to_spi_device(dev); 62 struct spi_device *spi = to_spi_device(dev);
63 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 63 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
64 struct adcxx *adc = dev_get_drvdata(&spi->dev); 64 struct adcxx *adc = dev_get_drvdata(&spi->dev);
65 u8 tx_buf[2] = { attr->index << 3 }; /* other bits are don't care */ 65 u8 tx_buf[2];
66 u8 rx_buf[2]; 66 u8 rx_buf[2];
67 int status; 67 int status;
68 int value; 68 u32 value;
69 69
70 if (mutex_lock_interruptible(&adc->lock)) 70 if (mutex_lock_interruptible(&adc->lock))
71 return -ERESTARTSYS; 71 return -ERESTARTSYS;
72 72
73 status = spi_write_then_read(spi, tx_buf, sizeof(tx_buf), 73 if (adc->channels == 1) {
74 rx_buf, sizeof(rx_buf)); 74 status = spi_read(spi, rx_buf, sizeof(rx_buf));
75 } else {
76 tx_buf[0] = attr->index << 3; /* other bits are don't care */
77 status = spi_write_then_read(spi, tx_buf, sizeof(tx_buf),
78 rx_buf, sizeof(rx_buf));
79 }
75 if (status < 0) { 80 if (status < 0) {
76 dev_warn(dev, "spi_write_then_read failed with status %d\n", 81 dev_warn(dev, "SPI synch. transfer failed with status %d\n",
77 status); 82 status);
78 goto out; 83 goto out;
79 } 84 }