Bluetooth: Use IS_ERR_OR_NULL for checking bt_debugfs
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 18 Oct 2013 00:24:16 +0000 (17:24 -0700)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 18 Oct 2013 07:45:19 +0000 (10:45 +0300)
Make sure to use IS_ERR_OR_NULL for checking the existing of the root
debugfs dentry bt_debugfs.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
net/bluetooth/l2cap_core.c
net/bluetooth/rfcomm/core.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c

index 8af34d2fdbef38f154931a55f7884638f05160c3..763b7417dab73879530567450fb43fb3046802cf 100644 (file)
@@ -6833,12 +6833,11 @@ int __init l2cap_init(void)
        if (err < 0)
                return err;
 
-       if (bt_debugfs) {
-               l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
-                                                   NULL, &l2cap_debugfs_fops);
-               if (!l2cap_debugfs)
-                       BT_ERR("Failed to create L2CAP debug file");
-       }
+       if (IS_ERR_OR_NULL(bt_debugfs))
+               return 0;
+
+       l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
+                                           NULL, &l2cap_debugfs_fops);
 
        return 0;
 }
index 27e936a7ddd977254460ea71c8da1674d5bb7a85..94d06cbfbc184a6e827aa5c3cbd15d4693eca49a 100644 (file)
@@ -2154,13 +2154,6 @@ static int __init rfcomm_init(void)
                goto unregister;
        }
 
-       if (bt_debugfs) {
-               rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
-                               bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
-               if (!rfcomm_dlc_debugfs)
-                       BT_ERR("Failed to create RFCOMM debug file");
-       }
-
        err = rfcomm_init_ttys();
        if (err < 0)
                goto stop;
@@ -2171,6 +2164,13 @@ static int __init rfcomm_init(void)
 
        BT_INFO("RFCOMM ver %s", VERSION);
 
+       if (IS_ERR_OR_NULL(bt_debugfs))
+               return 0;
+
+       rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
+                                                bt_debugfs, NULL,
+                                                &rfcomm_dlc_debugfs_fops);
+
        return 0;
 
 cleanup:
index df17276eb32b5f62d5d1f5ce915720276c4a42a6..c4d3d423f89b84d41b9ff0e6919e9f37786f4960 100644 (file)
@@ -1051,15 +1051,15 @@ int __init rfcomm_init_sockets(void)
                goto error;
        }
 
-       if (bt_debugfs) {
-               rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
-                               bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
-               if (!rfcomm_sock_debugfs)
-                       BT_ERR("Failed to create RFCOMM debug file");
-       }
-
        BT_INFO("RFCOMM socket layer initialized");
 
+       if (IS_ERR_OR_NULL(bt_debugfs))
+               return 0;
+
+       rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
+                                                 bt_debugfs, NULL,
+                                                 &rfcomm_sock_debugfs_fops);
+
        return 0;
 
 error:
index a92aebac56caf631eb8ebe9ade6dc462c3988a16..12a0e51e21e13631beeec14d97e64aa137fd0e99 100644 (file)
@@ -1177,15 +1177,14 @@ int __init sco_init(void)
                goto error;
        }
 
-       if (bt_debugfs) {
-               sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs,
-                                                 NULL, &sco_debugfs_fops);
-               if (!sco_debugfs)
-                       BT_ERR("Failed to create SCO debug file");
-       }
-
        BT_INFO("SCO socket layer initialized");
 
+       if (IS_ERR_OR_NULL(bt_debugfs))
+               return 0;
+
+       sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs,
+                                         NULL, &sco_debugfs_fops);
+
        return 0;
 
 error: