diff options
author | David Brownell <david-b@pacbell.net> | 2008-04-02 00:43:01 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-04-02 00:43:01 -0400 |
commit | 7c6d0ee14cb7a4cfad4864dc196256da5749bc0c (patch) | |
tree | a24af9205d80605d6e4b01693b652f9837071e5c /drivers/input/touchscreen/ads7846.c | |
parent | e6cdd15629a5a99d805fa3cbf0f5174bcfc685bb (diff) |
Input: ads7846 - simplify support of external vREF (and ads7843)
This updates the ads7846 driver to handle external vREF (required
on boards using ads7843 chips) without module parameters, and also
removes a needless variable with its associated bogus gcc warning.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen/ads7846.c')
-rw-r--r-- | drivers/input/touchscreen/ads7846.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 57a1c28bf122..a571aa965da0 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -87,6 +87,7 @@ struct ads7846 { | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | u16 model; | 89 | u16 model; |
90 | u16 vref_mv; | ||
90 | u16 vref_delay_usecs; | 91 | u16 vref_delay_usecs; |
91 | u16 x_plate_ohms; | 92 | u16 x_plate_ohms; |
92 | u16 pressure_max; | 93 | u16 pressure_max; |
@@ -184,9 +185,6 @@ struct ads7846 { | |||
184 | * The range is GND..vREF. The ads7843 and ads7835 must use external vREF; | 185 | * The range is GND..vREF. The ads7843 and ads7835 must use external vREF; |
185 | * ads7846 lets that pin be unconnected, to use internal vREF. | 186 | * ads7846 lets that pin be unconnected, to use internal vREF. |
186 | */ | 187 | */ |
187 | static unsigned vREF_mV; | ||
188 | module_param(vREF_mV, uint, 0); | ||
189 | MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts"); | ||
190 | 188 | ||
191 | struct ser_req { | 189 | struct ser_req { |
192 | u8 ref_on; | 190 | u8 ref_on; |
@@ -213,7 +211,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
213 | struct ads7846 *ts = dev_get_drvdata(dev); | 211 | struct ads7846 *ts = dev_get_drvdata(dev); |
214 | struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); | 212 | struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); |
215 | int status; | 213 | int status; |
216 | int uninitialized_var(sample); | ||
217 | int use_internal; | 214 | int use_internal; |
218 | 215 | ||
219 | if (!req) | 216 | if (!req) |
@@ -270,13 +267,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
270 | 267 | ||
271 | if (status == 0) { | 268 | if (status == 0) { |
272 | /* on-wire is a must-ignore bit, a BE12 value, then padding */ | 269 | /* on-wire is a must-ignore bit, a BE12 value, then padding */ |
273 | sample = be16_to_cpu(req->sample); | 270 | status = be16_to_cpu(req->sample); |
274 | sample = sample >> 3; | 271 | status = status >> 3; |
275 | sample &= 0x0fff; | 272 | status &= 0x0fff; |
276 | } | 273 | } |
277 | 274 | ||
278 | kfree(req); | 275 | kfree(req); |
279 | return status ? status : sample; | 276 | return status; |
280 | } | 277 | } |
281 | 278 | ||
282 | #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) | 279 | #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) |
@@ -317,7 +314,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v) | |||
317 | unsigned retval = v; | 314 | unsigned retval = v; |
318 | 315 | ||
319 | /* external resistors may scale vAUX into 0..vREF */ | 316 | /* external resistors may scale vAUX into 0..vREF */ |
320 | retval *= vREF_mV; | 317 | retval *= ts->vref_mv; |
321 | retval = retval >> 12; | 318 | retval = retval >> 12; |
322 | return retval; | 319 | return retval; |
323 | } | 320 | } |
@@ -375,14 +372,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts) | |||
375 | /* hwmon sensors need a reference voltage */ | 372 | /* hwmon sensors need a reference voltage */ |
376 | switch (ts->model) { | 373 | switch (ts->model) { |
377 | case 7846: | 374 | case 7846: |
378 | if (!vREF_mV) { | 375 | if (!ts->vref_mv) { |
379 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); | 376 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); |
380 | vREF_mV = 2500; | 377 | ts->vref_mv = 2500; |
381 | } | 378 | } |
382 | break; | 379 | break; |
383 | case 7845: | 380 | case 7845: |
384 | case 7843: | 381 | case 7843: |
385 | if (!vREF_mV) { | 382 | if (!ts->vref_mv) { |
386 | dev_warn(&spi->dev, | 383 | dev_warn(&spi->dev, |
387 | "external vREF for ADS%d not specified\n", | 384 | "external vREF for ADS%d not specified\n", |
388 | ts->model); | 385 | ts->model); |
@@ -875,6 +872,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
875 | 872 | ||
876 | ts->spi = spi; | 873 | ts->spi = spi; |
877 | ts->input = input_dev; | 874 | ts->input = input_dev; |
875 | ts->vref_mv = pdata->vref_mv; | ||
878 | 876 | ||
879 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 877 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
880 | ts->timer.function = ads7846_timer; | 878 | ts->timer.function = ads7846_timer; |