input: sensor-dev: fix smatch warning
[firefly-linux-kernel-4.4.55.git] / drivers / input / sensors / sensor-dev.c
index 01bbf40ce2b85a8f3003c2020fc6a37f4806f6cf..0527631730972a9485403269bb1ff1b4b7d6170f 100755 (executable)
@@ -1052,6 +1052,7 @@ static long gyro_dev_ioctl(struct file *file,
                result = sensor->status_cur;\r
                if (copy_to_user(argp, &result, sizeof(result)))\r
                {\r
+                       mutex_unlock(&sensor->operation_mutex);\r
                        printk("%s:failed to copy sense data to user space.\n",__FUNCTION__);\r
                        return -EFAULT;\r
                }\r
@@ -1060,9 +1061,9 @@ static long gyro_dev_ioctl(struct file *file,
                DBG("%s:L3G4200D_IOCTL_SET_ENABLE OK\n", __func__);\r
                break;\r
        case L3G4200D_IOCTL_SET_DELAY:                                  \r
-               mutex_lock(&sensor->operation_mutex);\r
                if (copy_from_user(&rate, argp, sizeof(rate)))\r
                return -EFAULT;\r
+               mutex_lock(&sensor->operation_mutex);\r
                if(sensor->status_cur == SENSOR_OFF)\r
                {\r
                        if ( (result = sensor->ops->active(client, 1, rate) ) < 0 ) {\r
@@ -2041,11 +2042,11 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
        if(result < 0)\r
                goto out_free_memory;\r
        \r
-       sensor->input_dev = input_allocate_device();\r
+       sensor->input_dev = devm_input_allocate_device(&client->dev);\r
        if (!sensor->input_dev) {\r
                result = -ENOMEM;\r
                dev_err(&client->dev,\r
-                       "Failed to allocate input device %s\n", sensor->input_dev->name);\r
+                       "Failed to allocate input device\n");\r
                goto out_free_memory;\r
        }       \r
 \r
@@ -2189,11 +2190,8 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
        return result;\r
        \r
 out_misc_device_register_device_failed:\r
-       input_unregister_device(sensor->input_dev);     \r
 out_input_register_device_failed:\r
-       input_free_device(sensor->input_dev);   \r
 out_free_memory:\r
-       //kfree(sensor);\r
 out_no_free:\r
        dev_err(&client->adapter->dev, "%s failed %d\n\n", __func__, result);\r
        return result;\r
@@ -2219,9 +2217,6 @@ static int sensor_remove(struct i2c_client *client)
        \r
        cancel_delayed_work_sync(&sensor->delaywork);\r
        misc_deregister(&sensor->miscdev);\r
-       input_unregister_device(sensor->input_dev);     \r
-       input_free_device(sensor->input_dev);   \r
-       kfree(sensor);\r
 #ifdef CONFIG_HAS_EARLYSUSPEND\r
        if((sensor->ops->suspend) && (sensor->ops->resume))\r
                unregister_early_suspend(&sensor->early_suspend);\r