input: sensors: fromdos and remove trailing whitespace
[firefly-linux-kernel-4.4.55.git] / drivers / input / sensors / gyro / ewtsa.c
index 78684d6ea678751d3ae64249d5b60c680d6a5b88..2670515575e94fc6ede9b913447babdfdc665925 100755 (executable)
-/* drivers/input/sensors/gyro/Ewtsa.c\r
- *\r
- * Copyright (C) 2012-2015 ROCKCHIP.\r
- * Author: zhangaihui <zah@rock-chips.com>\r
- *\r
- * This software is licensed under the terms of the GNU General Public\r
- * License version 2, as published by the Free Software Foundation, and\r
- * may be copied, distributed, and modified under those terms.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- */\r
-#include <linux/interrupt.h>\r
-#include <linux/i2c.h>\r
-#include <linux/slab.h>\r
-#include <linux/irq.h>\r
-#include <linux/miscdevice.h>\r
-#include <linux/gpio.h>\r
-#include <asm/uaccess.h>\r
-#include <asm/atomic.h>\r
-#include <linux/delay.h>\r
-#include <linux/input.h>\r
-#include <linux/workqueue.h>\r
-#include <linux/freezer.h>\r
-#include <linux/of_gpio.h>\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
-#include <linux/earlysuspend.h>\r
-#endif\r
-#include <linux/sensor-dev.h>\r
-\r
-/** This define controls compilation of the master device interface */\r
-/*#define EWTSA_MASTER_DEVICE*/\r
-/* configurable */\r
-#define GYRO_MOUNT_SWAP_XY      0   /* swap X, Y */\r
-#define GYRO_MOUNT_REVERSE_X    0   /* reverse X */\r
-#define GYRO_MOUNT_REVERSE_Y    0   /* reverse Y */\r
-#define GYRO_MOUNT_REVERSE_Z    0   /* reverse Z */\r
-\r
-/* macro defines */\r
-/*#define CHIP_ID                 0x68*/\r
-#define DEVICE_NAME             "ewtsa"\r
-#define EWTSA_ON                1\r
-#define EWTSA_OFF               0\r
-#define SLEEP_PIN               14\r
-#define DRDY_PIN                12\r
-#define DIAG_PIN                11\r
-#define MAX_VALUE               32768\r
-\r
-/* ewtsa_delay parameter */\r
-#define DELAY_THRES_MIN         1\r
-#define DELAY_THRES_1           4\r
-#define DELAY_THRES_2           9   /* msec x 90% */\r
-#define DELAY_THRES_3           18\r
-#define DELAY_THRES_4           45\r
-#define DELAY_THRES_5           90\r
-#define DELAY_THRES_6           128\r
-#define DELAY_THRES_MAX         255\r
-#define DELAY_DLPF_2            2\r
-#define DELAY_DLPF_3            3\r
-#define DELAY_DLPF_4            4\r
-#define DELAY_DLPF_5            5\r
-#define DELAY_DLPF_6            6\r
-#define DELAY_INTMIN_THRES      9\r
-\r
-#define DATA_RATE_1             0x01\r
-\r
-/* ewtsa_sleep parameter */\r
-#define SLEEP_OFF               0\r
-#define SLEEP_ON                1\r
-\r
-/* event mode */\r
-#define EWTSA_POLLING_MODE    0\r
-#define EWTSA_INTERUPT_MODE   1\r
-\r
-/* ewtsa register address */\r
-#define REG_SMPL                0x15\r
-#define REG_FS_DLPF             0x16\r
-#define REG_INT_CFG             0x17\r
-#define REG_INT_STATUS          0x1A\r
-#define REG_SELF_O_C            0x29\r
-#define REG_PWR_MGM             0x3E\r
-#define REG_MBURST_ALL          0xFF\r
-#define GYRO_DATA_REG            0x1D\r
-\r
-/* ewtsa register param */\r
-#define SELF_O_C_ENABLE         0x00\r
-#define SELF_O_C_DISABLE        0x01\r
-#define SLEEP_CTRL_ACTIVATE     0x40\r
-#define SLEEP_CTRL_SLEEP        0x00\r
-#define INT_CFG_INT_ENABLE      0x01\r
-#define INT_CFG_INT_DISABLE     0x00\r
-\r
-/* ewtsa interrupt control */\r
-#define EWSTA_INT_CLEAR         0x00\r
-#define EWSTA_INT_SKIP          0x01\r
-\r
-/* wait time(ms)*/\r
-#define EWTSA_BOOST_TIME_0      500\r
-\r
-/* sleep setting range */\r
-#define EWTSA_SLP_MIN 0\r
-#define EWTSA_SLP_MAX 1\r
-\r
-/* delay setting range */\r
-#define EWTSA_DLY_MIN 1\r
-#define EWTSA_DLY_MAX 255\r
-\r
-/* range setting range */\r
-#define EWTSA_RNG_MIN 0\r
-#define EWTSA_RNG_MAX 3\r
-\r
-/* soc setting range */\r
-#define EWTSA_SOC_MIN 0\r
-#define EWTSA_SOC_MAX 1\r
-\r
-/* event setting range */\r
-#define EWTSA_EVE_MIN 0\r
-#define EWTSA_EVE_MAX 1\r
-\r
-/* init param */\r
-#define SLEEP_INIT_VAL       (SLEEP_ON)\r
-#define DELAY_INIT_VAL       10\r
-#define RANGE_INIT_VAL       2 /*range 1000*/\r
-#define DLPF_INIT_VAL        (DELAY_DLPF_2)\r
-#define CALIB_FUNC_INIT_VAL  (EWTSA_ON)\r
-\r
-/*config store counter num*/\r
-#define CONFIG_COUNTER_MIN (6+9)\r
-#define CONFIG_COUNTER_MAX (32+9)\r
-\r
-/*command name */\r
-#define COMMAND_NAME_SOC 0\r
-#define COMMAND_NAME_DLY 1\r
-#define COMMAND_NAME_RNG 2\r
-#define COMMAND_NAME_EVE 3\r
-#define COMMAND_NAME_SLP 4\r
-#define COMMAND_NAME_NUM 5\r
-\r
-#define EWTSA_delay  DELAY_INIT_VAL\r
-#define EWTSA_range    RANGE_INIT_VAL\r
-#define EWTSA_calib    EWTSA_ON\r
-\r
-/****************operate according to sensor chip:start************/\r
-static int i2c_read_byte(struct i2c_client *thisClient, unsigned char regAddr, char *pReadData)\r
+/* drivers/input/sensors/gyro/Ewtsa.c
+ *
+ * Copyright (C) 2012-2015 ROCKCHIP.
+ * Author: zhangaihui <zah@rock-chips.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/irq.h>
+#include <linux/miscdevice.h>
+#include <linux/gpio.h>
+#include <asm/uaccess.h>
+#include <asm/atomic.h>
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/freezer.h>
+#include <linux/of_gpio.h>
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+#include <linux/sensor-dev.h>
+
+/** This define controls compilation of the master device interface */
+/*#define EWTSA_MASTER_DEVICE*/
+/* configurable */
+#define GYRO_MOUNT_SWAP_XY      0   /* swap X, Y */
+#define GYRO_MOUNT_REVERSE_X    0   /* reverse X */
+#define GYRO_MOUNT_REVERSE_Y    0   /* reverse Y */
+#define GYRO_MOUNT_REVERSE_Z    0   /* reverse Z */
+
+/* macro defines */
+/*#define CHIP_ID                 0x68*/
+#define DEVICE_NAME             "ewtsa"
+#define EWTSA_ON                1
+#define EWTSA_OFF               0
+#define SLEEP_PIN               14
+#define DRDY_PIN                12
+#define DIAG_PIN                11
+#define MAX_VALUE               32768
+
+/* ewtsa_delay parameter */
+#define DELAY_THRES_MIN         1
+#define DELAY_THRES_1           4
+#define DELAY_THRES_2           9   /* msec x 90% */
+#define DELAY_THRES_3           18
+#define DELAY_THRES_4           45
+#define DELAY_THRES_5           90
+#define DELAY_THRES_6           128
+#define DELAY_THRES_MAX         255
+#define DELAY_DLPF_2            2
+#define DELAY_DLPF_3            3
+#define DELAY_DLPF_4            4
+#define DELAY_DLPF_5            5
+#define DELAY_DLPF_6            6
+#define DELAY_INTMIN_THRES      9
+
+#define DATA_RATE_1             0x01
+
+/* ewtsa_sleep parameter */
+#define SLEEP_OFF               0
+#define SLEEP_ON                1
+
+/* event mode */
+#define EWTSA_POLLING_MODE    0
+#define EWTSA_INTERUPT_MODE   1
+
+/* ewtsa register address */
+#define REG_SMPL                0x15
+#define REG_FS_DLPF             0x16
+#define REG_INT_CFG             0x17
+#define REG_INT_STATUS          0x1A
+#define REG_SELF_O_C            0x29
+#define REG_PWR_MGM             0x3E
+#define REG_MBURST_ALL          0xFF
+#define GYRO_DATA_REG            0x1D
+
+/* ewtsa register param */
+#define SELF_O_C_ENABLE         0x00
+#define SELF_O_C_DISABLE        0x01
+#define SLEEP_CTRL_ACTIVATE     0x40
+#define SLEEP_CTRL_SLEEP        0x00
+#define INT_CFG_INT_ENABLE      0x01
+#define INT_CFG_INT_DISABLE     0x00
+
+/* ewtsa interrupt control */
+#define EWSTA_INT_CLEAR         0x00
+#define EWSTA_INT_SKIP          0x01
+
+/* wait time(ms)*/
+#define EWTSA_BOOST_TIME_0      500
+
+/* sleep setting range */
+#define EWTSA_SLP_MIN 0
+#define EWTSA_SLP_MAX 1
+
+/* delay setting range */
+#define EWTSA_DLY_MIN 1
+#define EWTSA_DLY_MAX 255
+
+/* range setting range */
+#define EWTSA_RNG_MIN 0
+#define EWTSA_RNG_MAX 3
+
+/* soc setting range */
+#define EWTSA_SOC_MIN 0
+#define EWTSA_SOC_MAX 1
+
+/* event setting range */
+#define EWTSA_EVE_MIN 0
+#define EWTSA_EVE_MAX 1
+
+/* init param */
+#define SLEEP_INIT_VAL       (SLEEP_ON)
+#define DELAY_INIT_VAL       10
+#define RANGE_INIT_VAL       2 /*range 1000*/
+#define DLPF_INIT_VAL        (DELAY_DLPF_2)
+#define CALIB_FUNC_INIT_VAL  (EWTSA_ON)
+
+/*config store counter num*/
+#define CONFIG_COUNTER_MIN (6+9)
+#define CONFIG_COUNTER_MAX (32+9)
+
+/*command name */
+#define COMMAND_NAME_SOC 0
+#define COMMAND_NAME_DLY 1
+#define COMMAND_NAME_RNG 2
+#define COMMAND_NAME_EVE 3
+#define COMMAND_NAME_SLP 4
+#define COMMAND_NAME_NUM 5
+
+#define EWTSA_delay  DELAY_INIT_VAL
+#define EWTSA_range    RANGE_INIT_VAL
+#define EWTSA_calib    EWTSA_ON
+
+/****************operate according to sensor chip:start************/
+static int i2c_read_byte(struct i2c_client *thisClient, unsigned char regAddr, char *pReadData)
 {
     int    ret = 0;
-       
+
     ret = i2c_master_send( thisClient, (char*)&regAddr, 1);
     if(ret < 0)
     {
-        printk("EWTSA send cAddress=0x%x error!\n", regAddr);\r
+        printk("EWTSA send cAddress=0x%x error!\n", regAddr);
         return ret;
     }
     ret = i2c_master_recv( thisClient, (char*)pReadData, 1);
     if(ret < 0)
     {
-        printk("EWTSAread *pReadData=0x%x error!\n", *pReadData);\r
+        printk("EWTSAread *pReadData=0x%x error!\n", *pReadData);
         return ret;
     }
 
     return 1;
-}\r
-static int i2c_write_byte(struct i2c_client *thisClient, unsigned char regAddr, unsigned char writeData)\r
+}
+static int i2c_write_byte(struct i2c_client *thisClient, unsigned char regAddr, unsigned char writeData)
 {
     char    write_data[2] = {0};
     int    ret=0;
-    
+
     write_data[0] = regAddr;
     write_data[1] = writeData;
-    
+
     ret = i2c_master_send(thisClient, write_data, 2);
-    if (ret < 0) 
+    if (ret < 0)
     {
         ret = i2c_master_send(thisClient, write_data, 2);
-        if (ret < 0) 
+        if (ret < 0)
         {
-            printk("EWTSA send regAddr=0x%x error!\n", regAddr);\r
+            printk("EWTSA send regAddr=0x%x error!\n", regAddr);
             return ret;
         }
         return 1;
     }
-    
+
     return 1;
-}\r
-\r
-static int ewtsa_system_restart(struct i2c_client *client)\r
+}
+
+static int ewtsa_system_restart(struct i2c_client *client)
 {
     int             err;
-     char   reg;\r
-     char   smpl , dlpf;\r
-\r
-    err = i2c_write_byte(client, ( unsigned char)REG_SELF_O_C, ( unsigned char)SELF_O_C_DISABLE);\r
+     char   reg;
+     char   smpl , dlpf;
+
+    err = i2c_write_byte(client, ( unsigned char)REG_SELF_O_C, ( unsigned char)SELF_O_C_DISABLE);
     if (err < 0) {
         return err;
     }
 
     ///Set SMPL register
-        if (EWTSA_delay <= ( unsigned char)DELAY_THRES_2) {\r
-            smpl = ( unsigned char)DELAY_INTMIN_THRES;\r
+        if (EWTSA_delay <= ( unsigned char)DELAY_THRES_2) {
+            smpl = ( unsigned char)DELAY_INTMIN_THRES;
         }else{
-            smpl = ( unsigned char)(EWTSA_delay - ( unsigned char)1);\r
-        }\r
-    err = i2c_write_byte(client, ( unsigned char)REG_SMPL, ( unsigned char)smpl);\r
+            smpl = ( unsigned char)(EWTSA_delay - ( unsigned char)1);
+        }
+    err = i2c_write_byte(client, ( unsigned char)REG_SMPL, ( unsigned char)smpl);
     if (err < 0) {
         return err;
     }
 
     ///Set DLPF register
-    if (EWTSA_delay >= ( unsigned char)DELAY_THRES_6){\r
-        dlpf = ( unsigned char)DELAY_DLPF_6;\r
-    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_5) {\r
-        dlpf = ( unsigned char)DELAY_DLPF_5;\r
-    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_4){\r
-        dlpf = ( unsigned char)DELAY_DLPF_4;\r
-    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_3) {\r
-        dlpf = ( unsigned char)DELAY_DLPF_3;\r
+    if (EWTSA_delay >= ( unsigned char)DELAY_THRES_6){
+        dlpf = ( unsigned char)DELAY_DLPF_6;
+    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_5) {
+        dlpf = ( unsigned char)DELAY_DLPF_5;
+    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_4){
+        dlpf = ( unsigned char)DELAY_DLPF_4;
+    }else if (EWTSA_delay >= ( unsigned char)DELAY_THRES_3) {
+        dlpf = ( unsigned char)DELAY_DLPF_3;
     }else{
-        dlpf = ( unsigned char)DELAY_DLPF_2;\r
+        dlpf = ( unsigned char)DELAY_DLPF_2;
     }
 
-    reg = ( unsigned char)(( unsigned char)(EWTSA_range << 3) | dlpf | ( unsigned char)0x80 ) ;\r
-\r
-    err = i2c_write_byte(client, REG_FS_DLPF, reg);\r
+    reg = ( unsigned char)(( unsigned char)(EWTSA_range << 3) | dlpf | ( unsigned char)0x80 ) ;
+
+    err = i2c_write_byte(client, REG_FS_DLPF, reg);
     if (err < 0) {
         return err;
     }
 
-    if (EWTSA_calib==  EWTSA_ON) {             \r
-       printk("EWTSA_set_calibration() start \n");\r
-       err =  i2c_write_byte(client,( unsigned char)REG_SELF_O_C, ( unsigned char)SELF_O_C_ENABLE);\r
-       if (err < 0) {\r
-               return err;\r
-       }\r
-       mdelay(500); \r
-       printk("EWTSA_set_calibration() end \n");\r
-     \r
+    if (EWTSA_calib==  EWTSA_ON) {
+       printk("EWTSA_set_calibration() start \n");
+       err =  i2c_write_byte(client,( unsigned char)REG_SELF_O_C, ( unsigned char)SELF_O_C_ENABLE);
+       if (err < 0) {
+               return err;
+       }
+       mdelay(500);
+       printk("EWTSA_set_calibration() end \n");
+
     }
 
-    return 0;\r
+    return 0;
+}
+
+static int ewtsa_disable(struct i2c_client *client)
+{
+       struct sensor_private_data *sensor =
+           (struct sensor_private_data *) i2c_get_clientdata(client);
+
+       gpio_direction_output(sensor->pdata->standby_pin, GPIO_HIGH);
+
+       DBG("%s: end \n",__func__);
+
+       return 0;
 }
-\r
-static int ewtsa_disable(struct i2c_client *client)\r
+
+static int ewtsa_enable(struct i2c_client *client)
 {
-       struct sensor_private_data *sensor =\r
-           (struct sensor_private_data *) i2c_get_clientdata(client);  \r
-       \r
-       gpio_direction_output(sensor->pdata->standby_pin, GPIO_HIGH);\r
-\r
-       DBG("%s: end \n",__func__);     \r
-\r
-       return 0;          \r
+       int err;
+       struct sensor_private_data *sensor =
+           (struct sensor_private_data *) i2c_get_clientdata(client);
+
+       gpio_direction_output(sensor->pdata->standby_pin, GPIO_LOW);
+       err = i2c_write_byte(client, ( unsigned char)REG_PWR_MGM, ( unsigned char)SLEEP_CTRL_ACTIVATE);////0x44
+       if (err < 0){
+               //return err;
+               err = ewtsa_system_restart(client);///restart; only when i2c error
+               if (err < 0){
+                       return err;
+               }
+       }
+
+       err = i2c_write_byte(client,  ( unsigned char) REG_INT_CFG, ( unsigned char)INT_CFG_INT_ENABLE);
+       if (err < 0) {
+               return err;
+       }
+       DBG("%s: end \n",__func__);
+       return 0;
 }
-\r
-static int ewtsa_enable(struct i2c_client *client)\r
+
+void gyro_dev_reset(struct i2c_client *client)
 {
-       int err;\r
-       struct sensor_private_data *sensor =\r
-           (struct sensor_private_data *) i2c_get_clientdata(client);  \r
-       \r
-       gpio_direction_output(sensor->pdata->standby_pin, GPIO_LOW);\r
-       err = i2c_write_byte(client, ( unsigned char)REG_PWR_MGM, ( unsigned char)SLEEP_CTRL_ACTIVATE);////0x44\r
-       if (err < 0){\r
-               //return err;\r
-               err = ewtsa_system_restart(client);///restart; only when i2c error\r
-               if (err < 0){\r
-                       return err;\r
-               }\r
-       }\r
-\r
-       err = i2c_write_byte(client,  ( unsigned char) REG_INT_CFG, ( unsigned char)INT_CFG_INT_ENABLE);\r
-       if (err < 0) {\r
-               return err;\r
-       }\r
-       DBG("%s: end \n",__func__);     \r
-       return 0;\r
+       struct sensor_private_data *sensor =
+           (struct sensor_private_data *) i2c_get_clientdata(client);
+
+
+    DBG("%s\n",__func__);
+       gpio_direction_output(sensor->pdata->standby_pin, GPIO_HIGH);
+       msleep(100);
+       gpio_direction_output(sensor->pdata->standby_pin, GPIO_LOW);
+       msleep(100);
 }
-\r
-void gyro_dev_reset(struct i2c_client *client)\r
+
+static int sensor_active(struct i2c_client *client, int enable, int rate)
 {
-       struct sensor_private_data *sensor =\r
-           (struct sensor_private_data *) i2c_get_clientdata(client);  \r
-\r
-       \r
-    DBG("%s\n",__func__);\r
-       gpio_direction_output(sensor->pdata->standby_pin, GPIO_HIGH);\r
-       msleep(100); \r
-       gpio_direction_output(sensor->pdata->standby_pin, GPIO_LOW);\r
-       msleep(100); \r
-}\r
-\r
-static int sensor_active(struct i2c_client *client, int enable, int rate)\r
-{\r
        /*
-       struct sensor_private_data *sensor =\r
-           (struct sensor_private_data *) i2c_get_clientdata(client);  \r
-       int status = 0;\r
+       struct sensor_private_data *sensor =
+           (struct sensor_private_data *) i2c_get_clientdata(client);
+       int status = 0;
        */
        int result = 0;
-       if(enable)\r
-       {       \r
-               result=ewtsa_enable(client);\r
-       }\r
-       else\r
-       {\r
-               result=ewtsa_disable(client);\r
-       }\r
-\r
-       if(result)\r
-               printk("%s:fail to active sensor\n",__func__);\r
-\r
-       return result;\r
-\r
-}\r
-\r
-static int sensor_init(struct i2c_client *client)\r
-{      \r
-       struct sensor_private_data *sensor =\r
-           (struct sensor_private_data *) i2c_get_clientdata(client);  \r
-       int result = 0; \r
+       if(enable)
+       {
+               result=ewtsa_enable(client);
+       }
+       else
+       {
+               result=ewtsa_disable(client);
+       }
+
+       if(result)
+               printk("%s:fail to active sensor\n",__func__);
+
+       return result;
+
+}
+
+static int sensor_init(struct i2c_client *client)
+{
+       struct sensor_private_data *sensor =
+           (struct sensor_private_data *) i2c_get_clientdata(client);
+       int result = 0;
        /*
-       unsigned char buf[5];           \r
-       unsigned char data = 0;\r
-       int i = 0;\r
-       char pReadData=0;\r
+       unsigned char buf[5];
+       unsigned char data = 0;
+       int i = 0;
+       char pReadData=0;
        */
-       sensor->status_cur = SENSOR_OFF;\r
-       gyro_dev_reset(client);\r
-       ewtsa_system_restart(client);\r
-       return result;\r
-}\r
-\r
-\r
-static int gyro_report_value(struct i2c_client *client, struct sensor_axis *axis)\r
-{\r
-       struct sensor_private_data *sensor =\r
-               (struct sensor_private_data *) i2c_get_clientdata(client);      \r
-\r
-       /* Report GYRO  information */\r
-       input_report_rel(sensor->input_dev, ABS_RX, axis->x);\r
-       input_report_rel(sensor->input_dev, ABS_RY, axis->y);\r
-       input_report_rel(sensor->input_dev, ABS_RZ, axis->z);\r
-       input_sync(sensor->input_dev);\r
-       DBG("gyro x==%d  y==%d z==%d\n",axis->x,axis->y,axis->z);\r
-\r
-       return 0;\r
-}\r
-\r
-static int sensor_report_value(struct i2c_client *client)\r
-{\r
-       struct sensor_private_data *sensor =\r
-               (struct sensor_private_data *) i2c_get_clientdata(client);      \r
-       struct sensor_platform_data *pdata = sensor->pdata;\r
-       int ret = 0;\r
-       int x = 0, y = 0, z = 0;\r
-       struct sensor_axis axis;\r
-       char buffer[6] = {0};   \r
-       int i = 0;\r
+       sensor->status_cur = SENSOR_OFF;
+       gyro_dev_reset(client);
+       ewtsa_system_restart(client);
+       return result;
+}
+
+
+static int gyro_report_value(struct i2c_client *client, struct sensor_axis *axis)
+{
+       struct sensor_private_data *sensor =
+               (struct sensor_private_data *) i2c_get_clientdata(client);
+
+       /* Report GYRO  information */
+       input_report_rel(sensor->input_dev, ABS_RX, axis->x);
+       input_report_rel(sensor->input_dev, ABS_RY, axis->y);
+       input_report_rel(sensor->input_dev, ABS_RZ, axis->z);
+       input_sync(sensor->input_dev);
+       DBG("gyro x==%d  y==%d z==%d\n",axis->x,axis->y,axis->z);
+
+       return 0;
+}
+
+static int sensor_report_value(struct i2c_client *client)
+{
+       struct sensor_private_data *sensor =
+               (struct sensor_private_data *) i2c_get_clientdata(client);
+       struct sensor_platform_data *pdata = sensor->pdata;
+       int ret = 0;
+       int x = 0, y = 0, z = 0;
+       struct sensor_axis axis;
+       char buffer[6] = {0};
+       int i = 0;
        /* int value = 0; */
-\r
-       memset(buffer, 0, 6);\r
-#if 0  \r
-       /* Data bytes from hardware xL, xH, yL, yH, zL, zH */   \r
-       do {\r
-               buffer[0] = sensor->ops->read_reg;\r
-               ret = sensor_rx_data(client, buffer, sensor->ops->read_len);\r
-               if (ret < 0)\r
-               return ret;\r
-       } while (0);\r
-#else\r
-\r
-       for(i=0; i<6; i++)\r
+
+       memset(buffer, 0, 6);
+#if 0
+       /* Data bytes from hardware xL, xH, yL, yH, zL, zH */
+       do {
+               buffer[0] = sensor->ops->read_reg;
+               ret = sensor_rx_data(client, buffer, sensor->ops->read_len);
+               if (ret < 0)
+               return ret;
+       } while (0);
+#else
+
+       for(i=0; i<6; i++)
        {
-               i2c_read_byte(client, sensor->ops->read_reg + i,&buffer[i]);\r
-       }\r
-#endif\r
-               \r
-       x = (short) (((buffer[0]) << 8) | buffer[1]);\r
-       y = (short) (((buffer[2]) << 8) | buffer[3]);\r
-       z = (short) (((buffer[4]) << 8) | buffer[5]);\r
-
-       //printk("%s: x=%d  y=%d z=%d \n",__func__, x,y,z);\r
+               i2c_read_byte(client, sensor->ops->read_reg + i,&buffer[i]);
+       }
+#endif
+
+       x = (short) (((buffer[0]) << 8) | buffer[1]);
+       y = (short) (((buffer[2]) << 8) | buffer[3]);
+       z = (short) (((buffer[4]) << 8) | buffer[5]);
+
+       //printk("%s: x=%d  y=%d z=%d \n",__func__, x,y,z);
        if(pdata && pdata->orientation)
        {
                axis.x = (pdata->orientation[0])*x + (pdata->orientation[1])*y + (pdata->orientation[2])*z;
-               axis.y = (pdata->orientation[3])*x + (pdata->orientation[4])*y + (pdata->orientation[5])*z;     
+               axis.y = (pdata->orientation[3])*x + (pdata->orientation[4])*y + (pdata->orientation[5])*z;
                axis.z = (pdata->orientation[6])*x + (pdata->orientation[7])*y + (pdata->orientation[8])*z;
        }
        else
        {
-               axis.x = x;     
+               axis.x = x;
                axis.y = y;
-               axis.z = z;     
+               axis.z = z;
        }
 
        //filter gyro data
-       if((abs(axis.x) > pdata->x_min)||(abs(axis.y) > pdata->y_min)||(abs(axis.z) > pdata->z_min))\r
-       {       \r
-               gyro_report_value(client, &axis);       \r
-\r
-                /* »¥³âµØ»º´æÊý¾Ý. */\r
-               mutex_lock(&(sensor->data_mutex) );\r
-               sensor->axis = axis;\r
-               mutex_unlock(&(sensor->data_mutex) );\r
-       }       \r
-       \r
-       return ret;\r
-}\r
-\r
-\r
-struct sensor_operate gyro_ewtsa_ops = {\r
-       .name                           = "ewtsa",\r
-       .type                           = SENSOR_TYPE_GYROSCOPE,//sensor type and it should be correct\r
-       .id_i2c                         = GYRO_ID_EWTSA,                //i2c id number\r
-       .read_reg                       = GYRO_DATA_REG,                //read data\r
-       .read_len                       = 6,                            //data length\r
-       .id_reg                         = -1,           //read device id from this register\r
-       .id_data                        = -1,           //device id\r
-       .precision                      = 8,                            //8 bits\r
-       .ctrl_reg                       = REG_PWR_MGM,          //enable or disable \r
-       .int_status_reg                 = REG_INT_STATUS,                       //intterupt status register,if no exist then -1\r
-       .range                          = {-32768,32768},               //range\r
-       .trig                           = IRQF_TRIGGER_HIGH|IRQF_ONESHOT,               \r
-       .active                         = sensor_active,        \r
-       .init                           = sensor_init,\r
-       .report                         = sensor_report_value,\r
-};\r
-\r
-/****************operate according to sensor chip:end************/\r
-\r
-//function name should not be changed\r
-static struct sensor_operate *gyro_get_ops(void)\r
-{\r
-       return &gyro_ewtsa_ops;\r
-}\r
-\r
-\r
-static int __init gyro_ewtsa_init(void)\r
-{\r
-       struct sensor_operate *ops = gyro_get_ops();\r
-       int result = 0;\r
-       int type = ops->type;\r
-       result = sensor_register_slave(type, NULL, NULL, gyro_get_ops);\r
-       return result;\r
-}\r
-\r
-static void __exit gyro_ewtsa_exit(void)\r
-{\r
-       struct sensor_operate *ops = gyro_get_ops();\r
-       int type = ops->type;\r
-       sensor_unregister_slave(type, NULL, NULL, gyro_get_ops);\r
-}\r
-\r
-\r
-module_init(gyro_ewtsa_init);\r
-module_exit(gyro_ewtsa_exit);\r
-\r
-\r
+       if((abs(axis.x) > pdata->x_min)||(abs(axis.y) > pdata->y_min)||(abs(axis.z) > pdata->z_min))
+       {
+               gyro_report_value(client, &axis);
+
+                /* »¥³âµØ»º´æÊý¾Ý. */
+               mutex_lock(&(sensor->data_mutex) );
+               sensor->axis = axis;
+               mutex_unlock(&(sensor->data_mutex) );
+       }
+
+       return ret;
+}
+
+
+struct sensor_operate gyro_ewtsa_ops = {
+       .name                           = "ewtsa",
+       .type                           = SENSOR_TYPE_GYROSCOPE,//sensor type and it should be correct
+       .id_i2c                         = GYRO_ID_EWTSA,                //i2c id number
+       .read_reg                       = GYRO_DATA_REG,                //read data
+       .read_len                       = 6,                            //data length
+       .id_reg                         = -1,           //read device id from this register
+       .id_data                        = -1,           //device id
+       .precision                      = 8,                            //8 bits
+       .ctrl_reg                       = REG_PWR_MGM,          //enable or disable
+       .int_status_reg                 = REG_INT_STATUS,                       //intterupt status register,if no exist then -1
+       .range                          = {-32768,32768},               //range
+       .trig                           = IRQF_TRIGGER_HIGH|IRQF_ONESHOT,
+       .active                         = sensor_active,
+       .init                           = sensor_init,
+       .report                         = sensor_report_value,
+};
+
+/****************operate according to sensor chip:end************/
+
+//function name should not be changed
+static struct sensor_operate *gyro_get_ops(void)
+{
+       return &gyro_ewtsa_ops;
+}
+
+
+static int __init gyro_ewtsa_init(void)
+{
+       struct sensor_operate *ops = gyro_get_ops();
+       int result = 0;
+       int type = ops->type;
+       result = sensor_register_slave(type, NULL, NULL, gyro_get_ops);
+       return result;
+}
+
+static void __exit gyro_ewtsa_exit(void)
+{
+       struct sensor_operate *ops = gyro_get_ops();
+       int type = ops->type;
+       sensor_unregister_slave(type, NULL, NULL, gyro_get_ops);
+}
+
+
+module_init(gyro_ewtsa_init);
+module_exit(gyro_ewtsa_exit);
+
+