Changeset edb5f837 in mainline
- Timestamp:
- 2011-03-06T17:38:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3e37964
- Parents:
- 40a5d40
- Location:
- uspace/drv/uhci-hcd/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/utils/device_keeper.c
r40a5d40 redb5f837 49 49 instance->devices[i].occupied = false; 50 50 instance->devices[i].handle = 0; 51 instance->devices[i].toggle_status = 0; 51 52 } 52 53 } … … 75 76 } 76 77 /*----------------------------------------------------------------------------*/ 78 int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target) 79 { 80 assert(instance); 81 int ret; 82 fibril_mutex_lock(&instance->guard); 83 if (target.endpoint > 15 || target.endpoint < 0 84 || target.address >= USB_ADDRESS_COUNT || target.address < 0 85 || !instance->devices[target.address].occupied) { 86 ret = EINVAL; 87 } else { 88 ret = (instance->devices[target.address].toggle_status >> target.endpoint) & 1; 89 } 90 fibril_mutex_unlock(&instance->guard); 91 return ret; 92 } 93 /*----------------------------------------------------------------------------*/ 94 int device_keeper_set_toggle( 95 device_keeper_t *instance, usb_target_t target, bool toggle) 96 { 97 assert(instance); 98 int ret; 99 fibril_mutex_lock(&instance->guard); 100 if (target.endpoint > 15 || target.endpoint < 0 101 || target.address >= USB_ADDRESS_COUNT || target.address < 0 102 || !instance->devices[target.address].occupied) { 103 ret = EINVAL; 104 } else { 105 if (toggle) { 106 instance->devices[target.address].toggle_status |= (1 << target.endpoint); 107 } else { 108 instance->devices[target.address].toggle_status &= ~(1 << target.endpoint); 109 } 110 ret = EOK; 111 } 112 fibril_mutex_unlock(&instance->guard); 113 return ret; 114 } 115 /*----------------------------------------------------------------------------*/ 77 116 usb_address_t device_keeper_request( 78 117 device_keeper_t *instance, usb_speed_t speed) … … 96 135 instance->devices[new_address].occupied = true; 97 136 instance->devices[new_address].speed = speed; 137 instance->devices[new_address].toggle_status = 0; 98 138 instance->last_address = new_address; 99 139 fibril_mutex_unlock(&instance->guard); -
uspace/drv/uhci-hcd/utils/device_keeper.h
r40a5d40 redb5f837 44 44 usb_speed_t speed; 45 45 bool occupied; 46 uint16_t toggle_status; 46 47 devman_handle_t handle; 47 48 }; … … 55 56 56 57 void device_keeper_init(device_keeper_t *instance); 58 57 59 void device_keeper_reserve_default( 58 60 device_keeper_t *instance, usb_speed_t speed); 61 59 62 void device_keeper_release_default(device_keeper_t *instance); 63 64 int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target); 65 66 int device_keeper_set_toggle(device_keeper_t *instance, usb_target_t target, bool toggle); 60 67 61 68 usb_address_t device_keeper_request( 62 69 device_keeper_t *instance, usb_speed_t speed); 70 63 71 void device_keeper_bind( 64 72 device_keeper_t *instance, usb_address_t address, devman_handle_t handle); 73 65 74 void device_keeper_release(device_keeper_t *instance, usb_address_t address); 75 66 76 usb_address_t device_keeper_find( 67 77 device_keeper_t *instance, devman_handle_t handle);
Note:
See TracChangeset
for help on using the changeset viewer.