linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Brownell <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org, jkosina@suse.cz, akpm@linux-foundation.org
Subject: [PATCH 03/37] Input: ads7846 - simplify support of external vREF (and ads7843)
Date: Wed, 2 Apr 2008 00:43:01 -0400	[thread overview]
Message-ID: <7c6d0ee14cb7a4cfad4864dc196256da5749bc0c.1208783694.git.dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <cover.1208783694.git.dmitry.torokhov@gmail.com>

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>
---
 drivers/input/touchscreen/ads7846.c |   22 ++++++++++------------
 include/linux/spi/ads7846.h         |    3 ++-
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 57a1c28..a571aa9 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -87,6 +87,7 @@ struct ads7846 {
 #endif
 
 	u16			model;
+	u16			vref_mv;
 	u16			vref_delay_usecs;
 	u16			x_plate_ohms;
 	u16			pressure_max;
@@ -184,9 +185,6 @@ struct ads7846 {
  * The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
  * ads7846 lets that pin be unconnected, to use internal vREF.
  */
-static unsigned vREF_mV;
-module_param(vREF_mV, uint, 0);
-MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts");
 
 struct ser_req {
 	u8			ref_on;
@@ -213,7 +211,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
 	struct ads7846		*ts = dev_get_drvdata(dev);
 	struct ser_req		*req = kzalloc(sizeof *req, GFP_KERNEL);
 	int			status;
-	int			uninitialized_var(sample);
 	int			use_internal;
 
 	if (!req)
@@ -270,13 +267,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
 
 	if (status == 0) {
 		/* on-wire is a must-ignore bit, a BE12 value, then padding */
-		sample = be16_to_cpu(req->sample);
-		sample = sample >> 3;
-		sample &= 0x0fff;
+		status = be16_to_cpu(req->sample);
+		status = status >> 3;
+		status &= 0x0fff;
 	}
 
 	kfree(req);
-	return status ? status : sample;
+	return status;
 }
 
 #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
@@ -317,7 +314,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
 	unsigned retval = v;
 
 	/* external resistors may scale vAUX into 0..vREF */
-	retval *= vREF_mV;
+	retval *= ts->vref_mv;
 	retval = retval >> 12;
 	return retval;
 }
@@ -375,14 +372,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
 	/* hwmon sensors need a reference voltage */
 	switch (ts->model) {
 	case 7846:
-		if (!vREF_mV) {
+		if (!ts->vref_mv) {
 			dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
-			vREF_mV = 2500;
+			ts->vref_mv = 2500;
 		}
 		break;
 	case 7845:
 	case 7843:
-		if (!vREF_mV) {
+		if (!ts->vref_mv) {
 			dev_warn(&spi->dev,
 				"external vREF for ADS%d not specified\n",
 				ts->model);
@@ -875,6 +872,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 
 	ts->spi = spi;
 	ts->input = input_dev;
+	ts->vref_mv = pdata->vref_mv;
 
 	hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	ts->timer.function = ads7846_timer;
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 334d314..daf7440 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -14,7 +14,8 @@ enum ads7846_filter {
 struct ads7846_platform_data {
 	u16	model;			/* 7843, 7845, 7846. */
 	u16	vref_delay_usecs;	/* 0 for external vref; etc */
-	int	keep_vref_on:1;		/* set to keep vref on for differential
+	u16	vref_mv;		/* external vref value, milliVolts */
+	bool	keep_vref_on;		/* set to keep vref on for differential
 					 * measurements as well */
 
 	/* Settling time of the analog signals; a function of Vcc and the
-- 
1.5.5.rc2.6.gf58d



  parent reply	other threads:[~2008-04-21 13:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21 13:14 [PATCH 00/37] Input queue for 2.6.26 merge window Dmitry Torokhov
2008-03-10 10:08 ` [PATCH 27/37] Input: aiptek - add support for Genius G-PEN 560 tablet Guryanov Dmitry
2008-03-10 12:40 ` [PATCH 28/37] Input: add Zhen Hua driver Martin Kebert
2008-03-10 12:43 ` [PATCH 29/37] Input: fix ordering in joystick Makefile Jiri Kosina
2008-04-02  4:41 ` [PATCH 01/37] Input: remove private member from input_dev structure Dmitry Torokhov
2008-04-02  4:42 ` [PATCH 02/37] Input: locomokbd - add 'off' button support for Sharp Collie/Poodle Helge Deller
2008-04-02  4:43 ` David Brownell [this message]
2008-04-02  4:51 ` [PATCH 04/37] Input: add support for WM97xx familty touchscreens Mark Brown
2008-04-02  4:51 ` [PATCH 05/37] Input: WM97xx - add chip driver for WM9705 touchscreen Mark Brown
2008-04-02  4:51 ` [PATCH 06/37] Input: WM97xx - add chip driver for WM9712 touchscreen Mark Brown
2008-04-02  4:51 ` [PATCH 07/37] Input: WM97xx - add chip driver for WM97123 touchscreen Mark Brown
2008-04-02  4:51 ` [PATCH 08/37] Input: WM97xx - add support for streaming mode on Mainstone Mark Brown
2008-04-02 14:02 ` [PATCH 09/37] Input: appletouch - add product IDs for the 4th generation MacBooks Tobias Mueller
2008-04-02 15:22 ` [PATCH 10/37] Input: tosakbd - fix suspend Dmitry Baryshkov
2008-04-03 20:17 ` [PATCH 11/37] Input: xpad - match xbox 360 devices with interface info Anssi Hannula
2008-04-03 20:18 ` [PATCH 12/37] Input: xpad - fix dpad handling of unknown devices Anssi Hannula
2008-04-03 20:18 ` [PATCH 13/37] Input: xpad - fix inverted Y and RY axes Anssi Hannula
2008-04-03 20:18 ` [PATCH 14/37] Input: xpad - add more xbox 360 controller ids Anssi Hannula
2008-04-03 20:18 ` [PATCH 15/37] Input: xpad - do not report nonexistent buttons for xbox360 Anssi Hannula
2008-04-03 20:18 ` [PATCH 16/37] Input: xpad - enable force feedback on xbox 360 controllers only Anssi Hannula
2008-04-03 20:19 ` [PATCH 17/37] Input: xpad - drop obsolete driver versioning Anssi Hannula
2008-04-03 20:19 ` [PATCH 18/37] Input: xpad - add support for wireless xbox360 controllers Brian Magnuson
2008-04-03 20:19 ` [PATCH 19/37] Input: xpad - don't use GFP_ATOMIC Oliver Neukum
2008-04-04 19:31 ` [PATCH 20/37] Input: usbtouchscreen - don't use DMA on stack Oliver Neukum
2008-04-15  5:30 ` [PATCH 21/37] Input: put ledstate in the keyboard notifier Karl Dahlke
2008-04-15  5:30 ` [PATCH 22/37] Input: add PS/2 serio driver for AVR32 devices Hans-Christian Egtvedt
2008-04-15  5:31 ` [PATCH 23/37] Input: gpio_keys - irq handling cleanup David Brownell
2008-04-15  5:31 ` [PATCH 24/37] Input: omap-keypad - fix build warning David Brownell
2008-04-15  5:31 ` [PATCH 25/37] Input: xpad - set proper buffer length for outgoing requests Michael Gruber
2008-04-15  5:31 ` [PATCH 26/37] Input: wacom - implement suspend and autosuspend Oliver Neukum
2008-04-17 13:24 ` [PATCH 30/37] Input: wm97xx-core - only schedule interrupt handler if not already scheduled Mark Brown
2008-04-17 13:24 ` [PATCH 31/37] Input: wm97xx-core - use IRQF_SAMPLE_RANDOM Mark Brown
2008-04-17 13:24 ` [PATCH 32/37] Input: wm97xx-core - support use as a wakeup source Mark Brown
2008-04-17 13:28 ` [PATCH 33/37] Input: drivers/char/keyboard.c - use time_after Julia Lawall
2008-04-18  4:24 ` [PATCH 34/37] Input: add MODULE_ALIAS() to hotpluggable platform modules Kay Sievers
2008-04-18  4:25 ` [PATCH 35/37] Input: bf54x-keys - add infrastructure for keypad wakeups Michael Hennerich
2008-04-18  4:25 ` [PATCH 36/37] Input: i8042 - fix incorrect usage of strncpy and strncat Roel Kluin
2008-04-18  4:25 ` [PATCH 37/37] Input: mac_hid - add lockdep annotation to emumousebtn Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c6d0ee14cb7a4cfad4864dc196256da5749bc0c.1208783694.git.dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).