1 /* 2 ** Copyright 2002/03, Thomas Kurschel. All rights reserved. 3 ** Distributed under the terms of the OpenBeOS License. 4 */ 5 6 /* 7 Part of Open SCSI Peripheral Driver 8 9 Basic handling of file handles. 10 */ 11 12 13 #include "scsi_periph_int.h" 14 15 #include "dl_list.h" 16 #include <malloc.h> 17 18 19 status_t 20 periph_handle_open(scsi_periph_device_info *device, periph_handle_cookie periph_handle, 21 scsi_periph_handle_info **res_handle) 22 { 23 scsi_periph_handle_info *handle; 24 25 // SHOW_FLOW( 3, "device=%p", device ); 26 27 handle = (scsi_periph_handle_info *)malloc(sizeof(*handle)); 28 if (handle == NULL) 29 return B_NO_MEMORY; 30 31 handle->periph_handle = periph_handle; 32 handle->device = device; 33 handle->pending_error = B_OK; 34 35 ACQUIRE_BEN(&device->mutex); 36 ADD_DL_LIST_HEAD(handle, device->handles, ); 37 RELEASE_BEN(&device->mutex); 38 39 *res_handle = handle; 40 41 // SHOW_FLOW( 3, "handle=%p", handle ); 42 43 return B_OK; 44 } 45 46 47 status_t 48 periph_handle_close(scsi_periph_handle_info *handle) 49 { 50 // SHOW_FLOW( 3, "handle=%p", handle ); 51 return B_OK; 52 } 53 54 55 status_t 56 periph_handle_free(scsi_periph_handle_info *handle) 57 { 58 scsi_periph_device_info *device = handle->device; 59 60 // SHOW_FLOW( 3, "handle=%p, device=%p", handle, handle->device ); 61 62 ACQUIRE_BEN(&device->mutex); 63 REMOVE_DL_LIST(handle, device->handles, ); 64 RELEASE_BEN(&device->mutex); 65 66 free(handle); 67 68 // SHOW_FLOW0( 3, "done" ); 69 70 return B_OK; 71 } 72