Changeset 6e6dc7d in mainline for uspace/lib/usb/src/recognise.c
- Timestamp:
- 2011-02-20T17:31:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 51f0e410
- Parents:
- c723b772
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/recognise.c
rc723b772 r6e6dc7d 112 112 } 113 113 114 #define ADD_MATCHID_OR_RETURN(match_ids, score, format, ...) \ 115 do { \ 116 int __rc = usb_add_match_id((match_ids), (score), \ 117 format, ##__VA_ARGS__); \ 118 if (__rc != EOK) { \ 119 return __rc; \ 120 } \ 121 } while (0) 122 114 123 /** Create device match ids based on its interface. 115 124 * … … 131 140 } 132 141 133 int rc;134 135 142 if (descriptor->interface_class == USB_CLASS_USE_INTERFACE) { 136 143 return ENOENT; … … 140 147 assert(classname != NULL); 141 148 142 rc = usb_add_match_id(matches, 50,149 ADD_MATCHID_OR_RETURN(matches, 50, 143 150 "usb&interface&class=%s", 144 151 classname); 145 if (rc != EOK) { 146 return rc; 147 } 148 149 rc = usb_add_match_id(matches, 70, 152 ADD_MATCHID_OR_RETURN(matches, 70, 150 153 "usb&interface&class=%s&subclass=0x%02x", 151 154 classname, descriptor->interface_subclass); 152 if (rc != EOK) { 153 return rc; 154 } 155 156 rc = usb_add_match_id(matches, 100, 155 ADD_MATCHID_OR_RETURN(matches, 100, 157 156 "usb&interface&class=%s&subclass=0x%02x&protocol=0x%02x", 158 157 classname, descriptor->interface_subclass, 159 158 descriptor->interface_protocol); 160 159 161 return rc;160 return EOK; 162 161 } 163 162 … … 172 171 const usb_standard_device_descriptor_t *device_descriptor) 173 172 { 174 int rc;175 176 173 /* 177 174 * Unless the vendor id is 0, the pair idVendor-idProduct … … 180 177 if (device_descriptor->vendor_id != 0) { 181 178 /* First, with release number. */ 182 rc = usb_add_match_id(matches, 100,179 ADD_MATCHID_OR_RETURN(matches, 100, 183 180 "usb&vendor=0x%04x&product=0x%04x&release=" BCD_FMT, 184 181 (int) device_descriptor->vendor_id, 185 182 (int) device_descriptor->product_id, 186 183 BCD_ARGS(device_descriptor->device_version)); 187 if (rc != EOK) {188 return rc;189 }190 184 191 185 /* Next, without release number. */ 192 rc = usb_add_match_id(matches, 90,186 ADD_MATCHID_OR_RETURN(matches, 90, 193 187 "usb&vendor=0x%04x&product=0x%04x", 194 188 (int) device_descriptor->vendor_id, 195 189 (int) device_descriptor->product_id); 196 if (rc != EOK) {197 return rc;198 }199 190 } 200 191 … … 204 195 */ 205 196 if (device_descriptor->device_class != USB_CLASS_USE_INTERFACE) { 206 rc = usb_add_match_id(matches, 50, "usb&class=%s",197 ADD_MATCHID_OR_RETURN(matches, 50, "usb&class=%s", 207 198 usb_str_class(device_descriptor->device_class)); 208 if (rc != EOK) {209 return rc;210 }211 199 } else { 212 rc = usb_add_match_id(matches, 50, "usb&mid"); 213 if (rc != EOK) { 214 return rc; 215 } 200 ADD_MATCHID_OR_RETURN(matches, 50, "usb&mid"); 216 201 } 217 202 … … 260 245 current_descriptor; 261 246 262 int rc = usb_add_match_id(matches, 50,247 ADD_MATCHID_OR_RETURN(matches, 50, 263 248 "usb&interface&class=%s", 264 249 usb_str_class(interface->interface_class)); 265 if (rc != EOK) {266 return rc;267 }268 250 } 269 251 … … 367 349 * As a fallback, provide the simplest match id possible. 368 350 */ 369 rc = usb_add_match_id(matches, 1, "usb&fallback"); 370 if (rc != EOK) { 371 return rc; 372 } 351 ADD_MATCHID_OR_RETURN(matches, 1, "usb&fallback"); 373 352 374 353 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.