1
0
mirror of https://github.com/gdsports/USBHost_t36 synced 2024-11-24 01:52:23 -05:00

Use linked list for device's drivers, not fixed size array

This commit is contained in:
PaulStoffregen 2017-02-12 00:22:50 -08:00
parent 326ecbe228
commit 26fa6f2e34
2 changed files with 5 additions and 5 deletions

View File

@ -63,7 +63,8 @@ struct Device_struct {
Pipe_t *control_pipe; Pipe_t *control_pipe;
Device_t *next; Device_t *next;
setup_t setup; setup_t setup;
USBHostDriver *driver[6]; //USBHostDriver *driver[6];
USBHostDriver *drivers;
uint8_t speed; // 0=12, 1=1.5, 2=480 Mbit/sec uint8_t speed; // 0=12, 1=1.5, 2=480 Mbit/sec
uint8_t address; uint8_t address;
uint8_t hub_address; uint8_t hub_address;

View File

@ -219,9 +219,8 @@ void USBHost::enumeration(const Transfer_t *transfer)
return; return;
case 15: // control transfers for other stuff? case 15: // control transfers for other stuff?
// TODO: handle other standard control: set/clear feature, etc // TODO: handle other standard control: set/clear feature, etc
for (unsigned int i=0; i < 6; i++) { for (USBHostDriver *d = dev->drivers; d != NULL; d = d->next) {
if (dev->driver[i] == NULL) break; // no more drivers if (d->control_callback(transfer)) {
if (dev->driver[i]->control_callback(transfer)) {
// this driver processed the control transfer reply // this driver processed the control transfer reply
return; return;
} }
@ -245,7 +244,7 @@ static void claim_drivers(Device_t *dev)
available_drivers = driver->next; available_drivers = driver->next;
} }
driver->next = NULL; driver->next = NULL;
dev->driver[0] = driver; dev->drivers = driver;
return; return;
} }
prev = driver; prev = driver;