]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge tag 'v3.14-rc4' into next
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 1 Mar 2014 18:31:53 +0000 (10:31 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 1 Mar 2014 18:31:53 +0000 (10:31 -0800)
Merge with Linux 3.14-rc4 to bring devm_request_any_context_irq().

1  2 
drivers/input/touchscreen/zforce_ts.c

index bdc936cb844542ec55d9bbb9c5f63a062798f69d,2175f341900204f8ba0c3ba42c99973603fc6b09..01d30cedde460f7f54f49ac72ad744b080fcfcb6
  #include <linux/sysfs.h>
  #include <linux/input/mt.h>
  #include <linux/platform_data/zforce_ts.h>
 +#include <linux/of.h>
 +#include <linux/of_gpio.h>
  
  #define WAIT_TIMEOUT          msecs_to_jiffies(1000)
  
  #define FRAME_START           0xee
 +#define FRAME_MAXSIZE         257
  
  /* Offsets of the different parts of the payload the controller sends */
  #define PAYLOAD_HEADER                0
@@@ -67,7 -64,7 +67,7 @@@
  #define RESPONSE_STATUS               0X1e
  
  /*
 - * Notifications are send by the touch controller without
 + * Notifications are sent by the touch controller without
   * being requested by the driver and include for example
   * touch indications
   */
@@@ -106,8 -103,8 +106,8 @@@ struct zforce_point 
   * @suspended         device suspended
   * @access_mutex      serialize i2c-access, to keep multipart reads together
   * @command_done      completion to wait for the command result
 - * @command_mutex     serialize commands send to the ic
 - * @command_waiting   the id of the command that that is currently waiting
 + * @command_mutex     serialize commands sent to the ic
 + * @command_waiting   the id of the command that is currently waiting
   *                    for a result
   * @command_result    returned result of the command
   */
@@@ -238,8 -235,7 +238,8 @@@ static int zforce_scan_frequency(struc
                        (finger & 0xff), ((finger >> 8) & 0xff),
                        (stylus & 0xff), ((stylus >> 8) & 0xff) };
  
 -      dev_dbg(&client->dev, "set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
 +      dev_dbg(&client->dev,
 +              "set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
                idle, finger, stylus);
  
        return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
@@@ -259,7 -255,7 +259,7 @@@ static int zforce_setconfig(struct zfor
  static int zforce_start(struct zforce_ts *ts)
  {
        struct i2c_client *client = ts->client;
 -      const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
 +      const struct zforce_ts_platdata *pdata = ts->pdata;
        int ret;
  
        dev_dbg(&client->dev, "starting device\n");
@@@ -330,14 -326,13 +330,14 @@@ static int zforce_stop(struct zforce_t
  static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
  {
        struct i2c_client *client = ts->client;
 -      const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
 +      const struct zforce_ts_platdata *pdata = ts->pdata;
        struct zforce_point point;
        int count, i, num = 0;
  
        count = payload[0];
        if (count > ZFORCE_REPORT_POINTS) {
 -              dev_warn(&client->dev, "to many coordinates %d, expected max %d\n",
 +              dev_warn(&client->dev,
 +                       "too many coordinates %d, expected max %d\n",
                         count, ZFORCE_REPORT_POINTS);
                count = ZFORCE_REPORT_POINTS;
        }
@@@ -426,7 -421,7 +426,7 @@@ static int zforce_read_packet(struct zf
                goto unlock;
        }
  
 -      if (buf[PAYLOAD_LENGTH] <= 0 || buf[PAYLOAD_LENGTH] > 255) {
 +      if (buf[PAYLOAD_LENGTH] == 0) {
                dev_err(&client->dev, "invalid payload length: %d\n",
                        buf[PAYLOAD_LENGTH]);
                ret = -EIO;
@@@ -461,22 -456,31 +461,31 @@@ static void zforce_complete(struct zfor
        }
  }
  
- static irqreturn_t zforce_interrupt(int irq, void *dev_id)
+ static irqreturn_t zforce_irq(int irq, void *dev_id)
+ {
+       struct zforce_ts *ts = dev_id;
+       struct i2c_client *client = ts->client;
+       if (ts->suspended && device_may_wakeup(&client->dev))
+               pm_wakeup_event(&client->dev, 500);
+       return IRQ_WAKE_THREAD;
+ }
+ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
  {
        struct zforce_ts *ts = dev_id;
        struct i2c_client *client = ts->client;
 -      const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
 +      const struct zforce_ts_platdata *pdata = ts->pdata;
        int ret;
 -      u8 payload_buffer[512];
 +      u8 payload_buffer[FRAME_MAXSIZE];
        u8 *payload;
  
        /*
-        * When suspended, emit a wakeup signal if necessary and return.
+        * When still suspended, return.
         * Due to the level-interrupt we will get re-triggered later.
         */
        if (ts->suspended) {
-               if (device_may_wakeup(&client->dev))
-                       pm_wakeup_event(&client->dev, 500);
                msleep(20);
                return IRQ_HANDLED;
        }
        while (!gpio_get_value(pdata->gpio_int)) {
                ret = zforce_read_packet(ts, payload_buffer);
                if (ret < 0) {
 -                      dev_err(&client->dev, "could not read packet, ret: %d\n",
 -                              ret);
 +                      dev_err(&client->dev,
 +                              "could not read packet, ret: %d\n", ret);
                        break;
                }
  
                                                payload[RESPONSE_DATA + 4];
                        ts->version_rev   = (payload[RESPONSE_DATA + 7] << 8) |
                                                payload[RESPONSE_DATA + 6];
 -                      dev_dbg(&ts->client->dev, "Firmware Version %04x:%04x %04x:%04x\n",
 +                      dev_dbg(&ts->client->dev,
 +                              "Firmware Version %04x:%04x %04x:%04x\n",
                                ts->version_major, ts->version_minor,
                                ts->version_build, ts->version_rev);
  
                        break;
  
                default:
 -                      dev_err(&ts->client->dev, "unrecognized response id: 0x%x\n",
 +                      dev_err(&ts->client->dev,
 +                              "unrecognized response id: 0x%x\n",
                                payload[RESPONSE_ID]);
                        break;
                }
@@@ -616,8 -618,7 +625,8 @@@ static int zforce_suspend(struct devic
  
                enable_irq_wake(client->irq);
        } else if (input->users) {
 -              dev_dbg(&client->dev, "suspend without being a wakeup source\n");
 +              dev_dbg(&client->dev,
 +                      "suspend without being a wakeup source\n");
  
                ret = zforce_stop(ts);
                if (ret)
@@@ -683,45 -684,6 +692,45 @@@ static void zforce_reset(void *data
        gpio_set_value(ts->pdata->gpio_rst, 0);
  }
  
 +static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
 +{
 +      struct zforce_ts_platdata *pdata;
 +      struct device_node *np = dev->of_node;
 +
 +      if (!np)
 +              return ERR_PTR(-ENOENT);
 +
 +      pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 +      if (!pdata) {
 +              dev_err(dev, "failed to allocate platform data\n");
 +              return ERR_PTR(-ENOMEM);
 +      }
 +
 +      pdata->gpio_int = of_get_gpio(np, 0);
 +      if (!gpio_is_valid(pdata->gpio_int)) {
 +              dev_err(dev, "failed to get interrupt gpio\n");
 +              return ERR_PTR(-EINVAL);
 +      }
 +
 +      pdata->gpio_rst = of_get_gpio(np, 1);
 +      if (!gpio_is_valid(pdata->gpio_rst)) {
 +              dev_err(dev, "failed to get reset gpio\n");
 +              return ERR_PTR(-EINVAL);
 +      }
 +
 +      if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
 +              dev_err(dev, "failed to get x-size property\n");
 +              return ERR_PTR(-EINVAL);
 +      }
 +
 +      if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
 +              dev_err(dev, "failed to get y-size property\n");
 +              return ERR_PTR(-EINVAL);
 +      }
 +
 +      return pdata;
 +}
 +
  static int zforce_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
  {
        struct input_dev *input_dev;
        int ret;
  
 -      if (!pdata)
 -              return -EINVAL;
 +      if (!pdata) {
 +              pdata = zforce_parse_dt(&client->dev);
 +              if (IS_ERR(pdata))
 +                      return PTR_ERR(pdata);
 +      }
  
        ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL);
        if (!ts)
         * Therefore we can trigger the interrupt anytime it is low and do
         * not need to limit it to the interrupt edge.
         */
-       ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
-                                       zforce_interrupt,
+       ret = devm_request_threaded_irq(&client->dev, client->irq,
+                                       zforce_irq, zforce_irq_thread,
                                        IRQF_TRIGGER_LOW | IRQF_ONESHOT,
                                        input_dev->name, ts);
        if (ret) {
                return ret;
        }
  
 -      /* this gets the firmware version among other informations */
 +      /* this gets the firmware version among other information */
        ret = zforce_command_wait(ts, COMMAND_STATUS);
        if (ret < 0) {
                dev_err(&client->dev, "couldn't get status, %d\n", ret);
@@@ -870,20 -829,11 +879,20 @@@ static struct i2c_device_id zforce_idta
  };
  MODULE_DEVICE_TABLE(i2c, zforce_idtable);
  
 +#ifdef CONFIG_OF
 +static struct of_device_id zforce_dt_idtable[] = {
 +      { .compatible = "neonode,zforce" },
 +      {},
 +};
 +MODULE_DEVICE_TABLE(of, zforce_dt_idtable);
 +#endif
 +
  static struct i2c_driver zforce_driver = {
        .driver = {
                .owner  = THIS_MODULE,
                .name   = "zforce-ts",
                .pm     = &zforce_pm_ops,
 +              .of_match_table = of_match_ptr(zforce_dt_idtable),
        },
        .probe          = zforce_probe,
        .id_table       = zforce_idtable,