X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Finput%2Ftouchscreen%2Fegalax_ts.c;h=17c9097f3b5ddddd40fad74345b1d2376c4ada7a;hb=e2619cf78e19476bfd7ceaefa9eff0847529346e;hp=c1e3460f1195aed3953c0e09542c9718d8664421;hpb=35fd3dc58da675d659513384221349ef90749a01;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index c1e3460f1195..17c9097f3b5d 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * Mouse Mode: some panel may configure the controller to mouse mode, @@ -122,9 +123,17 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) /* wake up controller by an falling edge of interrupt gpio. */ static int egalax_wake_up_device(struct i2c_client *client) { - int gpio = irq_to_gpio(client->irq); + struct device_node *np = client->dev.of_node; + int gpio; int ret; + if (!np) + return -ENODEV; + + gpio = of_get_named_gpio(np, "wakeup-gpios", 0); + if (!gpio_is_valid(gpio)) + return -ENODEV; + ret = gpio_request(gpio, "egalax_irq"); if (ret < 0) { dev_err(&client->dev, @@ -144,7 +153,7 @@ static int egalax_wake_up_device(struct i2c_client *client) return 0; } -static int __devinit egalax_firmware_version(struct i2c_client *client) +static int egalax_firmware_version(struct i2c_client *client) { static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 }; int ret; @@ -156,7 +165,7 @@ static int __devinit egalax_firmware_version(struct i2c_client *client) return 0; } -static int __devinit egalax_ts_probe(struct i2c_client *client, +static int egalax_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct egalax_ts *ts; @@ -181,7 +190,11 @@ static int __devinit egalax_ts_probe(struct i2c_client *client, ts->input_dev = input_dev; /* controller may be in sleep, wake it up. */ - egalax_wake_up_device(client); + error = egalax_wake_up_device(client); + if (error) { + dev_err(&client->dev, "Failed to wake up the controller\n"); + goto err_free_dev; + } ret = egalax_firmware_version(client); if (ret < 0) { @@ -233,7 +246,7 @@ err_free_ts: return error; } -static __devexit int egalax_ts_remove(struct i2c_client *client) +static int egalax_ts_remove(struct i2c_client *client) { struct egalax_ts *ts = i2c_get_clientdata(client); @@ -274,15 +287,21 @@ static int egalax_ts_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); +static struct of_device_id egalax_ts_dt_ids[] = { + { .compatible = "eeti,egalax_ts" }, + { /* sentinel */ } +}; + static struct i2c_driver egalax_ts_driver = { .driver = { .name = "egalax_ts", .owner = THIS_MODULE, .pm = &egalax_ts_pm_ops, + .of_match_table = of_match_ptr(egalax_ts_dt_ids), }, .id_table = egalax_ts_id, .probe = egalax_ts_probe, - .remove = __devexit_p(egalax_ts_remove), + .remove = egalax_ts_remove, }; module_i2c_driver(egalax_ts_driver);