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
This commit is contained in:
Oliver Ruiz Dorantes 2008-02-12 21:08:43 +00:00
parent 485b82bace
commit e6b529a362
3 changed files with 27 additions and 18 deletions

View File

@ -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

View File

@ -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, &notify_hooks);
usb->register_driver(BLUETOOTH_DEVICE_DEVFS_NAME, supported_devices, 1, NULL);
usb->install_notify(BLUETOOTH_DEVICE_DEVFS_NAME, &notify_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);

View File

@ -17,7 +17,6 @@
#include <net/net_buffer.h>
#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)