* Copyright 2011, Haiku, Inc. All RightsReserved.
* Copyright 2002-03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "scsi_periph_int.h"
#include <stdlib.h>
#include "dl_list.h"
status_t
periph_handle_open(scsi_periph_device_info *device,
periph_handle_cookie periph_handle, scsi_periph_handle_info **res_handle)
{
scsi_periph_handle_info *handle;
handle = (scsi_periph_handle_info *)malloc(sizeof(*handle));
if (handle == NULL)
return B_NO_MEMORY;
handle->periph_handle = periph_handle;
handle->device = device;
handle->pending_error = B_OK;
mutex_lock(&device->mutex);
ADD_DL_LIST_HEAD(handle, device->handles, );
mutex_unlock(&device->mutex);
*res_handle = handle;
return B_OK;
}
status_t
periph_handle_close(scsi_periph_handle_info *handle)
{
return B_OK;
}
status_t
periph_handle_free(scsi_periph_handle_info *handle)
{
scsi_periph_device_info *device = handle->device;
mutex_lock(&device->mutex);
REMOVE_DL_LIST(handle, device->handles, );
mutex_unlock(&device->mutex);
free(handle);
return B_OK;
}