Style cleanup.

Some more useful default levels for the debug output (only wrapper.h, the
values actually used were okay).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10303 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-11-30 18:00:26 +00:00
parent 1ed378f0cc
commit 959aeaf834
4 changed files with 154 additions and 141 deletions
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -9,6 +9,7 @@
Device management. Device management.
*/ */
#include "scsi_dsk_int.h" #include "scsi_dsk_int.h"
#include <pnp_devfs.h> #include <pnp_devfs.h>
@@ -139,8 +140,7 @@ das_device_added(pnp_node_handle node)
// ready to register // ready to register
{ {
pnp_node_attr attrs[] = pnp_node_attr attrs[] = {
{
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_DSK_MODULE_NAME }}, { PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_DSK_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: BLKDEV_TYPE_NAME }}, { PNP_DRIVER_TYPE, B_STRING_TYPE, { string: BLKDEV_TYPE_NAME }},
// we always want blkdev on top of us // we always want blkdev on top of us
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -9,11 +9,14 @@
File handle management. File handle management.
*/ */
#include "scsi_dsk_int.h" #include "scsi_dsk_int.h"
#include <malloc.h> #include <malloc.h>
status_t das_open( das_device_info *device, das_handle_info **handle_out )
status_t
das_open(das_device_info *device, das_handle_info **handle_out)
{ {
das_handle_info *handle; das_handle_info *handle;
int res; int res;
@@ -40,7 +43,9 @@ status_t das_open( das_device_info *device, das_handle_info **handle_out )
return B_OK; return B_OK;
} }
status_t das_close( das_handle_info *handle )
status_t
das_close(das_handle_info *handle)
{ {
SHOW_FLOW0(3, ""); SHOW_FLOW0(3, "");
@@ -51,7 +56,9 @@ status_t das_close( das_handle_info *handle )
return B_OK; return B_OK;
} }
status_t das_free( das_handle_info *handle )
status_t
das_free(das_handle_info *handle)
{ {
SHOW_FLOW0(3, ""); SHOW_FLOW0(3, "");
@@ -1,6 +1,6 @@
/* /*
** Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
/* /*
@@ -9,6 +9,7 @@
Everything doing the real input/output stuff. Everything doing the real input/output stuff.
*/ */
#include "scsi_dsk_int.h" #include "scsi_dsk_int.h"
#define DAS_STD_TIMEOUT 10 #define DAS_STD_TIMEOUT 10
@@ -20,26 +21,29 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
bool write); bool write);
status_t das_read( das_handle_info *handle, const phys_vecs *vecs, status_t
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred ) das_read(das_handle_info *handle, const phys_vecs *vecs, off_t pos, size_t numBlocks,
uint32 blockSize, size_t *bytesTransferred)
{ {
return das_read_write( handle, vecs, pos, return das_read_write(handle, vecs, pos, numBlocks, blockSize,
num_blocks, block_size, bytes_transferred, false ); bytesTransferred, false);
} }
status_t das_write( das_handle_info *handle, const phys_vecs *vecs, status_t
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred ) das_write(das_handle_info *handle, const phys_vecs *vecs, off_t pos, size_t numBlocks,
uint32 blockSize, size_t *bytesTransferred)
{ {
return das_read_write( handle, vecs, pos, return das_read_write(handle, vecs, pos, numBlocks, blockSize,
num_blocks, block_size, bytes_transferred, true ); bytesTransferred, true);
} }
// universal read/write function /** universal read/write function */
static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
off_t pos64, size_t num_blocks, uint32 block_size, size_t *bytes_transferred, static int
bool write ) das_read_write(das_handle_info *handle, const phys_vecs *vecs, off_t pos64,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred, bool write)
{ {
das_device_info *device = handle->device; das_device_info *device = handle->device;
scsi_ccb *request; scsi_ccb *request;
@@ -50,7 +54,6 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
// don't test rw10_enabled restrictions - this flag may get changed // don't test rw10_enabled restrictions - this flag may get changed
request = device->scsi->alloc_ccb(device->scsi_device); request = device->scsi->alloc_ccb(device->scsi_device);
if (request == NULL) if (request == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -132,7 +135,6 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
// last chance to detect errors that occured during concurrent accesses // last chance to detect errors that occured during concurrent accesses
err = handle->pending_error; err = handle->pending_error;
if (err) if (err)
goto abort; goto abort;
@@ -149,8 +151,8 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
break; break;
case err_act_start: case err_act_start:
res = scsi_periph->send_start_stop( res = scsi_periph->send_start_stop(device->scsi_periph_device,
device->scsi_periph_device, request, 1, device->removable ); request, 1, device->removable);
if (res.action == err_act_ok) if (res.action == err_act_ok)
res.action = err_act_retry; res.action = err_act_retry;
break; break;
@@ -165,10 +167,8 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
res.action = err_act_fail; res.action = err_act_fail;
break; break;
} }
} while ((res.action == err_act_retry && retries++ < 3)
} while( || (res.action == err_act_many_retries && retries++ < 30));
(res.action == err_act_retry && retries++ < 3) ||
(res.action == err_act_many_retries && retries++ < 30 ));
device->scsi->free_ccb(request); device->scsi->free_ccb(request);
@@ -176,7 +176,7 @@ static int das_read_write( das_handle_info *handle, const phys_vecs *vecs,
// map them to "write" errors if this was a write request // map them to "write" errors if this was a write request
if (res.error_code == B_DEV_READ_ERROR && write) if (res.error_code == B_DEV_READ_ERROR && write)
return B_DEV_WRITE_ERROR; return B_DEV_WRITE_ERROR;
else
return res.error_code; return res.error_code;
abort: abort:
@@ -187,25 +187,31 @@ abort:
// kernel daemon /** kernel daemon
// once in a minute, it sets a flag so that the next command is executed * once in a minute, it sets a flag so that the next command is executed
// ordered; this way, we avoid starvation of SCSI commands inside the * ordered; this way, we avoid starvation of SCSI commands inside the
// SCSI queuing system - the ordered command waits for all previous * SCSI queuing system - the ordered command waits for all previous
// commands and thus no command can starve longer then a minute * commands and thus no command can starve longer then a minute
void das_sync_queue_daemon( void *arg, int iteration ) */
void
das_sync_queue_daemon(void *arg, int iteration)
{ {
das_device_info *device = (das_device_info *)arg; das_device_info *device = (das_device_info *)arg;
atomic_or(&device->next_tag_action, SCSI_ORDERED_QTAG); atomic_or(&device->next_tag_action, SCSI_ORDERED_QTAG);
} }
void das_handle_set_error( das_handle_info *handle, status_t error_code )
void
das_handle_set_error(das_handle_info *handle, status_t errorCode)
{ {
handle->pending_error = error_code; handle->pending_error = errorCode;
} }
status_t das_handle_get_error( das_handle_info *handle ) status_t
das_handle_get_error(das_handle_info *handle)
{ {
return handle->pending_error; return handle->pending_error;
} }
@@ -43,7 +43,7 @@
#endif #endif
#ifndef debug_level_flow #ifndef debug_level_flow
# define debug_level_flow 3 # define debug_level_flow 1
#endif #endif
#ifndef debug_level_info #ifndef debug_level_info
@@ -51,7 +51,7 @@
#endif #endif
#ifndef debug_level_error #ifndef debug_level_error
# define debug_level_error 1 # define debug_level_error 3
#endif #endif
#define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": " #define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": "