aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/tty
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2020-05-21 11:11:52 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-22 11:06:15 +0200
commit2aa916e67db3e625cc0bfe577f67034a46f81c8a (patch)
tree35121cebc60dca6ad8ab0a9266be9cbce6eb5bdf /drivers/tty
parentsc16is7xx: Allow sharing the IRQ line (diff)
downloadwireguard-linux-2aa916e67db3e625cc0bfe577f67034a46f81c8a.tar.xz
wireguard-linux-2aa916e67db3e625cc0bfe577f67034a46f81c8a.zip
sc16is7xx: Read the LSR register for basic device presence check
Currently, the driver probes just fine and binds all its resources even if the physical device is not present. As the device lacks an identification register, let's at least read the LSR register to check whether a device at the configured address responds to the request at all. Signed-off-by: Daniel Mack <daniel@zonque.org> Link: https://lore.kernel.org/r/20200521091152.404404-7-daniel@zonque.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/sc16is7xx.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 7d98367d6e83..8fee0e8b851f 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1172,6 +1172,7 @@ static int sc16is7xx_probe(struct device *dev,
{
struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 };
unsigned long freq = 0, *pfreq = dev_get_platdata(dev);
+ unsigned int val;
u32 uartclk = 0;
int i, ret;
struct sc16is7xx_port *s;
@@ -1179,6 +1180,16 @@ static int sc16is7xx_probe(struct device *dev,
if (IS_ERR(regmap))
return PTR_ERR(regmap);
+ /*
+ * This device does not have an identification register that would
+ * tell us if we are really connected to the correct device.
+ * The best we can do is to check if communication is at all possible.
+ */
+ ret = regmap_read(regmap,
+ SC16IS7XX_LSR_REG << SC16IS7XX_REG_SHIFT, &val);
+ if (ret < 0)
+ return ret;
+
/* Alloc port structure */
s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL);
if (!s) {