diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2006-08-21 11:07:03 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2006-08-21 11:07:03 +0000 |
commit | 01416cc1b3b051c5b876f0ad8f9233a390ed7225 (patch) | |
tree | 4776e8418b83832f8fdf37164cf775a353d1498c | |
parent | 46b2bfea1a997ffacc4c46c53532681efdfa4a52 (diff) |
Use hci_devinfo in favor of HCIGETDEVINFO ioctl where possible
-rw-r--r-- | hcid/dbus-manager.c | 5 | ||||
-rw-r--r-- | hcid/main.c | 13 | ||||
-rw-r--r-- | hcid/security.c | 4 |
3 files changed, 7 insertions, 15 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index 10d1a07f..b4805632 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -169,10 +169,7 @@ static DBusHandlerResult list_adapters(DBusConnection *conn, char path[MAX_PATH_LENGTH], *path_ptr = path; struct hci_dev_info di; - memset(&di, 0 , sizeof(struct hci_dev_info)); - di.dev_id = dr->dev_id; - - if (ioctl(sk, HCIGETDEVINFO, &di) < 0) + if (hci_devinfo(dr->dev_id, &di) < 0) continue; snprintf(path, sizeof(path), "%s/%s", BASE_PATH, di.name); diff --git a/hcid/main.c b/hcid/main.c index 5aadca01..be71c3ad 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -127,8 +127,7 @@ static struct device_opts *get_device_opts(int sock, int hdev) struct hci_dev_info di; /* First try to get BD_ADDR based settings ... */ - di.dev_id = hdev; - if (!ioctl(sock, HCIGETDEVINFO, (void *) &di)) { + if (!hci_devinfo(hdev, &di) < 0) { char addr[18]; ba2str(&di.bdaddr, addr); device_opts = find_device_opts(addr); @@ -162,8 +161,7 @@ int get_discoverable_timeout(int hdev) if (sock < 0) goto no_address; - di.dev_id = hdev; - if (ioctl(sock, HCIGETDEVINFO, (void *) &di) < 0) { + if (!hci_devinfo(hdev, &di) < 0) { close(sock); goto no_address; } @@ -272,8 +270,7 @@ static void configure_device(int hdev) exit(1); } - di.dev_id = hdev; - if (ioctl(s, HCIGETDEVINFO, (void *) &di) < 0) + if (hci_devinfo(hdev, &di) < 0) exit(1); if (hci_test_bit(HCI_RAW, &di.flags)) @@ -410,9 +407,7 @@ static void init_device(int hdev) exit(1); } - memset(&di, 0, sizeof(di)); - di.dev_id = dev_id; - if (ioctl(dd, HCIGETDEVINFO, (void *) &di) < 0) + if (hci_devinfo(dev_id, &di) < 0) exit(1); if (hci_test_bit(HCI_RAW, &di.flags)) diff --git a/hcid/security.c b/hcid/security.c index 9b02f213..08a5835d 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -821,11 +821,11 @@ void start_security_manager(int hdev) return; } - di->dev_id = hdev; - if (ioctl(dev, HCIGETDEVINFO, (void *)di)) { + if (hci_devinfo(hdev, di) < 0) { error("Can't get device info: %s (%d)", strerror(errno), errno); close(dev); + free(di); return; } |