Changeset a546687 in mainline for uspace/lib/usb/src/pipes.c
- Timestamp:
- 2011-04-09T09:17:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d48fcc0
- Parents:
- d5ac90f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/pipes.c
rd5ac90f ra546687 41 41 #include <errno.h> 42 42 #include <assert.h> 43 #include "pipepriv.h" 43 44 44 45 #define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */ … … 246 247 int usb_pipe_start_session(usb_pipe_t *pipe) 247 248 { 248 assert(pipe); 249 250 if (usb_pipe_is_session_started(pipe)) { 251 return EBUSY; 252 } 253 254 int phone = devman_device_connect(pipe->wire->hc_handle, 0); 255 if (phone < 0) { 256 return phone; 257 } 258 259 pipe->hc_phone = phone; 260 261 return EOK; 249 return pipe_add_ref(pipe); 262 250 } 263 251 … … 272 260 int usb_pipe_end_session(usb_pipe_t *pipe) 273 261 { 274 assert(pipe); 275 276 if (!usb_pipe_is_session_started(pipe)) { 277 return ENOENT; 278 } 279 280 int rc = async_hangup(pipe->hc_phone); 281 if (rc != EOK) { 282 return rc; 283 } 284 285 pipe->hc_phone = -1; 286 262 pipe_drop_ref(pipe); 287 263 return EOK; 288 264 } … … 298 274 bool usb_pipe_is_session_started(usb_pipe_t *pipe) 299 275 { 300 return (pipe->hc_phone >= 0); 276 pipe_acquire(pipe); 277 bool started = pipe->refcount > 0; 278 pipe_release(pipe); 279 return started; 301 280 } 302 281
Note:
See TracChangeset
for help on using the changeset viewer.