Skip to content

Commit 2aa916e

Browse files
zonquegregkh
authored andcommitted
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>
1 parent 2d12fc7 commit 2aa916e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/tty/serial/sc16is7xx.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,24 @@ static int sc16is7xx_probe(struct device *dev,
11721172
{
11731173
struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 };
11741174
unsigned long freq = 0, *pfreq = dev_get_platdata(dev);
1175+
unsigned int val;
11751176
u32 uartclk = 0;
11761177
int i, ret;
11771178
struct sc16is7xx_port *s;
11781179

11791180
if (IS_ERR(regmap))
11801181
return PTR_ERR(regmap);
11811182

1183+
/*
1184+
* This device does not have an identification register that would
1185+
* tell us if we are really connected to the correct device.
1186+
* The best we can do is to check if communication is at all possible.
1187+
*/
1188+
ret = regmap_read(regmap,
1189+
SC16IS7XX_LSR_REG << SC16IS7XX_REG_SHIFT, &val);
1190+
if (ret < 0)
1191+
return ret;
1192+
11821193
/* Alloc port structure */
11831194
s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL);
11841195
if (!s) {

0 commit comments

Comments
 (0)