Bluetooth: synchronization for name assignment to HCI devices
authorRaffaele Aquilone <raffaelex.aquilone@intel.com>
Tue, 15 May 2012 12:09:00 +0000 (14:09 +0200)
committerbuildbot <buildbot@intel.com>
Wed, 30 May 2012 18:08:23 +0000 (11:08 -0700)
BZ: 36212

Improves readability, changing name to a variable and a macro

Change-Id: I62b9bf349f18d3fa04bd51a9e40171fbe6575bac
Signed-off-by: Raffaele Aquilone <raffaelex.aquilone@intel.com>
Reviewed-on: http://android.intel.com:8080/48832
Reviewed-by: Beldie, OvidiuX <ovidiux.beldie@intel.com>
Reviewed-by: Bransiec, ChristopheX <christophex.bransiec@intel.com>
Reviewed-by: Gros, JulienX <julienx.gros@intel.com>
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Reviewed-by: Kanigeri, Hari K <hari.k.kanigeri@intel.com>
Tested-by: Zurmely, PierreX <pierrex.zurmely@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
include/net/bluetooth/hci.h
net/bluetooth/hci_sysfs.c

index 4516a60..5c51ef7 100644 (file)
@@ -31,8 +31,8 @@
 #define HCI_MAX_FRAME_SIZE     (HCI_MAX_ACL_SIZE + 4)
 
 /* HCI dev name management */
-#define HCI_NAME_MAX                   20
-#define HCI_NAME_MSEC_DELAY            50
+#define HCI_DEV_SEM_MAX                20
+#define HCI_DEV_SEM_MSEC_DELAY         50
 
 /* HCI dev events */
 #define HCI_DEV_REG                    1
index 4e4c250..243317c 100644 (file)
@@ -9,7 +9,7 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
-static atomic_t hci_name[HCI_NAME_MAX];
+static atomic_t hci_dev_sem[HCI_DEV_SEM_MAX];
 
 static struct class *bt_class;
 
@@ -94,14 +94,14 @@ static void add_conn(struct work_struct *work)
                                                                work_add.work);
        struct hci_dev *hdev = conn->hdev;
 
-       if (conn->handle < HCI_NAME_MAX &&
-                                       atomic_read(&hci_name[conn->handle])) {
+       if (conn->handle < HCI_DEV_SEM_MAX &&
+                               atomic_read(&hci_dev_sem[conn->handle])) {
                queue_delayed_work(conn->hdev->workqueue, &conn->work_add,
-                                       msecs_to_jiffies(HCI_NAME_MSEC_DELAY));
+                               msecs_to_jiffies(HCI_DEV_SEM_MSEC_DELAY));
                return;
        }
-       if (conn->handle < HCI_NAME_MAX)
-               atomic_set(&hci_name[conn->handle], 1);
+       if (conn->handle < HCI_DEV_SEM_MAX)
+               atomic_set(&hci_dev_sem[conn->handle], 1);
 
        dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
 
@@ -109,8 +109,8 @@ static void add_conn(struct work_struct *work)
 
        if (device_add(&conn->dev) < 0) {
                BT_ERR("Failed to register connection device");
-               if (conn->handle < HCI_NAME_MAX)
-                       atomic_set(&hci_name[conn->handle], 0);
+               if (conn->handle < HCI_DEV_SEM_MAX)
+                       atomic_set(&hci_dev_sem[conn->handle], 0);
                return;
        }
 
@@ -149,8 +149,8 @@ static void del_conn(struct work_struct *work)
        put_device(&conn->dev);
 
        hci_dev_put(hdev);
-       if (conn->handle < HCI_NAME_MAX)
-               atomic_set(&hci_name[conn->handle], 0);
+       if (conn->handle < HCI_DEV_SEM_MAX)
+               atomic_set(&hci_dev_sem[conn->handle], 0);
 }
 
 void hci_conn_init_sysfs(struct hci_conn *conn)
@@ -174,7 +174,7 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
        BT_DBG("conn %p", conn);
 
        queue_delayed_work(conn->hdev->workqueue, &conn->work_add,
-                                       msecs_to_jiffies(HCI_NAME_MSEC_DELAY));
+                               msecs_to_jiffies(HCI_DEV_SEM_MSEC_DELAY));
 }
 
 void hci_conn_del_sysfs(struct hci_conn *conn)
@@ -614,8 +614,8 @@ int __init bt_sysfs_init(void)
        bt_class = class_create(THIS_MODULE, "bluetooth");
        if (IS_ERR(bt_class))
                return PTR_ERR(bt_class);
-       for (i = 0; i < HCI_NAME_MAX; i++)
-               atomic_set(&hci_name[i], 0);
+       for (i = 0; i < HCI_DEV_SEM_MAX; i++)
+               atomic_set(&hci_dev_sem[i], 0);
 
        return 0;
 }