mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
usb: Strip ALL spaces from passthrough ATA serial number
Leading spaces in particular were resulting in Linux warnings/panics, but to be safe strip out all spaces, including those in the middle. This was noticed on an ipod6g with the stock hard drive; it reported a serial number of ' xxxxxxxx', which is technically legal per ATA specs, but needs to be properly trimmed. Change-Id: I34309fe64b341caefd5b18f6d0cf539cb97d4a38
This commit is contained in:
parent
7795426648
commit
43ec77f84c
1 changed files with 39 additions and 8 deletions
|
@ -373,16 +373,17 @@ static void set_serial_descriptor(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_printable) {
|
if (is_printable) {
|
||||||
/* trim trailing spaces */
|
/* trim ALL spaces */
|
||||||
while (length > 0 && sn[length - 1] == ' ') {
|
int totallen = length;
|
||||||
length--;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
|
if (sn[i] == ' ') {
|
||||||
|
totallen--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*p++ = sn[i];
|
*p++ = sn[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_string_iSerial.bLength = 2 + 2 * (1 + length);
|
usb_string_iSerial.bLength = 2 + 2 * (1 + totallen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
|
@ -597,8 +598,38 @@ static void control_request_handler_drivers(struct usb_ctrlrequest* req, void* r
|
||||||
if(drivers[i].enabled &&
|
if(drivers[i].enabled &&
|
||||||
drivers[i].control_request &&
|
drivers[i].control_request &&
|
||||||
drivers[i].first_interface <= interface &&
|
drivers[i].first_interface <= interface &&
|
||||||
drivers[i].last_interface > interface)
|
drivers[i].last_interface > interface) {
|
||||||
{
|
/* Check for SET_INTERFACE and GET_INTERFACE */
|
||||||
|
if((req->bRequestType & USB_RECIP_MASK) == USB_RECIP_INTERFACE &&
|
||||||
|
(req->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
|
||||||
|
|
||||||
|
if(req->bRequest == USB_REQ_SET_INTERFACE) {
|
||||||
|
logf("usb_core: SET INTERFACE 0x%x 0x%x", req->wValue, req->wIndex);
|
||||||
|
if(drivers[i].set_interface &&
|
||||||
|
drivers[i].set_interface(req->wIndex, req->wValue) >= 0) {
|
||||||
|
sleep(1);
|
||||||
|
usb_drv_control_response(USB_CONTROL_ACK, NULL, 0);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(req->bRequest == USB_REQ_GET_INTERFACE) {
|
||||||
|
int alt = -1;
|
||||||
|
logf("usb_core: GET INTERFACE 0x%x", req->wIndex);
|
||||||
|
|
||||||
|
if(drivers[i].get_interface)
|
||||||
|
alt = drivers[i].get_interface(req->wIndex);
|
||||||
|
|
||||||
|
if(alt >= 0 && alt < 255) {
|
||||||
|
response_data[0] = alt;
|
||||||
|
usb_drv_control_response(USB_CONTROL_ACK, response_data, 1);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fallback */
|
||||||
|
}
|
||||||
|
|
||||||
handled = drivers[i].control_request(req, reqdata, response_data);
|
handled = drivers[i].control_request(req, reqdata, response_data);
|
||||||
if(handled)
|
if(handled)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue