1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
From alan@linux.intel.com Wed Jun 16 13:50:26 2010
From: jianwei.yang <jianwei.yang@intel.com>
Date: Wed, 16 Jun 2010 14:46:49 +0100
Subject: max3110 sanity check a register
To: greg@kroah.com, linux-serial@vger.kernel.org
Message-ID: <20100616134616.12686.11518.stgit@localhost.localdomain>
From: jianwei.yang <jianwei.yang@intel.com>
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>
---
drivers/serial/mrst_max3110.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/drivers/serial/mrst_max3110.c
+++ b/drivers/serial/mrst_max3110.c
@@ -721,7 +721,7 @@ static int serial_m3110_probe(struct 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
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;
|