OSDN Git Service

input: touchscreen: Handle failure case in Atmel driver
authorVenkata Prahlad Valluru <vvalluru@codeaurora.org>
Tue, 13 Mar 2018 10:17:23 +0000 (15:47 +0530)
committerVenkata Prahlad Valluru <vvalluru@codeaurora.org>
Wed, 14 Mar 2018 03:48:59 +0000 (09:18 +0530)
Handle file already exists and failure case separately.

Change-Id: I0c8004c88feb323b592ad8f622f86fe66cb63006
Signed-off-by: Venkata Prahlad Valluru <vvalluru@codeaurora.org>
drivers/input/touchscreen/atmel_maxtouch_ts.c

index f58fc85..9aa57c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Atmel maXTouch Touchscreen driver
  *
- * Copyright (c) 2014-2015, The Linux Foundation.  All rights reserved.
+ * Copyright (c) 2014-2015, 2018 The Linux Foundation.  All rights reserved.
  *
  * Linux foundation chooses to take subject only to the GPLv2 license terms,
  * and distributes only under these terms.
@@ -529,6 +529,8 @@ static ssize_t mxt_debug_msg_read(struct file *filp, struct kobject *kobj,
 
 static int mxt_debug_msg_init(struct mxt_data *data)
 {
+       int ret;
+
        sysfs_bin_attr_init(&data->debug_msg_attr);
        data->debug_msg_attr.attr.name = "debug_msg";
        data->debug_msg_attr.attr.mode = 0666;
@@ -536,11 +538,20 @@ static int mxt_debug_msg_init(struct mxt_data *data)
        data->debug_msg_attr.write = mxt_debug_msg_write;
        data->debug_msg_attr.size = data->T5_msg_size * DEBUG_MSG_MAX;
 
-       if (sysfs_create_bin_file(&data->client->dev.kobj,
-                                 &data->debug_msg_attr) < 0)
-               dev_info(&data->client->dev, "Debugfs already exists\n");
+       ret = sysfs_create_bin_file(&data->client->dev.kobj,
+                                 &data->debug_msg_attr);
+       if (ret < 0) {
+               if (ret == -EEXIST) {
+                       dev_info(&data->client->dev,
+                                       "Debugfs already exists\n");
+                       ret = 0;
+               } else {
+                       dev_err(&data->client->dev,
+                                       "Failed to create 'debug_msg' file\n");
+               }
+       }
 
-       return 0;
+       return ret;
 }
 
 static void mxt_debug_msg_remove(struct mxt_data *data)