[U-Boot] [PATCH v4 06/12] SPEAr : usbd driver support for SPEAr SoCs

Tom Tom.Rix at windriver.com
Thu Jan 14 16:34:31 CET 2010


Vipin Kumar wrote:
> Hello Tom,
> 
>> +static void udc_state_transition(usb_device_state_t initial,
>> +                                usb_device_state_t final)
>> +{
>> +       if (initial < final) {
>> +               switch (initial) {
>> +               case STATE_ATTACHED:
>> +                       usbd_device_event_irq(udc_device,
>> +                                             DEVICE_HUB_CONFIGURED, 0);
>> +                       if (final == STATE_POWERED)
>> +                               break;
>> +               case STATE_POWERED:
>> +                       usbd_device_event_irq(udc_device, DEVICE_RESET, 0);
>> +                       if (final == STATE_DEFAULT)
>> +                               break;
>> +               case STATE_DEFAULT:
>> +                       usbd_device_event_irq(udc_device,
>> +                                             DEVICE_ADDRESS_ASSIGNED, 0);
>> +                       if (final == STATE_ADDRESSED)
>> +                               break;
>> +               case STATE_ADDRESSED:
>> +                       usbd_device_event_irq(udc_device, DEVICE_CONFIGURED, 0);
>> +               case STATE_CONFIGURED:
>> +                       break;
>> +               default:
>> +                       break;
>> +               }
>> +       } else if (initial > final) {
>> +               switch (initial) {
>> +               case STATE_CONFIGURED:
>> +                       usbd_device_event_irq(udc_device,
>> +                                             DEVICE_DE_CONFIGURED, 0);
>> +                       if (final == STATE_ADDRESSED)
>> +                               break;
>> +               case STATE_ADDRESSED:
>> +                       usbd_device_event_irq(udc_device, DEVICE_RESET, 0);
>> +                       if (final == STATE_DEFAULT)
>> +                               break;
>> +               case STATE_DEFAULT:
>> +                       usbd_device_event_irq(udc_device,
>> +                                             DEVICE_POWER_INTERRUPTION, 0);
>> +                       if (final == STATE_POWERED)
>> +                               break;
>> +               case STATE_POWERED:
>> +                       usbd_device_event_irq(udc_device, DEVICE_HUB_RESET, 0);
>> +               case STATE_ATTACHED:
>> +                       break;
>> +               default:
>> +                       break;
>> +               }
>> +       }
>> No panicing if the state transition is the default ?
> 
> default here is not an error case. The device state may be other than what are
> written as switch cases

Ok

Tom

> 
> All other review feedbacks are accepted.
> Patch set v5 would contain the changes
> 
> Regards
> Vipin



More information about the U-Boot mailing list