Fixed style issues.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33557 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,7 +101,8 @@ usb_printer_transfer_data(printer_device *device, bool directionIn, void *data,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
bigtime_t timeout = directionIn ? READ_TIMEOUT : WRITE_TIMEOUT;
|
bigtime_t timeout = directionIn ? READ_TIMEOUT : WRITE_TIMEOUT;
|
||||||
result = acquire_sem_etc(device->notify, 1, B_RELATIVE_TIMEOUT, timeout);
|
result = acquire_sem_etc(device->notify, 1, B_RELATIVE_TIMEOUT,
|
||||||
|
timeout);
|
||||||
if (result == B_TIMED_OUT) {
|
if (result == B_TIMED_OUT) {
|
||||||
// Cancel the transfer and collect the sem that should now be
|
// Cancel the transfer and collect the sem that should now be
|
||||||
// released through the callback on cancel. Handling of device
|
// released through the callback on cancel. Handling of device
|
||||||
@@ -150,7 +151,8 @@ usb_printer_device_added(usb_device newDevice, void **cookie)
|
|||||||
device->alternate_setting = 0;
|
device->alternate_setting = 0;
|
||||||
|
|
||||||
// scan through the interfaces to find our bulk-only data interface
|
// scan through the interfaces to find our bulk-only data interface
|
||||||
const usb_configuration_info *configuration = gUSBModule->get_configuration(newDevice);
|
const usb_configuration_info *configuration =
|
||||||
|
gUSBModule->get_configuration(newDevice);
|
||||||
if (configuration == NULL) {
|
if (configuration == NULL) {
|
||||||
free(device);
|
free(device);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -162,10 +164,12 @@ usb_printer_device_added(usb_device newDevice, void **cookie)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (interface->descr->interface_class == PRINTER_INTERFACE_CLASS
|
if (interface->descr->interface_class == PRINTER_INTERFACE_CLASS
|
||||||
&& interface->descr->interface_subclass == PRINTER_INTERFACE_SUBCLASS
|
&& interface->descr->interface_subclass ==
|
||||||
|
PRINTER_INTERFACE_SUBCLASS
|
||||||
&& (interface->descr->interface_protocol == PIT_UNIDIRECTIONAL
|
&& (interface->descr->interface_protocol == PIT_UNIDIRECTIONAL
|
||||||
|| interface->descr->interface_protocol == PIT_BIDIRECTIONAL
|
|| interface->descr->interface_protocol == PIT_BIDIRECTIONAL
|
||||||
|| interface->descr->interface_protocol == PIT_1284_4_COMPATIBLE)) {
|
|| interface->descr->interface_protocol ==
|
||||||
|
PIT_1284_4_COMPATIBLE)) {
|
||||||
|
|
||||||
bool hasIn = false;
|
bool hasIn = false;
|
||||||
bool hasOut = false;
|
bool hasOut = false;
|
||||||
@@ -232,9 +236,9 @@ usb_printer_device_added(usb_device newDevice, void **cookie)
|
|||||||
}
|
}
|
||||||
if (freeDeviceMask != (uint32)-1) {
|
if (freeDeviceMask != (uint32)-1) {
|
||||||
// reuse device number of first 32 devices
|
// reuse device number of first 32 devices
|
||||||
for (int32 device_number = 0; device_number < 32; device_number ++) {
|
for (int32 deviceNumber = 0; deviceNumber < 32; deviceNumber++) {
|
||||||
if (freeDeviceMask & (1 << device_number) == 0) {
|
if (freeDeviceMask & (1 << deviceNumber) == 0) {
|
||||||
device->device_number = device_number;
|
device->device_number = deviceNumber;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,26 +357,29 @@ usb_printer_get_device_id(printer_device *device, void *buffer)
|
|||||||
uint16 value = 0;
|
uint16 value = 0;
|
||||||
uint16 index = (device->interface << 8) | device->alternate_setting;
|
uint16 index = (device->interface << 8) | device->alternate_setting;
|
||||||
char device_id[USB_PRINTER_DEVICE_ID_LENGTH + 2];
|
char device_id[USB_PRINTER_DEVICE_ID_LENGTH + 2];
|
||||||
size_t device_id_size = 0;
|
size_t deviceIdSize = 0;
|
||||||
status_t st = gUSBModule->send_request(device->device, PRINTER_REQUEST,
|
status_t status = gUSBModule->send_request(device->device, PRINTER_REQUEST,
|
||||||
REQUEST_GET_DEVICE_ID, value, index,
|
REQUEST_GET_DEVICE_ID, value, index,
|
||||||
sizeof(device_id), device_id, &device_id_size);
|
sizeof(device_id), device_id, &deviceIdSize);
|
||||||
|
|
||||||
if (st == B_OK && device_id_size > 2) {
|
if (status == B_OK && deviceIdSize > 2) {
|
||||||
// terminate string
|
// terminate string
|
||||||
device_id[device_id_size - 1] = '\0';
|
device_id[deviceIdSize - 1] = '\0';
|
||||||
// skip first two bytes containing string length again
|
// skip first two bytes containing string length again
|
||||||
st = user_strlcpy((char *)buffer, &device_id[2], USB_PRINTER_DEVICE_ID_LENGTH);
|
status = user_strlcpy((char *)buffer, &device_id[2],
|
||||||
|
USB_PRINTER_DEVICE_ID_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
dprintf("%s: Failed to get device ID for interface %d and alternate setting %d: %s\n",
|
dprintf("%s: Failed to get device ID for interface %d "
|
||||||
DRIVER_NAME,
|
"and alternate setting %d: %s\n",
|
||||||
(int)device->interface,
|
DRIVER_NAME,
|
||||||
(int)device->alternate_setting,
|
(int)device->interface,
|
||||||
strerror(st));
|
(int)device->alternate_setting,
|
||||||
st = user_strlcpy((char *)buffer,
|
strerror(status));
|
||||||
"MFG:Unknown;CMD:Unknown;MDL:Unknown;", USB_PRINTER_DEVICE_ID_LENGTH);
|
status = user_strlcpy((char *)buffer,
|
||||||
|
"MFG:Unknown;CMD:Unknown;MDL:Unknown;",
|
||||||
|
USB_PRINTER_DEVICE_ID_LENGTH);
|
||||||
}
|
}
|
||||||
return st;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -404,7 +411,8 @@ usb_printer_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
usb_printer_transfer(printer_device* device, bool directionIn, void* buffer, size_t* length)
|
usb_printer_transfer(printer_device* device, bool directionIn, void* buffer,
|
||||||
|
size_t* length)
|
||||||
{
|
{
|
||||||
status_t result = B_ERROR;
|
status_t result = B_ERROR;
|
||||||
if (buffer == NULL || length == NULL || *length <= 0) {
|
if (buffer == NULL || length == NULL || *length <= 0) {
|
||||||
@@ -479,7 +487,8 @@ usb_printer_write(void *cookie, off_t position, const void *buffer,
|
|||||||
return B_DEV_NOT_READY;
|
return B_DEV_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t result = usb_printer_transfer(device, false, (void*)buffer, length);
|
status_t result = usb_printer_transfer(device, false, (void*)buffer,
|
||||||
|
length);
|
||||||
|
|
||||||
mutex_unlock(&device->lock);
|
mutex_unlock(&device->lock);
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
@@ -498,7 +507,7 @@ usb_printer_write(void *cookie, off_t position, const void *buffer,
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
init_hardware()
|
init_hardware()
|
||||||
{
|
{
|
||||||
TRACE("init_hardware()\n");
|
TRACE("init_hardware()\n");
|
||||||
|
|||||||
@@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
// class specific requests
|
// class specific requests
|
||||||
// bmRequestType
|
// bmRequestType
|
||||||
#define PRINTER_REQUEST (USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_CLASS)
|
#define PRINTER_REQUEST (USB_REQTYPE_INTERFACE_IN \
|
||||||
|
| USB_REQTYPE_CLASS)
|
||||||
// bRequest
|
// bRequest
|
||||||
#define REQUEST_GET_DEVICE_ID 0x00
|
#define REQUEST_GET_DEVICE_ID 0x00
|
||||||
#define REQUEST_GET_PORT_STATUS 0x01
|
#define REQUEST_GET_PORT_STATUS 0x01
|
||||||
|
|||||||
Reference in New Issue
Block a user