Changeset 229629d in mainline


Ignore:
Timestamp:
2011-10-13T21:24:40Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
344a0ac
Parents:
359d96f
Message:

usbmid: Use new usb_mid_t to store all the interfaces and functions.

Location:
uspace/drv/bus/usb/usbmid
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmid/explore.c

    r359d96f r229629d  
    163163        }
    164164
     165        usb_mid_t *usb_mid = malloc(sizeof(usb_mid_t));
     166        if (!usb_mid) {
     167                usb_log_error("Failed to create USB MID structure.\n");
     168                return false;
     169        }
     170
    165171        /* Create control function */
    166         ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
    167         if (ctl_fun == NULL) {
     172        usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
     173        if (usb_mid->ctl_fun == NULL) {
    168174                usb_log_error("Failed to create control function.\n");
    169                 return false;
    170         }
    171 
    172         ctl_fun->ops = &mid_device_ops;
    173 
    174         rc = ddf_fun_bind(ctl_fun);
     175                free(usb_mid);
     176                return false;
     177        }
     178
     179        usb_mid->ctl_fun->ops = &mid_device_ops;
     180
     181        rc = ddf_fun_bind(usb_mid->ctl_fun);
    175182        if (rc != EOK) {
    176                 ddf_fun_destroy(ctl_fun);
    177183                usb_log_error("Failed to bind control function: %s.\n",
    178184                    str_error(rc));
    179                 return false;
    180         }
     185                ddf_fun_destroy(usb_mid->ctl_fun);
     186                free(usb_mid);
     187                return false;
     188        }
     189
    181190
    182191        /* Create interface children. */
    183         list_t interface_list;
    184         list_initialize(&interface_list);
     192        list_initialize(&usb_mid->interface_list);
    185193        create_interfaces(config_descriptor_raw, config_descriptor_size,
    186             &interface_list);
    187 
    188         list_foreach(interface_list, link) {
     194            &usb_mid->interface_list);
     195
     196        list_foreach(usb_mid->interface_list, link) {
    189197                usbmid_interface_t *iface = list_get_instance(link,
    190198                    usbmid_interface_t, link);
     
    201209                }
    202210        }
     211        dev->driver_data = usb_mid;
    203212
    204213        return true;
  • uspace/drv/bus/usb/usbmid/usbmid.h

    r359d96f r229629d  
    5858} usbmid_interface_t;
    5959
     60/** Container to hold all the function pointers */
     61typedef struct usb_mid {
     62        ddf_fun_t *ctl_fun;
     63        list_t interface_list;
     64} usb_mid_t;
     65
    6066bool usbmid_explore_device(usb_device_t *);
    6167int usbmid_spawn_interface_child(usb_device_t *, usbmid_interface_t *,
Note: See TracChangeset for help on using the changeset viewer.