usb_hid: fix trace build, use a macro for device path suffix

no functional change

Change-Id: If8a147727214c8d40853058c033d241c284eec84
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2462
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Jérôme Duval
2020-04-10 11:25:39 +00:00
parent ee87ae146f
commit 1e0d4ffa2e
10 changed files with 49 additions and 37 deletions
@@ -228,7 +228,7 @@ usb_hid_device_removed(void *cookie)
static status_t static status_t
usb_hid_open(const char *name, uint32 flags, void **_cookie) usb_hid_open(const char *name, uint32 flags, void **_cookie)
{ {
TRACE("open(%s, %lu, %p)\n", name, flags, _cookie); TRACE("open(%s, %" B_PRIu32 ", %p)\n", name, flags, _cookie);
device_cookie *cookie = new(std::nothrow) device_cookie(); device_cookie *cookie = new(std::nothrow) device_cookie();
if (cookie == NULL) if (cookie == NULL)
@@ -262,8 +262,8 @@ usb_hid_read(void *_cookie, off_t position, void *buffer, size_t *numBytes)
{ {
device_cookie *cookie = (device_cookie *)_cookie; device_cookie *cookie = (device_cookie *)_cookie;
TRACE("read(%p, %llu, %p, %p (%lu)\n", cookie, position, buffer, numBytes, TRACE("read(%p, %" B_PRIu64 ", %p, %p (%lu)\n", cookie, position, buffer,
numBytes != NULL ? *numBytes : 0); numBytes, numBytes != NULL ? *numBytes : 0);
return cookie->handler->Read(&cookie->cookie, position, buffer, numBytes); return cookie->handler->Read(&cookie->cookie, position, buffer, numBytes);
} }
@@ -274,7 +274,7 @@ usb_hid_write(void *_cookie, off_t position, const void *buffer,
{ {
device_cookie *cookie = (device_cookie *)_cookie; device_cookie *cookie = (device_cookie *)_cookie;
TRACE("write(%p, %llu, %p, %p (%lu)\n", cookie, position, buffer, numBytes, TRACE("write(%p, %" B_PRIu64 ", %p, %p (%lu)\n", cookie, position, buffer, numBytes,
numBytes != NULL ? *numBytes : 0); numBytes != NULL ? *numBytes : 0);
return cookie->handler->Write(&cookie->cookie, position, buffer, numBytes); return cookie->handler->Write(&cookie->cookie, position, buffer, numBytes);
} }
@@ -285,7 +285,8 @@ usb_hid_control(void *_cookie, uint32 op, void *buffer, size_t length)
{ {
device_cookie *cookie = (device_cookie *)_cookie; device_cookie *cookie = (device_cookie *)_cookie;
TRACE("control(%p, %lu, %p, %lu)\n", cookie, op, buffer, length); TRACE("control(%p, %" B_PRIu32 ", %p, %" B_PRIuSIZE ")\n", cookie, op,
buffer, length);
return cookie->handler->Control(&cookie->cookie, op, buffer, length); return cookie->handler->Control(&cookie->cookie, op, buffer, length);
} }
@@ -15,6 +15,7 @@
#include "DeviceList.h" #include "DeviceList.h"
#define DRIVER_NAME "usb_hid" #define DRIVER_NAME "usb_hid"
#define DEVICE_PATH_SUFFIX "usb"
#define USB_INTERFACE_CLASS_HID 3 #define USB_INTERFACE_CLASS_HID 3
#define USB_INTERFACE_SUBCLASS_HID_BOOT 1 #define USB_INTERFACE_SUBCLASS_HID_BOOT 1
@@ -95,8 +95,8 @@ HIDDevice::HIDDevice(usb_device device, const usb_configuration_info *config,
B_USB_HID_DESCRIPTOR_HID << 8, interfaceIndex, descriptorLength, B_USB_HID_DESCRIPTOR_HID << 8, interfaceIndex, descriptorLength,
hidDescriptor, &descriptorLength); hidDescriptor, &descriptorLength);
TRACE("get hid descriptor: result: 0x%08lx; length: %lu\n", result, TRACE("get hid descriptor: result: 0x%08" B_PRIx32 "; length: %lu"
descriptorLength); "\n", result, descriptorLength);
if (result == B_OK) { if (result == B_OK) {
descriptorLength descriptorLength
= hidDescriptor->descriptor_info[0].descriptor_length; = hidDescriptor->descriptor_info[0].descriptor_length;
@@ -123,8 +123,8 @@ HIDDevice::HIDDevice(usb_device device, const usb_configuration_info *config,
B_USB_HID_DESCRIPTOR_REPORT << 8, interfaceIndex, descriptorLength, B_USB_HID_DESCRIPTOR_REPORT << 8, interfaceIndex, descriptorLength,
reportDescriptor, &descriptorLength); reportDescriptor, &descriptorLength);
TRACE("get report descriptor: result: 0x%08lx; length: %lu\n", result, TRACE("get report descriptor: result: 0x%08" B_PRIx32 "; length: %"
descriptorLength); B_PRIuSIZE "\n", result, descriptorLength);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("failed tot get report descriptor\n"); TRACE_ALWAYS("failed tot get report descriptor\n");
free(reportDescriptor); free(reportDescriptor);
@@ -102,7 +102,7 @@ HIDParser::ParseReportDescriptor(const uint8 *reportDescriptor,
} }
} }
TRACE("got item: type: %s; size: %lu; tag: %u; data: %lu\n", TRACE("got item: type: %s; size: %lu; tag: %u; data: %" B_PRIu32 "\n",
item->type == ITEM_TYPE_MAIN ? "main" item->type == ITEM_TYPE_MAIN ? "main"
: item->type == ITEM_TYPE_GLOBAL ? "global" : item->type == ITEM_TYPE_GLOBAL ? "global"
: item->type == ITEM_TYPE_LOCAL ? "local" : "long", : item->type == ITEM_TYPE_LOCAL ? "local" : "long",
@@ -73,27 +73,33 @@ HIDReport::AddMainItem(global_item_state &globalState,
TRACE("\tglobal state:\n"); TRACE("\tglobal state:\n");
TRACE("\t\tusage_page: 0x%x\n", globalState.usage_page); TRACE("\t\tusage_page: 0x%x\n", globalState.usage_page);
TRACE("\t\tlogical_minimum: %ld\n", logicalMinimum); TRACE("\t\tlogical_minimum: %" B_PRId32 "\n", logicalMinimum);
TRACE("\t\tlogical_maximum: %ld\n", logicalMaximum); TRACE("\t\tlogical_maximum: %" B_PRId32 "\n", logicalMaximum);
TRACE("\t\tphysical_minimum: %ld\n", physicalMinimum); TRACE("\t\tphysical_minimum: %" B_PRId32 "\n", physicalMinimum);
TRACE("\t\tphysical_maximum: %ld\n", physicalMaximum); TRACE("\t\tphysical_maximum: %" B_PRId32 "\n", physicalMaximum);
TRACE("\t\tunit_exponent: %d\n", globalState.unit_exponent); TRACE("\t\tunit_exponent: %d\n", globalState.unit_exponent);
TRACE("\t\tunit: %d\n", globalState.unit); TRACE("\t\tunit: %d\n", globalState.unit);
TRACE("\t\treport_size: %lu\n", globalState.report_size); TRACE("\t\treport_size: %" B_PRIu32 "\n", globalState.report_size);
TRACE("\t\treport_count: %lu\n", globalState.report_count); TRACE("\t\treport_count: %" B_PRIu32 "\n", globalState.report_count);
TRACE("\t\treport_id: %u\n", globalState.report_id); TRACE("\t\treport_id: %u\n", globalState.report_id);
TRACE("\tlocal state:\n"); TRACE("\tlocal state:\n");
TRACE("\t\tusage stack (%lu)\n", localState.usage_stack_used); TRACE("\t\tusage stack (%" B_PRIu32 ")\n", localState.usage_stack_used);
for (uint32 i = 0; i < localState.usage_stack_used; i++) { for (uint32 i = 0; i < localState.usage_stack_used; i++) {
TRACE("\t\t\t0x%08lx\n", localState.usage_stack[i].u.extended); TRACE("\t\t\t0x%08" B_PRIx32 "\n",
localState.usage_stack[i].u.extended);
} }
TRACE("\t\tusage_minimum: 0x%08lx\n", localState.usage_minimum.u.extended); TRACE("\t\tusage_minimum: 0x%08" B_PRIx32 "\n",
TRACE("\t\tusage_maximum: 0x%08lx\n", localState.usage_maximum.u.extended); localState.usage_minimum.u.extended);
TRACE("\t\tdesignator_index: %lu\n", localState.designator_index); TRACE("\t\tusage_maximum: 0x%08" B_PRIu32 "\n",
TRACE("\t\tdesignator_minimum: %lu\n", localState.designator_minimum); localState.usage_maximum.u.extended);
TRACE("\t\tdesignator_maximum: %lu\n", localState.designator_maximum); TRACE("\t\tdesignator_index: %" B_PRIu32 "\n",
localState.designator_index);
TRACE("\t\tdesignator_minimum: %" B_PRIu32 "\n",
localState.designator_minimum);
TRACE("\t\tdesignator_maximum: %" B_PRIu32 "\n",
localState.designator_maximum);
TRACE("\t\tstring_index: %u\n", localState.string_index); TRACE("\t\tstring_index: %u\n", localState.string_index);
TRACE("\t\tstring_minimum: %u\n", localState.string_minimum); TRACE("\t\tstring_minimum: %u\n", localState.string_minimum);
TRACE("\t\tstring_maximum: %u\n", localState.string_maximum); TRACE("\t\tstring_maximum: %u\n", localState.string_maximum);
@@ -25,7 +25,7 @@
JoystickProtocolHandler::JoystickProtocolHandler(HIDReport &report) JoystickProtocolHandler::JoystickProtocolHandler(HIDReport &report)
: :
ProtocolHandler(report.Device(), "joystick/usb/", 0), ProtocolHandler(report.Device(), "joystick/" DEVICE_PATH_SUFFIX "/", 0),
fReport(report), fReport(report),
fAxisCount(0), fAxisCount(0),
fAxis(NULL), fAxis(NULL),
@@ -110,7 +110,8 @@ JoystickProtocolHandler::JoystickProtocolHandler(HIDReport &report)
fCurrentValues.initialize(fAxisCount, fHatCount, fMaxButton); fCurrentValues.initialize(fAxisCount, fHatCount, fMaxButton);
TRACE("joystick device with %lu buttons, %lu axes and %lu hats\n", TRACE("joystick device with %" B_PRIu32 " buttons, %" B_PRIu32
" axes and %" B_PRIu32 " hats\n",
fButtonCount, fAxisCount, fHatCount); fButtonCount, fAxisCount, fHatCount);
TRACE("report id: %u\n", report.ID()); TRACE("report id: %u\n", report.ID());
} }
@@ -53,7 +53,8 @@ debug_get_keyboard_config(int argc, char **argv)
KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport, KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
HIDReport *outputReport) HIDReport *outputReport)
: :
ProtocolHandler(inputReport.Device(), "input/keyboard/usb/", 512), ProtocolHandler(inputReport.Device(), "input/keyboard/" DEVICE_PATH_SUFFIX
"/", 512),
fInputReport(inputReport), fInputReport(inputReport),
fOutputReport(outputReport), fOutputReport(outputReport),
fRepeatDelay(300000), fRepeatDelay(300000),
@@ -80,7 +81,8 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
if (item->UsagePage() == B_HID_USAGE_PAGE_KEYBOARD if (item->UsagePage() == B_HID_USAGE_PAGE_KEYBOARD
|| item->UsagePage() == B_HID_USAGE_PAGE_CONSUMER || item->UsagePage() == B_HID_USAGE_PAGE_CONSUMER
|| item->UsagePage() == B_HID_USAGE_PAGE_BUTTON) { || item->UsagePage() == B_HID_USAGE_PAGE_BUTTON) {
TRACE("keyboard item with usage %lx\n", item->UsageMinimum()); TRACE("keyboard item with usage %" B_PRIx32 "\n",
item->UsageMinimum());
if (item->Array()) { if (item->Array()) {
// normal or "consumer"/button keys handled as array items // normal or "consumer"/button keys handled as array items
@@ -114,8 +116,8 @@ KeyboardProtocolHandler::KeyboardProtocolHandler(HIDReport &inputReport,
sDebugKeyboardFound = true; sDebugKeyboardFound = true;
} }
TRACE("keyboard device with %lu keys and %lu modifiers\n", fKeyCount, TRACE("keyboard device with %" B_PRIu32 " keys and %" B_PRIu32
fModifierCount); " modifiers\n", fKeyCount, fModifierCount);
TRACE("input report: %u; output report: %u\n", inputReport.ID(), TRACE("input report: %u; output report: %u\n", inputReport.ID(),
outputReport != NULL ? outputReport->ID() : 255); outputReport != NULL ? outputReport->ID() : 255);
@@ -219,7 +221,7 @@ KeyboardProtocolHandler::AddHandlers(HIDDevice &device,
collection.BuildReportList(HID_REPORT_TYPE_INPUT, inputReports, collection.BuildReportList(HID_REPORT_TYPE_INPUT, inputReports,
inputReportCount); inputReportCount);
TRACE("input report count: %lu\n", inputReportCount); TRACE("input report count: %" B_PRIu32 "\n", inputReportCount);
for (uint32 i = 0; i < inputReportCount; i++) { for (uint32 i = 0; i < inputReportCount; i++) {
HIDReport *inputReport = inputReports[i]; HIDReport *inputReport = inputReports[i];
@@ -26,7 +26,7 @@
MouseProtocolHandler::MouseProtocolHandler(HIDReport &report, MouseProtocolHandler::MouseProtocolHandler(HIDReport &report,
HIDReportItem &xAxis, HIDReportItem &yAxis) HIDReportItem &xAxis, HIDReportItem &yAxis)
: :
ProtocolHandler(report.Device(), "input/mouse/usb/", 0), ProtocolHandler(report.Device(), "input/mouse/" DEVICE_PATH_SUFFIX "/", 0),
fReport(report), fReport(report),
fXAxis(xAxis), fXAxis(xAxis),
@@ -58,8 +58,8 @@ MouseProtocolHandler::MouseProtocolHandler(HIDReport &report,
fHorizontalPan = report.FindItem(B_HID_USAGE_PAGE_CONSUMER, fHorizontalPan = report.FindItem(B_HID_USAGE_PAGE_CONSUMER,
B_HID_UID_CON_AC_PAN); B_HID_UID_CON_AC_PAN);
TRACE("mouse device with %lu buttons %sand %swheel\n", buttonCount, TRACE("mouse device with %" B_PRIu32 " buttons %sand %swheel\n",
fHorizontalPan == NULL ? "" : ", horizontal pan ", buttonCount, fHorizontalPan == NULL ? "" : ", horizontal pan ",
fWheel == NULL ? "no " : ""); fWheel == NULL ? "no " : "");
TRACE("report id: %u\n", report.ID()); TRACE("report id: %u\n", report.ID());
} }
@@ -74,7 +74,7 @@ ProtocolHandler::AddHandlers(HIDDevice &device, ProtocolHandler *&handlerList,
uint32 appCollectionCount = rootCollection->CountChildrenFlat( uint32 appCollectionCount = rootCollection->CountChildrenFlat(
COLLECTION_APPLICATION); COLLECTION_APPLICATION);
TRACE("root collection holds %lu application collection%s\n", TRACE("root collection holds %" B_PRIu32 " application collection%s\n",
appCollectionCount, appCollectionCount != 1 ? "s" : ""); appCollectionCount, appCollectionCount != 1 ? "s" : "");
for (uint32 i = 0; i < appCollectionCount; i++) { for (uint32 i = 0; i < appCollectionCount; i++) {
@@ -110,7 +110,7 @@ ProtocolHandler::AddHandlers(HIDDevice &device, ProtocolHandler *&handlerList,
return; return;
} }
TRACE("added %ld handlers for hid device\n", handlerCount); TRACE("added %" B_PRId32 " handlers for hid device\n", handlerCount);
} }
@@ -28,7 +28,8 @@
TabletProtocolHandler::TabletProtocolHandler(HIDReport &report, TabletProtocolHandler::TabletProtocolHandler(HIDReport &report,
HIDReportItem &xAxis, HIDReportItem &yAxis) HIDReportItem &xAxis, HIDReportItem &yAxis)
: :
ProtocolHandler(report.Device(), "input/tablet/usb/", 0), ProtocolHandler(report.Device(), "input/tablet/" DEVICE_PATH_SUFFIX "/",
0),
fReport(report), fReport(report),
fXAxis(xAxis), fXAxis(xAxis),
@@ -86,7 +87,7 @@ TabletProtocolHandler::TabletProtocolHandler(HIDReport &report,
fYTilt = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER, fYTilt = report.FindItem(B_HID_USAGE_PAGE_DIGITIZER,
B_HID_UID_DIG_Y_TILT); B_HID_UID_DIG_Y_TILT);
TRACE("tablet device with %lu buttons, %stip, %seraser, " TRACE("tablet device with %" B_PRIu32 " buttons, %stip, %seraser, "
"%spressure, and %stilt\n", "%spressure, and %stilt\n",
buttonCount, buttonCount,
fTip == NULL ? "no " : "", fTip == NULL ? "no " : "",