Changes in uspace/drv/nic/ar9271/ath_usb.c [b3c39690:cde999a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ar9271/ath_usb.c
rb3c39690 rcde999a 35 35 #include <usb/dev/pipes.h> 36 36 #include <usb/debug.h> 37 #include < malloc.h>37 #include <stdlib.h> 38 38 #include <errno.h> 39 39 #include "ath_usb.h" … … 56 56 * @param usb_device Connected USB device. 57 57 * 58 * @return EOK if succeed, negativeerror code otherwise.58 * @return EOK if succeed, error code otherwise. 59 59 * 60 60 */ 61 int ath_usb_init(ath_t *ath, usb_device_t *usb_device , const usb_endpoint_description_t **endpoints)61 int ath_usb_init(ath_t *ath, usb_device_t *usb_device) 62 62 { 63 63 ath_usb_t *ath_usb = malloc(sizeof(ath_usb_t)); … … 70 70 ath_usb->usb_device = usb_device; 71 71 72 int rc; 73 74 #define _MAP_EP(target, ep_no) do {\ 75 usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep_desc(usb_device, endpoints[ep_no]);\ 76 if (!epm || !epm->present) {\ 77 usb_log_error("Failed to map endpoint: " #ep_no ".");\ 78 rc = ENOENT;\ 79 goto err_ath_usb;\ 80 }\ 81 target = &epm->pipe;\ 82 } while (0); 83 84 _MAP_EP(ath_usb->output_data_pipe, 0); 85 _MAP_EP(ath_usb->input_data_pipe, 1); 86 _MAP_EP(ath_usb->input_ctrl_pipe, 2); 87 _MAP_EP(ath_usb->output_ctrl_pipe, 3); 88 89 #undef _MAP_EP 72 /* TODO: Assign by iterating over pipes. */ 73 ath_usb->output_data_pipe_number = 0; 74 ath_usb->input_data_pipe_number = 1; 75 ath_usb->input_ctrl_pipe_number = 2; 76 ath_usb->output_ctrl_pipe_number = 3; 90 77 91 78 ath->ctrl_response_length = 64; … … 96 83 97 84 return EOK; 98 err_ath_usb:99 free(ath_usb);100 return rc;101 85 } 102 86 … … 107 91 * @param buffer_size Buffer size. 108 92 * 109 * @return EOK if succeed, negativeerror code otherwise.93 * @return EOK if succeed, error code otherwise. 110 94 * 111 95 */ … … 114 98 { 115 99 ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data; 116 return usb_pipe_write(ath_usb->output_ctrl_pipe, buffer, buffer_size); 100 usb_pipe_t *pipe = &usb_device_get_mapped_ep( 101 ath_usb->usb_device, ath_usb->output_ctrl_pipe_number)->pipe; 102 103 return usb_pipe_write(pipe, buffer, buffer_size); 117 104 } 118 105 … … 124 111 * @param transferred_size Real size of read data. 125 112 * 126 * @return EOK if succeed, negativeerror code otherwise.113 * @return EOK if succeed, error code otherwise. 127 114 * 128 115 */ … … 131 118 { 132 119 ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data; 133 return usb_pipe_read(ath_usb->input_ctrl_pipe, buffer, buffer_size, transferred_size); 120 usb_pipe_t *pipe = &usb_device_get_mapped_ep( 121 ath_usb->usb_device, ath_usb->input_ctrl_pipe_number)->pipe; 122 123 return usb_pipe_read(pipe, buffer, buffer_size, transferred_size); 134 124 } 135 125 … … 140 130 * @param buffer_size Buffer size. 141 131 * 142 * @return EOK if succeed, negativeerror code otherwise.132 * @return EOK if succeed, error code otherwise. 143 133 * 144 134 */ … … 158 148 159 149 ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data; 160 int ret_val = usb_pipe_write(ath_usb->output_data_pipe, complete_buffer, 150 usb_pipe_t *pipe = &usb_device_get_mapped_ep( 151 ath_usb->usb_device, ath_usb->output_data_pipe_number)->pipe; 152 153 int ret_val = usb_pipe_write(pipe, complete_buffer, 161 154 complete_buffer_size); 162 155 … … 173 166 * @param transferred_size Real size of read data. 174 167 * 175 * @return EOK if succeed, negativeerror code otherwise.168 * @return EOK if succeed, error code otherwise. 176 169 * 177 170 */ … … 180 173 { 181 174 ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data; 182 return usb_pipe_read(ath_usb->input_data_pipe, buffer, buffer_size, transferred_size); 175 usb_pipe_t *pipe = &usb_device_get_mapped_ep( 176 ath_usb->usb_device, ath_usb->input_data_pipe_number)->pipe; 177 178 return usb_pipe_read(pipe, buffer, buffer_size, transferred_size); 183 179 }
Note:
See TracChangeset
for help on using the changeset viewer.