From f510899da42a07e3d90834c0a927bbcbb31ddb8b Mon Sep 17 00:00:00 2001 From: Raffaele Aquilone Date: Tue, 15 May 2012 14:09:00 +0200 Subject: [PATCH] Bluetooth: synchronization for name assignment to HCI devices BZ: 36212 Improves readability, changing name to a variable and a macro Change-Id: I62b9bf349f18d3fa04bd51a9e40171fbe6575bac Signed-off-by: Raffaele Aquilone Reviewed-on: http://android.intel.com:8080/48832 Reviewed-by: Beldie, OvidiuX Reviewed-by: Bransiec, ChristopheX Reviewed-by: Gros, JulienX Reviewed-by: Gross, Mark Reviewed-by: Kanigeri, Hari K Tested-by: Zurmely, PierreX Reviewed-by: buildbot Tested-by: buildbot --- include/net/bluetooth/hci.h | 4 ++-- net/bluetooth/hci_sysfs.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4516a60..5c51ef7 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -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 diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 4e4c250..243317c 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -9,7 +9,7 @@ #include #include -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; } -- 2.7.4