* Cleanup for 80 char per line limit.

* Don't spam the syslog when the device was not a Wacom.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26553 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-07-21 23:16:48 +00:00
parent a524312842
commit 6df047777a
+57 -38
View File
@@ -142,7 +142,8 @@ add_device(usb_device dev)
DPRINTF_INFO((ID "add_device() - examining interface: %d\n", ifc)); DPRINTF_INFO((ID "add_device() - examining interface: %d\n", ifc));
for (alt = 0; alt < conf->interface[ifc].alt_count; alt++) { for (alt = 0; alt < conf->interface[ifc].alt_count; alt++) {
ii = &conf->interface[ifc].alt[alt]; ii = &conf->interface[ifc].alt[alt];
DPRINTF_INFO((ID "add_device() - examining alt interface: %d\n", alt)); DPRINTF_INFO((ID "add_device() - examining alt interface: "
"%d\n", alt));
// does it have the correct type of interface? // does it have the correct type of interface?
@@ -191,7 +192,8 @@ got_one:
// the interface we found is not the active one and has to be set // the interface we found is not the active one and has to be set
DPRINTF_INFO((ID "add_device() - setting interface: %p...\n", ii)); DPRINTF_INFO((ID "add_device() - setting interface: %p...\n", ii));
if ((st = usb->set_alt_interface(dev, ii)) != B_OK) { if ((st = usb->set_alt_interface(dev, ii)) != B_OK) {
dprintf(ID "add_device() -> set_alt_interface() returns %ld\n", st); dprintf(ID "add_device() -> set_alt_interface() returns %ld\n",
st);
goto fail; goto fail;
} else } else
DPRINTF_ERR((ID " ... success!\n")); DPRINTF_ERR((ID " ... success!\n"));
@@ -205,16 +207,20 @@ got_one:
st = usb->send_request(dev, 0x21, 0x0b, 1, 0, 0, 0, st = usb->send_request(dev, 0x21, 0x0b, 1, 0, 0, 0,
&controlTransferLength); &controlTransferLength);
if (st < B_OK) if (st < B_OK) {
dprintf(ID "add_device() - control transfer 1 failed: %ld\n", st); dprintf(ID "add_device() - control transfer 1 failed: %ld\n",
st);
}
// "set interface" -> ?!? // "set interface" -> ?!?
controlTransferLength = 2; controlTransferLength = 2;
st = usb->send_request(dev, 0x21, 0x09, (3 << 8) + 2, 1, 2, repData, st = usb->send_request(dev, 0x21, 0x09, (3 << 8) + 2, 1, 2, repData,
&controlTransferLength); &controlTransferLength);
if (st < B_OK) if (st < B_OK) {
dprintf(ID "add_device() - control transfer 2 failed: %ld\n", st); dprintf(ID "add_device() - control transfer 2 failed: %ld\n",
st);
}
} }
// } // }
@@ -226,12 +232,14 @@ got_one:
device->data = (char*)malloc(device->max_packet_size); device->data = (char*)malloc(device->max_packet_size);
if (device->data == NULL) if (device->data == NULL)
goto fail; goto fail;
//DPRINTF_INFO((ID "add_device() - max packet length = %ld\n", device->max_packet_size)); //DPRINTF_INFO((ID "add_device() - max packet length = %ld\n",
// device->max_packet_size));
device->status = 0;//B_USB_STATUS_SUCCESS; device->status = 0;//B_USB_STATUS_SUCCESS;
device->vendor = udd->vendor_id; device->vendor = udd->vendor_id;
device->product = udd->product_id; device->product = udd->product_id;
DPRINTF_INFO((ID "add_device() - added %p (/dev/%s%d)\n", device, kBasePublishPath, num)); DPRINTF_INFO((ID "add_device() - added %p (/dev/%s%d)\n", device,
kBasePublishPath, num));
// add it to the list of devices so it will be published, etc // add it to the list of devices so it will be published, etc
acquire_sem(sDeviceListLock); acquire_sem(sDeviceListLock);
@@ -283,7 +291,7 @@ device_added(usb_device dev, void** cookie)
DPRINTF_INFO((ID "device_added() - done!\n")); DPRINTF_INFO((ID "device_added() - done!\n"));
return B_OK; return B_OK;
} else } else
DPRINTF_ERR((ID "device_added() - failed to add device!\n")); DPRINTF_INFO((ID "device_added() - failed to add device!\n"));
return B_ERROR; return B_ERROR;
} }
@@ -325,7 +333,7 @@ device_removed(void *cookie)
remove_device(device); remove_device(device);
} else { } else {
dprintf(ID "device /dev/%s%d still open -- marked for removal\n", dprintf(ID "device /dev/%s%d still open -- marked for removal\n",
kBasePublishPath, device->number); kBasePublishPath, device->number);
} }
release_sem(sDeviceListLock); release_sem(sDeviceListLock);
@@ -340,7 +348,7 @@ device_removed(void *cookie)
// device_open // device_open
static status_t static status_t
device_open(const char *dname, uint32 flags, void **cookie) device_open(const char *dname, uint32 flags, void** cookie)
{ {
wacom_device *device; wacom_device *device;
int n; int n;
@@ -366,11 +374,13 @@ device_open(const char *dname, uint32 flags, void **cookie)
DPRINTF_ERR((ID "device_open() open: %d\n", device->open)); DPRINTF_ERR((ID "device_open() open: %d\n", device->open));
if (device->notify_lock < 0) { if (device->notify_lock < 0) {
if ((device->notify_lock = create_sem(0, "notify_lock")) < 0) { device->notify_lock = create_sem(0, "notify_lock");
if (device->notify_lock < 0) {
ret = device->notify_lock; ret = device->notify_lock;
device->open--; device->open--;
*cookie = NULL; *cookie = NULL;
dprintf(ID "device_open() -> create_sem() returns %ld\n", ret); dprintf(ID "device_open() -> create_sem() returns %ld\n",
ret);
} else { } else {
ret = B_OK; ret = B_OK;
} }
@@ -394,7 +404,8 @@ device_close (void *cookie)
{ {
#if DEBUG_DRIVER #if DEBUG_DRIVER
wacom_device *device = (wacom_device*) cookie; wacom_device *device = (wacom_device*) cookie;
DPRINTF_ERR((ID "device_close() name = \"%s%d\"\n", kBasePublishPath, device->number)); DPRINTF_ERR((ID "device_close() name = \"%s%d\"\n", kBasePublishPath,
device->number));
#endif #endif
return B_OK; return B_OK;
} }
@@ -405,7 +416,8 @@ device_free(void *cookie)
{ {
wacom_device *device = (wacom_device *)cookie; wacom_device *device = (wacom_device *)cookie;
DPRINTF_INFO((ID "device_free() name = \"%s%d\"\n", kBasePublishPath, device->number)); DPRINTF_INFO((ID "device_free() name = \"%s%d\"\n", kBasePublishPath,
device->number));
acquire_sem(sDeviceListLock); acquire_sem(sDeviceListLock);
@@ -423,8 +435,8 @@ device_free(void *cookie)
// device_interupt_callback // device_interupt_callback
static void static void
device_interupt_callback(void* cookie, uint32 status, device_interupt_callback(void* cookie, status_t status, void* data,
void* data, uint32 actualLength) uint32 actualLength)
{ {
wacom_device* device = (wacom_device*)cookie; wacom_device* device = (wacom_device*)cookie;
uint32 length = min_c(actualLength, device->max_packet_size); uint32 length = min_c(actualLength, device->max_packet_size);
@@ -435,7 +447,7 @@ device_interupt_callback(void* cookie, uint32 status,
device->status = status; device->status = status;
if (device->notify_lock >= 0) { if (device->notify_lock >= 0) {
if (status == 0/*B_USB_STATUS_SUCCESS*/) { if (status == B_OK) {
memcpy(device->data, data, length); memcpy(device->data, data, length);
device->length = length; device->length = length;
} else { } else {
@@ -477,26 +489,29 @@ device_read(void* cookie, off_t pos, void* buf, size_t* count)
cookie, pos, buf, *count, kBasePublishPath, device->number)); cookie, pos, buf, *count, kBasePublishPath, device->number));
if (ret >= B_OK) { if (ret >= B_OK) {
// what the client "reads" is decided depending on how much bytes are provided // what the client "reads" is decided depending on how much bytes are
// 8 bytes are needed to "read" vendor id, product id and max packet size // provided 8 bytes are needed to "read" vendor id, product id and max
// in case the client wants to read more than 8 bytes, a usb interupt transfer // packet size in case the client wants to read more than 8 bytes, a usb
// is scheduled, and an error report is returned as appropriate // interupt transfer is scheduled, and an error report is returned as
// appropriate
if (*count > 8) { if (*count > 8) {
// queue the interrupt transfer // queue the interrupt transfer
ret = usb->queue_interrupt(device->pipe, device->data, device->max_packet_size, ret = usb->queue_interrupt(device->pipe, device->data,
device_interupt_callback, device); device->max_packet_size, device_interupt_callback, device);
if (ret >= B_OK) { if (ret >= B_OK) {
// we will block here until the interrupt transfer has been done // we will block here until the interrupt transfer has been done
ret = acquire_sem_etc(device->notify_lock, 1, B_RELATIVE_TIMEOUT, 500 * 1000); ret = acquire_sem_etc(device->notify_lock, 1,
B_RELATIVE_TIMEOUT, 500 * 1000);
// handle time out // handle time out
if (ret < B_OK) { if (ret < B_OK) {
// usb->cancel_queued_transfers(device->pipe); // usb->cancel_queued_transfers(device->pipe);
if (ret == B_TIMED_OUT) { if (ret == B_TIMED_OUT) {
// a time_out is ok, since it only means that the device // a time_out is ok, since it only means that the device
// had nothing to report (ie mouse/pen was not moved) within // had nothing to report (ie mouse/pen was not moved)
// the given time interval // within the given time interval
DPRINTF_INFO((ID "device_read(%p) name = \"%s%d\" -> " DPRINTF_INFO((ID "device_read(%p) name = \"%s%d\" -> "
"B_TIMED_OUT\n", cookie, kBasePublishPath, device->number)); "B_TIMED_OUT\n", cookie, kBasePublishPath,
device->number));
*count = 8; *count = 8;
read_header(device, buffer); read_header(device, buffer);
ret = B_OK; ret = B_OK;
@@ -515,21 +530,24 @@ device_read(void* cookie, off_t pos, void* buf, size_t* count)
} else { } else {
// an error happened during the interrupt transfer // an error happened during the interrupt transfer
*count = 0; *count = 0;
dprintf(ID "interrupt transfer - failure: %ld\n", device->status); dprintf(ID "interrupt transfer - failure: %ld\n",
device->status);
ret = B_ERROR; ret = B_ERROR;
} }
} }
} else { } else {
*count = 0; *count = 0;
dprintf(ID "device_read(%p) name = \"%s%d\" -> error queuing interrupt: %ld\n", dprintf(ID "device_read(%p) name = \"%s%d\" -> error queuing "
cookie, kBasePublishPath, device->number, ret); "interrupt: %ld\n", cookie, kBasePublishPath,
device->number, ret);
} }
} else if (*count == 8) { } else if (*count == 8) {
read_header(device, buffer); read_header(device, buffer);
ret = B_OK; ret = B_OK;
} else { } else {
dprintf(ID "device_read(%p) name = \"%s%d\" -> buffer size must be at least 8 bytes!\n", dprintf(ID "device_read(%p) name = \"%s%d\" -> buffer size must be "
cookie, kBasePublishPath, device->number); "at least 8 bytes!\n", cookie, kBasePublishPath,
device->number);
*count = 0; *count = 0;
ret = B_BAD_VALUE; ret = B_BAD_VALUE;
} }
@@ -645,26 +663,27 @@ publish_devices()
} }
acquire_sem(sDeviceListLock); acquire_sem(sDeviceListLock);
sDeviceNames = (char **) malloc(sizeof(char*) * (sDeviceCount + 2)); sDeviceNames = (char**)malloc(sizeof(char*) * (sDeviceCount + 2));
if (sDeviceNames) { if (sDeviceNames) {
for (i = 0, device = sDeviceList; device; device = device->next) { for (i = 0, device = sDeviceList; device; device = device->next) {
if ((sDeviceNames[i] = (char *) malloc(strlen(kBasePublishPath) + 4))) { sDeviceNames[i] = (char*)malloc(strlen(kBasePublishPath) + 4);
if (sDeviceNames[i]) {
sprintf(sDeviceNames[i],"%s%d",kBasePublishPath,device->number); sprintf(sDeviceNames[i],"%s%d",kBasePublishPath,device->number);
DPRINTF_INFO((ID "publishing: \"/dev/%s\"\n",sDeviceNames[i])); DPRINTF_INFO((ID "publishing: \"/dev/%s\"\n",sDeviceNames[i]));
i++; i++;
} }
} }
// publish the currently fake control device // publish the currently fake control device
if ((sDeviceNames[i] = (char *) malloc(strlen(kBasePublishPath) + 8))) { sDeviceNames[i] = (char*)malloc(strlen(kBasePublishPath) + 8);
if (sDeviceNames[i])
sprintf(sDeviceNames[i], "%s%s", kBasePublishPath, "control"); sprintf(sDeviceNames[i], "%s%s", kBasePublishPath, "control");
}
sDeviceNames[i + 1] = NULL; sDeviceNames[i + 1] = NULL;
} }
release_sem(sDeviceListLock); release_sem(sDeviceListLock);
return (const char **) sDeviceNames; return (const char**)sDeviceNames;
} }
static device_hooks sDeviceHooks = { static device_hooks sDeviceHooks = {