diff options
-rw-r--r-- | Documentation/devicetree/bindings/staging/iio/light/iqs253-ps.txt | 4 | ||||
-rw-r--r-- | drivers/staging/iio/light/iqs253.c | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/staging/iio/light/iqs253-ps.txt b/Documentation/devicetree/bindings/staging/iio/light/iqs253-ps.txt index 1dab27d73dfc..a57827c05948 100644 --- a/Documentation/devicetree/bindings/staging/iio/light/iqs253-ps.txt +++ b/Documentation/devicetree/bindings/staging/iio/light/iqs253-ps.txt @@ -11,6 +11,9 @@ Required properties: - wake-gpio: gpio to be used for wakeup on stylus insert/removal event. - sar-gpio: gpio to be used for sending proximity event to SAR sensor. +Optional properties: +- stylus-detect: specify this option to enable stylus detection + Example: iqs253@44 { @@ -23,4 +26,5 @@ Example: rdy-gpio = <&gpio TEGRA_GPIO(PK, 5) 1>; wake-gpio = <&gpio TEGRA_GPIO(PW, 3) 1>; sar-gpio = <&gpio TEGRA_GPIO(I, 2) 1>; + stylus-detect; }; diff --git a/drivers/staging/iio/light/iqs253.c b/drivers/staging/iio/light/iqs253.c index 7a87ccc0af3e..1e26539e02ca 100644 --- a/drivers/staging/iio/light/iqs253.c +++ b/drivers/staging/iio/light/iqs253.c @@ -508,6 +508,7 @@ static int iqs253_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct input_dev *idev; int rdy_gpio = -1, wake_gpio = -1, sar_gpio = -1; + struct property *stylus_detect = NULL; rdy_gpio = of_get_named_gpio(client->dev.of_node, "rdy-gpio", 0); if (rdy_gpio == -EPROBE_DEFER) @@ -608,11 +609,17 @@ static int iqs253_probe(struct i2c_client *client, goto err_gpio_request; } + stylus_detect = of_find_property(client->dev.of_node, + "stylus-detect", NULL); + if (!stylus_detect) + goto finish; + idev = iqs253_stylus_input_init(iqs253_chip); if (IS_ERR_OR_NULL(idev)) goto err_gpio_request; iqs253_chip->idev = idev; +finish: dev_info(&client->dev, "devname:%s func:%s line:%d probe success\n", id->name, __func__, __LINE__); @@ -634,9 +641,12 @@ static int iqs253_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct iqs253_chip *chip = iio_priv(indio_dev); gpio_free(chip->rdy_gpio); - destroy_workqueue(chip->wq); - input_unregister_device(chip->idev); - input_free_device(chip->idev); + if (chip->wq) + destroy_workqueue(chip->wq); + if (chip->idev) { + input_unregister_device(chip->idev); + input_free_device(chip->idev); + } iio_device_unregister(indio_dev); iio_device_free(indio_dev); return 0; |