From 7547a288d59421f1c6647e0ab62c83210b7b6f7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Wed, 29 Aug 2012 12:22:59 +0800 Subject: [PATCH] input: sensor-dev: todos and fix build error without earlysuspend, fix gcc warning --- drivers/input/sensors/sensor-dev.c | 46 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/input/sensors/sensor-dev.c b/drivers/input/sensors/sensor-dev.c index 81d5f559ca05..4eb052a5065d 100755 --- a/drivers/input/sensors/sensor-dev.c +++ b/drivers/input/sensors/sensor-dev.c @@ -317,7 +317,7 @@ error: return result; } - +#ifdef CONFIG_HAS_EARLYSUSPEND static void sensor_suspend(struct early_suspend *h) { struct sensor_private_data *sensor = @@ -336,6 +336,7 @@ static void sensor_resume(struct early_suspend *h) if(sensor->ops->resume) sensor->ops->resume(sensor->client); } +#endif static int gsensor_dev_open(struct inode *inode, struct file *file) { @@ -381,9 +382,9 @@ static long gsensor_dev_ioctl(struct file *file, break; default: break; - } - - switch (cmd) { + } + + switch (cmd) { case GSENSOR_IOCTL_START: DBG("%s:GSENSOR_IOCTL_START start,status=%d\n", __func__,sensor->status_cur); mutex_lock(&sensor->operation_mutex); @@ -413,7 +414,7 @@ static long gsensor_dev_ioctl(struct file *file, mutex_unlock(&sensor->operation_mutex); DBG("%s:GSENSOR_IOCTL_START OK\n", __func__); break; - + case GSENSOR_IOCTL_CLOSE: DBG("%s:GSENSOR_IOCTL_CLOSE start,status=%d\n", __func__,sensor->status_cur); mutex_lock(&sensor->operation_mutex); @@ -442,7 +443,7 @@ static long gsensor_dev_ioctl(struct file *file, mutex_unlock(&sensor->operation_mutex); break; - + case GSENSOR_IOCTL_APP_SET_RATE: DBG("%s:GSENSOR_IOCTL_APP_SET_RATE start\n", __func__); mutex_lock(&sensor->operation_mutex); @@ -465,9 +466,9 @@ static long gsensor_dev_ioctl(struct file *file, default: result = -ENOTTY; goto error; - } - - switch (cmd) { + } + + switch (cmd) { case GSENSOR_IOCTL_GETDATA: if ( copy_to_user(argp, &axis, sizeof(axis) ) ) { printk("failed to copy sense data to user space."); @@ -475,20 +476,21 @@ static long gsensor_dev_ioctl(struct file *file, goto error; } DBG("%s:GSENSOR_IOCTL_GETDATA OK\n", __func__); - break; - default: - break; + break; + default: + break; } error: return result; } -static ssize_t gsensor_set_orientation_online(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t gsensor_set_orientation_online(struct class *class, + struct class_attribute *attr, const char *buf, size_t count) { int i=0; char orientation[20]; + char *tmp; struct sensor_private_data *sensor = g_sensor[SENSOR_TYPE_ACCEL]; struct sensor_platform_data *pdata = sensor->pdata; @@ -499,7 +501,7 @@ static ssize_t gsensor_set_orientation_online(struct device *dev, int end = strcspn(p,"}"); strncpy(orientation,p+start,end-start+1); - char *tmp = orientation; + tmp = orientation; while(strncmp(tmp,"}",1)!=0) @@ -532,7 +534,7 @@ static ssize_t gsensor_set_orientation_online(struct device *dev, } -static CLASS_ATTR(orientation, 0660, NULL,gsensor_set_orientation_online); +static CLASS_ATTR(orientation, 0660, NULL, gsensor_set_orientation_online); static int gsensor_class_init(void) { @@ -760,9 +762,9 @@ static long light_dev_ioctl(struct file *file, switch(cmd) { - case LIGHTSENSOR_IOCTL_GET_ENABLED: + case LIGHTSENSOR_IOCTL_GET_ENABLED: *argp = sensor->status_cur; - break; + break; case LIGHTSENSOR_IOCTL_ENABLE: DBG("%s:LIGHTSENSOR_IOCTL_ENABLE start\n", __func__); mutex_lock(&sensor->operation_mutex); @@ -845,7 +847,7 @@ static long proximity_dev_ioctl(struct file *file, { case PSENSOR_IOCTL_GET_ENABLED: *argp = sensor->status_cur; - break; + break; case PSENSOR_IOCTL_ENABLE: DBG("%s:PSENSOR_IOCTL_ENABLE start\n", __func__); mutex_lock(&sensor->operation_mutex); @@ -1264,7 +1266,7 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid) } sensor->input_dev->dev.parent = &client->dev; - + result = input_register_device(sensor->input_dev); if (result) { dev_err(&client->dev, @@ -1328,11 +1330,13 @@ out_no_free: static void sensor_shut_down(struct i2c_client *client) { +#ifdef CONFIG_HAS_EARLYSUSPEND struct sensor_private_data *sensor = (struct sensor_private_data *) i2c_get_clientdata(client); if((sensor->ops->suspend) && (sensor->ops->resume)) unregister_early_suspend(&sensor->early_suspend); DBG("%s:%s\n",__func__,sensor->i2c_id->name); +#endif } static int sensor_remove(struct i2c_client *client) @@ -1348,7 +1352,7 @@ static int sensor_remove(struct i2c_client *client) kfree(sensor); #ifdef CONFIG_HAS_EARLYSUSPEND if((sensor->ops->suspend) && (sensor->ops->resume)) - unregister_early_suspend(&sensor->early_suspend); + unregister_early_suspend(&sensor->early_suspend); #endif return result; } -- 2.34.1