diff options
author | jianwei.yang <jianwei.yang@intel.com> | 2010-06-16 14:46:49 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 13:47:39 -0700 |
commit | 99dd3f6b7e2ef5179f67503a401a99141708687a (patch) | |
tree | 0a0a30ea891d7d92aea47949c4ec8a16e710c1d6 | |
parent | 225109957a74c571c49e860fcc4e81fa6df1079d (diff) | |
download | linux-3.10-99dd3f6b7e2ef5179f67503a401a99141708687a.tar.gz linux-3.10-99dd3f6b7e2ef5179f67503a401a99141708687a.tar.bz2 linux-3.10-99dd3f6b7e2ef5179f67503a401a99141708687a.zip |
max3110 sanity check a register
MAX3111 is the SPI/UART IC installed on the MRST SPI Port Card as a serial
debug goal, and the SPI Port Card will be frequently mounted and unmounted
from the main board by developers depending whether debug serial is
required or not.
As the MAX3111 has no subvendor or product id registers available, the patch
will try to access one register to decide if this IC is present or not.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/serial/mrst_max3110.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/serial/mrst_max3110.c b/drivers/serial/mrst_max3110.c index 273e7cbe74c..f9c01aeb6f8 100644 --- a/drivers/serial/mrst_max3110.c +++ b/drivers/serial/mrst_max3110.c @@ -721,7 +721,7 @@ static int serial_m3110_probe(struct spi_device *spi) struct uart_max3110 *max; int ret; unsigned char *buffer; - + u16 res; max = kzalloc(sizeof(*max), GFP_KERNEL); if (!max) return -ENOMEM; @@ -753,7 +753,16 @@ static int serial_m3110_probe(struct spi_device *spi) max->cur_conf = 0; atomic_set(&max->irq_pending, 0); - + /* Check if reading configuration register returns something sane */ + + res = RC_TAG; + ret = max3110_write_then_read(max, (u8 *)&res, (u8 *)&res, 2, 0); + if (ret < 0 || res == 0 || res == 0xffff) { + printk(KERN_ERR "MAX3111 deemed not present (conf reg %04x)", + res); + ret = -ENODEV; + goto err_get_page; + } buffer = (unsigned char *)__get_free_page(GFP_KERNEL); if (!buffer) { ret = -ENOMEM; |