提交 037e966f 编写于 作者: H Hartmut Knaack 提交者: Jonathan Cameron

iio:light:stk3310: move device register to end of probe

iio_device_register should be the last operation during probe. Therefor
move up interrupt setup code and while at it, change the check for invalid
values of client->irq to be smaller than zero.
Fixes: 3dd477ac ("iio: light: Add threshold interrupt support for STK3310")

As the device_register makes the userspace interfaces of the device available
it is possible for requests to come in before the probe sequence has finished.
This can lead to unhandled interrupts and similar.
Signed-off-by: NHartmut Knaack <knaack.h@gmx.de>
Reviewed-by: NTiberiu Breana <tiberiu.a.breana@intel.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 c5d0db06
...@@ -608,13 +608,7 @@ static int stk3310_probe(struct i2c_client *client, ...@@ -608,13 +608,7 @@ static int stk3310_probe(struct i2c_client *client,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = iio_device_register(indio_dev); if (client->irq < 0)
if (ret < 0) {
dev_err(&client->dev, "device_register failed\n");
stk3310_set_state(data, STK3310_STATE_STANDBY);
}
if (client->irq <= 0)
client->irq = stk3310_gpio_probe(client); client->irq = stk3310_gpio_probe(client);
if (client->irq >= 0) { if (client->irq >= 0) {
...@@ -629,6 +623,12 @@ static int stk3310_probe(struct i2c_client *client, ...@@ -629,6 +623,12 @@ static int stk3310_probe(struct i2c_client *client,
client->irq); client->irq);
} }
ret = iio_device_register(indio_dev);
if (ret < 0) {
dev_err(&client->dev, "device_register failed\n");
stk3310_set_state(data, STK3310_STATE_STANDBY);
}
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册