h2generic: Fix x86_64 build

This commit is contained in:
Alexander von Gluck IV
2016-04-09 20:57:34 -05:00
parent b4a9d9a6d6
commit f29863944e
2 changed files with 40 additions and 36 deletions
@@ -123,9 +123,10 @@ spawn_device(usb_device* usb_dev)
for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) {
if (bt_usb_devices[i] == NULL) { if (bt_usb_devices[i] == NULL) {
bt_usb_devices[i] = new_bt_dev; bt_usb_devices[i] = new_bt_dev;
sprintf(new_bt_dev->name, "%s/%ld", BLUETOOTH_DEVICE_PATH, i); sprintf(new_bt_dev->name, "%s/%" B_PRId32,
BLUETOOTH_DEVICE_PATH, i);
new_bt_dev->num = i; new_bt_dev->num = i;
debugf("added device %p %ld %s\n", bt_usb_devices[i], debugf("added device %p %" B_PRId32 " %s\n", bt_usb_devices[i],
new_bt_dev->num, new_bt_dev->name); new_bt_dev->num, new_bt_dev->name);
break; break;
} }
@@ -183,21 +184,21 @@ fetch_device(bt_usb_dev* dev, hci_id hid)
// debugf("(%p) or %d\n", dev, hid); // debugf("(%p) or %d\n", dev, hid);
acquire_sem(dev_table_sem); acquire_sem(dev_table_sem);
if (dev != NULL) if (dev != NULL) {
for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) {
if (bt_usb_devices[i] == dev) { if (bt_usb_devices[i] == dev) {
release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE);
return bt_usb_devices[i]; return bt_usb_devices[i];
} }
} }
else } else {
for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) {
if (bt_usb_devices[i] != NULL && bt_usb_devices[i]->hdev == hid) { if (bt_usb_devices[i] != NULL && bt_usb_devices[i]->hdev == hid) {
release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE);
return bt_usb_devices[i]; return bt_usb_devices[i];
} }
} }
}
release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE);
@@ -227,7 +228,7 @@ device_added(usb_device* dev, void** cookie)
bt_usb_dev* new_bt_dev = spawn_device(dev); bt_usb_dev* new_bt_dev = spawn_device(dev);
int e; int e;
debugf("device_added(%ld, %p)\n", dev, new_bt_dev); debugf("device_added(%p)\n", new_bt_dev);
if (new_bt_dev == NULL) { if (new_bt_dev == NULL) {
flowf("Couldn't allocate device record.\n"); flowf("Couldn't allocate device record.\n");
@@ -244,21 +245,22 @@ device_added(usb_device* dev, void** cookie)
goto bail; goto bail;
} }
debugf("found %ld alt interfaces.\n", config->interface->alt_count); debugf("found %" B_PRIuSIZE " alt interfaces.\n",
config->interface->alt_count);
// set first interface // set first interface
interface = &config->interface->alt[0]; interface = &config->interface->alt[0];
err = usb->set_alt_interface(new_bt_dev->dev, interface); err = usb->set_alt_interface(new_bt_dev->dev, interface);
if (err != B_OK) { if (err != B_OK) {
debugf("set_alt_interface() returned %ld.\n", err); debugf("%s: set_alt_interface() error.\n", __func__);
goto bail; goto bail;
} }
// call set_configuration() only after calling set_alt_interface() // call set_configuration() only after calling set_alt_interface()
err = usb->set_configuration(dev, config); err = usb->set_configuration(dev, config);
if (err != B_OK) { if (err != B_OK) {
debugf("set_configuration() returned %ld.\n", err); debugf("%s: set_configuration() error.\n", __func__);
goto bail; goto bail;
} }
@@ -294,7 +296,9 @@ device_added(usb_device* dev, void** cookie)
goto bail; goto bail;
} }
debugf("Found %ld interfaces. Expected 3\n", config->interface_count); debugf("Found %" B_PRIuSIZE " interfaces. Expected 3\n",
config->interface_count);
// Find endpoints that we need // Find endpoints that we need
uif = config->interface->active; uif = config->interface->active;
for (e = 0; e < uif->descr->num_endpoints; e++) { for (e = 0; e < uif->descr->num_endpoints; e++) {
@@ -419,7 +423,7 @@ submit_nbuffer(hci_id hid, net_buffer* nbuf)
bdev = fetch_device(NULL, hid); bdev = fetch_device(NULL, hid);
debugf("index=%lx nbuf=%p bdev=%p\n",hid, nbuf, bdev); debugf("index=%" B_PRId32 " nbuf=%p bdev=%p\n", hid, nbuf, bdev);
if (bdev != NULL) { if (bdev != NULL) {
switch (nbuf->protocol) { switch (nbuf->protocol) {
@@ -536,7 +540,7 @@ device_close(void* cookie)
if (bdev == NULL) if (bdev == NULL)
panic("bad cookie"); panic("bad cookie");
debugf("device_close() called on %ld\n", bdev->hdev ); debugf("%s: device_close() called\n", __func__);
// Clean queues // Clean queues
@@ -560,15 +564,13 @@ device_close(void* cookie)
// TX // TX
for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) {
if (i == BT_COMMAND) if (i == BT_COMMAND) {
while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL)
snb_free((snet_buffer*)item); snb_free((snet_buffer*)item);
} } else {
else while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL)
while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) {
nb_destroy((net_buffer*)item); nb_destroy((net_buffer*)item);
} }
} }
// RX // RX
for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) { for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) {
@@ -623,7 +625,7 @@ device_control(void* cookie, uint32 msg, void* params, size_t size)
#endif #endif
TOUCH(size); TOUCH(size);
debugf("ioctl() opcode %ld size %ld.\n", msg, size); debugf("ioctl() opcode %" B_PRId32 " size %" B_PRIuSIZE ".\n", msg, size);
if (bdev == NULL) { if (bdev == NULL) {
flowf("Bad cookie\n"); flowf("Bad cookie\n");
@@ -656,7 +658,7 @@ device_control(void* cookie, uint32 msg, void* params, size_t size)
snb_put(snbuf, params, size); snb_put(snbuf, params, size);
err = submit_tx_command(bdev, snbuf); err = submit_tx_command(bdev, snbuf);
debugf("command launched %ld\n", err); debugf("%s: command launched\n", __func__);
break; break;
case BT_UP: case BT_UP:
@@ -701,7 +703,7 @@ device_control(void* cookie, uint32 msg, void* params, size_t size)
default: default:
debugf("Invalid opcode %ld.\n", msg); debugf("%s: Invalid opcode.\n", __func__);
err = B_DEV_INVALID_IOCTL; err = B_DEV_INVALID_IOCTL;
break; break;
} }
@@ -715,7 +717,7 @@ device_control(void* cookie, uint32 msg, void* params, size_t size)
static status_t static status_t
device_read(void* cookie, off_t pos, void* buffer, size_t* count) device_read(void* cookie, off_t pos, void* buffer, size_t* count)
{ {
debugf("Reading... count = %ld\n", *count); debugf("Reading... count = %" B_PRIuSIZE "\n", *count);
*count = 0; *count = 0;
return B_OK; return B_OK;
@@ -769,7 +771,8 @@ init_driver(void)
int j; int j;
flowf("init_driver()\n"); flowf("init_driver()\n");
if (get_module(BT_CORE_DATA_MODULE_NAME,(module_info**)&btCoreData) != B_OK) { if (get_module(BT_CORE_DATA_MODULE_NAME,
(module_info**)&btCoreData) != B_OK) {
debugf("cannot get module \"%s\"\n", BT_CORE_DATA_MODULE_NAME); debugf("cannot get module \"%s\"\n", BT_CORE_DATA_MODULE_NAME);
return B_ERROR; return B_ERROR;
} else } else
@@ -910,7 +913,7 @@ publish_devices(void)
release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE);
publish_names[i] = NULL; publish_names[i] = NULL;
debugf("published %ld devices\n", i); debugf("published %" B_PRId32 " devices\n", i);
// TODO: this method might make better memory use // TODO: this method might make better memory use
// dev_names = (char**)malloc(sizeof(char*) * (dev_count + 1)); // dev_names = (char**)malloc(sizeof(char*) * (dev_count + 1));
@@ -63,7 +63,8 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
// bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer / slower option // bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer / slower option
status_t error; status_t error;
debugf("cookie@%p status=%s len=%ld\n", cookie, strerror(status), actual_len); debugf("cookie@%p status=%s len=%" B_PRIuSIZE "\n", cookie,
strerror(status), actual_len);
if (bdev == NULL) if (bdev == NULL)
return; return;
@@ -212,7 +213,7 @@ command_complete(void* cookie, status_t status, void* data, size_t actual_len)
snet_buffer* snbuf = (snet_buffer*)cookie; snet_buffer* snbuf = (snet_buffer*)cookie;
bt_usb_dev* bdev = (bt_usb_dev*)snb_cookie(snbuf); bt_usb_dev* bdev = (bt_usb_dev*)snb_cookie(snbuf);
debugf("status = %ld len = %ld @%p\n", status, actual_len, data); debugf("len = %" B_PRIuSIZE " @%p\n", actual_len, data);
if (status == B_OK) { if (status == B_OK) {
bdev->stat.successfulTX++; bdev->stat.successfulTX++;
@@ -241,7 +242,7 @@ acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len)
net_buffer* nbuf = (net_buffer*)cookie; net_buffer* nbuf = (net_buffer*)cookie;
bt_usb_dev* bdev = GET_DEVICE(nbuf); bt_usb_dev* bdev = GET_DEVICE(nbuf);
debugf("fetched=%p status=%ld type %lx %p\n", bdev, status, nbuf->type, data); //debugf("fetched=%p type %lx %p\n", bdev, nbuf->type, data);
if (status == B_OK) { if (status == B_OK) {
bdev->stat.successfulTX++; bdev->stat.successfulTX++;