From e6b529a362a547fe1972d1ff0e79e6467af701ca Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Tue, 12 Feb 2008 21:08:43 +0000 Subject: [PATCH] Build the device path in devfs from the configuration file git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23955 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/bluetooth/h2/h2generic/h2cfg.h | 19 +++++++++++++++---- .../bluetooth/h2/h2generic/h2generic.c | 17 ++++++++--------- .../bluetooth/h2/h2generic/h2generic.h | 9 ++++----- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h index d60544eff4..a990dcdbfe 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2cfg.h @@ -8,13 +8,14 @@ #ifndef _H2CFG_H_ #define _H2CFG_H_ -/* TODO: move exclusive header for drivers*/ + #define BT_DRIVER_SUPPORTS_CMD 1 #define BT_DRIVER_SUPPORTS_EVT 1 #define BT_DRIVER_SUPPORTS_ESCO 0 #define BT_DRIVER_SUPPORTS_SCO 0 #define BT_DRIVER_SUPPORTS_ACL 0 +/* TODO: move exclusive header for drivers*/ #define BT_DRIVER_RXCOVERAGE (BT_DRIVER_SUPPORTS_EVT+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) #define BT_DRIVER_TXCOVERAGE (BT_DRIVER_SUPPORTS_CMD+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO) @@ -22,11 +23,21 @@ #error incomplete Bluetooth driver Commands and Events should be implemented #endif - -//////////////////////////////////// - #define BT_SURVIVE_WITHOUT_HCI #define BT_SURVIVE_WITHOUT_NET_BUFFERS +//////////////////////////////////// + +#ifndef BLUETOOTH_DEVICE_TRANSPORT +#error BLUETOOTH_DEVICE_TRANSPORT must be defined to build the publishing path +#endif + +#ifndef BLUETOOTH_DEVICE_NAME +#error BLUETOOTH_DEVICE_NAME must be defined to build the publishing path +#endif + +#define BLUETOOTH_DEVICE_DEVFS_NAME BLUETOOTH_DEVICE_TRANSPORT BLUETOOTH_DEVICE_NAME +#define BLUETOOTH_DEVICE_PATH "bluetooth/" BLUETOOTH_DEVICE_DEVFS_NAME + #endif diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c index edfe63879c..c68da4ce7a 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c @@ -96,14 +96,14 @@ spawn_device(const usb_device* usb_dev) memset(new_bt_dev, 0, sizeof(bt_usb_dev) ); /* We will need this sem for some flow control */ - new_bt_dev->cmd_complete = create_sem(1, ID "cmd_complete"); + new_bt_dev->cmd_complete = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "cmd_complete"); if (new_bt_dev->cmd_complete < 0) { err = new_bt_dev->cmd_complete; goto bail0; } /* and this for something else */ - new_bt_dev->lock = create_sem(1, ID "lock"); + new_bt_dev->lock = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "lock"); if (new_bt_dev->lock < 0) { err = new_bt_dev->lock; goto bail1; @@ -114,7 +114,7 @@ spawn_device(const usb_device* usb_dev) for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { if (bt_usb_devices[i] == NULL) { bt_usb_devices[i] = new_bt_dev; - sprintf(new_bt_dev->name, "%s/%ld", DEVICE_PATH, i); + sprintf(new_bt_dev->name, "%s/%ld", BLUETOOTH_DEVICE_PATH, i); new_bt_dev->num = i; debugf("added device %p %ld %s\n", bt_usb_devices[i] ,new_bt_dev->num,new_bt_dev->name); break; @@ -556,7 +556,7 @@ device_free (void *cookie) status_t err = B_OK; bt_usb_dev* dev = (bt_usb_dev*)cookie; - debugf("device_free() called on \"%s %ld\"\n",DEVICE_PATH, dev->num); + debugf("device_free() called on %s \n",BLUETOOTH_DEVICE_PATH); if (--dev->open_count == 0) { @@ -693,7 +693,7 @@ init_driver(void) debugf("nb module at %p\n", nb); // GENERAL INITS - dev_table_sem = create_sem(1, ID "dev_table_lock"); + dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock"); if (dev_table_sem < 0) { goto err; } @@ -704,8 +704,8 @@ init_driver(void) /* After here device_added and publish devices hooks are called be carefull USB devs */ - usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); - usb->install_notify(DEVICE_NAME, ¬ify_hooks); + usb->register_driver(BLUETOOTH_DEVICE_DEVFS_NAME, supported_devices, 1, NULL); + usb->install_notify(BLUETOOTH_DEVICE_DEVFS_NAME, ¬ify_hooks); return B_OK; @@ -740,8 +740,7 @@ uninit_driver(void) } - usb->uninstall_notify(DEVICE_NAME); - usb->register_driver(DEVICE_NAME, supported_devices, 1, NULL); + usb->uninstall_notify(BLUETOOTH_DEVICE_DEVFS_NAME); /* Releasing modules */ put_module(usb_name); diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h index 7bad302b37..f63c9f25e9 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.h @@ -17,7 +17,6 @@ #include -#include "h2cfg.h" #include "snet_buffer.h" /* USB definitions for the generic device*/ @@ -25,11 +24,11 @@ #define UDSUBCLASS_RF 0x01 #define UDPROTO_BLUETOOTH 0x01 -#define TRANSPORT_NAME "h2" -#define DEVICE_NAME "generic" -#define DEVICE_PATH "bus/bluetooth/" TRANSPORT_NAME "/" DEVICE_NAME +#define BLUETOOTH_DEVICE_TRANSPORT "h2" +#define BLUETOOTH_DEVICE_NAME "generic" +#include "h2cfg.h" -#define ID DEVICE_NAME ": " /* prefix for debug messages */ +//#define ID DEVICE_NAME ": " /* prefix for debug messages */ #define USB_TYPE_CLASS (0x01 << 5) /// Check if it is in some other header #define USB_TYPE_VENDOR (0x02 << 5)