input: sensor-dev: todos and fix build error without earlysuspend, fix gcc warning
author黄涛 <huangtao@rock-chips.com>
Wed, 29 Aug 2012 04:22:59 +0000 (12:22 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 29 Aug 2012 04:22:59 +0000 (12:22 +0800)
drivers/input/sensors/sensor-dev.c

index 81d5f559ca0592085f6a8e7aeffe420c9332922c..4eb052a5065d07c5e2ee47fe609ec7501580bd2b 100755 (executable)
@@ -317,7 +317,7 @@ error:
        return result;\r
 }\r
 \r
-\r
+#ifdef CONFIG_HAS_EARLYSUSPEND\r
 static void sensor_suspend(struct early_suspend *h)\r
 {\r
        struct sensor_private_data *sensor = \r
@@ -336,6 +336,7 @@ static void sensor_resume(struct early_suspend *h)
        if(sensor->ops->resume)\r
                sensor->ops->resume(sensor->client);\r
 }\r
+#endif\r
 \r
 static int gsensor_dev_open(struct inode *inode, struct file *file)\r
 {\r
@@ -381,9 +382,9 @@ static long gsensor_dev_ioctl(struct file *file,
                break;\r
        default:\r
                break;\r
-       }
-
-       switch (cmd) {
+       }\r
+\r
+       switch (cmd) {\r
        case GSENSOR_IOCTL_START:       \r
                DBG("%s:GSENSOR_IOCTL_START start,status=%d\n", __func__,sensor->status_cur);\r
                mutex_lock(&sensor->operation_mutex);   \r
@@ -413,7 +414,7 @@ static long gsensor_dev_ioctl(struct file *file,
                mutex_unlock(&sensor->operation_mutex);\r
                DBG("%s:GSENSOR_IOCTL_START OK\n", __func__);\r
                break;\r
-
+\r
        case GSENSOR_IOCTL_CLOSE:                               \r
                DBG("%s:GSENSOR_IOCTL_CLOSE start,status=%d\n", __func__,sensor->status_cur);\r
                mutex_lock(&sensor->operation_mutex);           \r
@@ -442,7 +443,7 @@ static long gsensor_dev_ioctl(struct file *file,
                \r
                mutex_unlock(&sensor->operation_mutex); \r
                break;\r
-
+\r
        case GSENSOR_IOCTL_APP_SET_RATE:                \r
                DBG("%s:GSENSOR_IOCTL_APP_SET_RATE start\n", __func__);         \r
                mutex_lock(&sensor->operation_mutex);   \r
@@ -465,9 +466,9 @@ static long gsensor_dev_ioctl(struct file *file,
        default:\r
                result = -ENOTTY;\r
        goto error;\r
-       }
-
-       switch (cmd) {
+       }\r
+\r
+       switch (cmd) {\r
        case GSENSOR_IOCTL_GETDATA:\r
                if ( copy_to_user(argp, &axis, sizeof(axis) ) ) {\r
                    printk("failed to copy sense data to user space.");\r
@@ -475,20 +476,21 @@ static long gsensor_dev_ioctl(struct file *file,
                                goto error;\r
                }               \r
                DBG("%s:GSENSOR_IOCTL_GETDATA OK\n", __func__);\r
-               break;
-       default:
-               break;
+               break;\r
+       default:\r
+               break;\r
        }\r
        \r
 error:\r
        return result;\r
 }\r
 \r
-static ssize_t gsensor_set_orientation_online(struct device *dev,\r
-               struct device_attribute *attr, char *buf)\r
+static ssize_t gsensor_set_orientation_online(struct class *class,\r
+               struct class_attribute *attr, const char *buf, size_t count)\r
 {\r
        int i=0;\r
        char orientation[20];\r
+       char *tmp;\r
        \r
        struct sensor_private_data *sensor = g_sensor[SENSOR_TYPE_ACCEL];\r
        struct sensor_platform_data *pdata = sensor->pdata;\r
@@ -499,7 +501,7 @@ static ssize_t gsensor_set_orientation_online(struct device *dev,
        int end = strcspn(p,"}");\r
        \r
        strncpy(orientation,p+start,end-start+1);\r
-       char *tmp = orientation;\r
+       tmp = orientation;\r
        \r
 \r
        while(strncmp(tmp,"}",1)!=0)\r
@@ -532,7 +534,7 @@ static ssize_t gsensor_set_orientation_online(struct device *dev,
 \r
 }\r
 \r
-static CLASS_ATTR(orientation, 0660, NULL,gsensor_set_orientation_online);\r
+static CLASS_ATTR(orientation, 0660, NULL, gsensor_set_orientation_online);\r
 \r
 static int  gsensor_class_init(void)\r
 {\r
@@ -760,9 +762,9 @@ static long light_dev_ioctl(struct file *file,
 \r
        switch(cmd)\r
        {\r
-               case LIGHTSENSOR_IOCTL_GET_ENABLED:
+               case LIGHTSENSOR_IOCTL_GET_ENABLED:\r
                        *argp = sensor->status_cur;\r
-                       break;
+                       break;\r
                case LIGHTSENSOR_IOCTL_ENABLE:          \r
                        DBG("%s:LIGHTSENSOR_IOCTL_ENABLE start\n", __func__);\r
                        mutex_lock(&sensor->operation_mutex);    \r
@@ -845,7 +847,7 @@ static long proximity_dev_ioctl(struct file *file,
        {\r
                case PSENSOR_IOCTL_GET_ENABLED:\r
                        *argp = sensor->status_cur;\r
-                       break;
+                       break;\r
                case PSENSOR_IOCTL_ENABLE:              \r
                        DBG("%s:PSENSOR_IOCTL_ENABLE start\n", __func__);\r
                        mutex_lock(&sensor->operation_mutex);    \r
@@ -1264,7 +1266,7 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
 \r
        }\r
        sensor->input_dev->dev.parent = &client->dev;\r
-
+\r
        result = input_register_device(sensor->input_dev);\r
        if (result) {\r
                dev_err(&client->dev,\r
@@ -1328,11 +1330,13 @@ out_no_free:
 \r
 static void sensor_shut_down(struct i2c_client *client)\r
 {\r
+#ifdef CONFIG_HAS_EARLYSUSPEND\r
        struct sensor_private_data *sensor =\r
            (struct sensor_private_data *) i2c_get_clientdata(client);\r
        if((sensor->ops->suspend) && (sensor->ops->resume))             \r
                unregister_early_suspend(&sensor->early_suspend);\r
        DBG("%s:%s\n",__func__,sensor->i2c_id->name);\r
+#endif\r
 }\r
 \r
 static int sensor_remove(struct i2c_client *client)\r
@@ -1348,7 +1352,7 @@ static int sensor_remove(struct i2c_client *client)
        kfree(sensor);\r
 #ifdef CONFIG_HAS_EARLYSUSPEND\r
        if((sensor->ops->suspend) && (sensor->ops->resume))\r
-       unregister_early_suspend(&sensor->early_suspend);\r
+               unregister_early_suspend(&sensor->early_suspend);\r
 #endif  \r
        return result;\r
 }\r