- fix warnings, produced by Haiku version of gcc;

- space indentation replaced by tab-based one to conform with Haiku coding guidelines;
 - a bit of cleanup;

 NB: Sorry for big amount of changes. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18781 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
imker
2006-09-08 19:37:58 +00:00
parent 4d493bb44a
commit d8b1cf0703
7 changed files with 690 additions and 671 deletions
+30 -34
View File
@@ -1,9 +1,15 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
/** bulk-only protocol specific implementation */
/* References:
@@ -59,18 +65,24 @@ typedef struct _usb_mass_CSW{
#define CBW_FLAGS_OUT 0x00
#define CBW_FLAGS_IN 0x80
static void trace_CBW(usb_device_info *udi, const usb_mass_CBW *cbw);
static void trace_CSW(usb_device_info *udi, const usb_mass_CSW *csw);
static status_t bulk_only_initialize(usb_device_info *udi);
static status_t bulk_only_reset(usb_device_info *udi);
static void bulk_only_transfer(usb_device_info *udi, uint8 *cmd,
uint8 cmdlen, //sg_buffer *sgb,
iovec *sg_data, int32 sg_count,
int32 transfer_len, EDirection dir,
CCB_SCSIIO *ccbio, ud_transfer_callback cb);
/*=========================== tracing helpers ==================================*/
void trace_CBW(usb_device_info *udi, const usb_mass_CBW *cbw)
{
char buf[sizeof(uint32) + 1] = {0};
strncpy(buf, (char *)&cbw->signature, sizeof(uint32));
PTRACE(udi, "\nCBW:{'%s'; tag:%d; data_len:%d; flags:0x%02x; lun:%d; cdb_len:%d;}\n",
buf,
cbw->tag,
cbw->data_transfer_len,
cbw->flags,
cbw->lun,
cbw->cdb_len);
buf, cbw->tag, cbw->data_transfer_len,
cbw->flags, cbw->lun, cbw->cdb_len);
udi->trace_bytes("CDB:\n", cbw->CDB, CBW_CDB_LENGTH);
}
@@ -79,10 +91,7 @@ void trace_CSW(usb_device_info *udi, const usb_mass_CSW *csw)
char buf[sizeof(uint32) + 1] = {0};
strncpy(buf, (char *)&csw->signature, sizeof(uint32));
PTRACE(udi, "CSW:{'%s'; tag:%d; residue:%d; status:0x%02x}\n",
buf,
csw->tag,
csw->data_residue,
csw->status);
buf, csw->tag, csw->data_residue, csw->status);
}
/**
@@ -131,10 +140,7 @@ get_max_luns(usb_device_info *udi)
operation.
*/
static status_t
queue_bulk(usb_device_info *udi,
void *buffer,
size_t len,
bool b_in)
queue_bulk(usb_device_info *udi, void* buffer, size_t len, bool b_in)
{
status_t status = B_OK;
usb_pipe pipe = b_in ? udi->pipe_in : udi->pipe_out;
@@ -161,9 +167,7 @@ queue_bulk(usb_device_info *udi,
BulkOnly specification ([2] 6.3)
*/
static bool
check_CSW(usb_device_info *udi,
usb_mass_CSW *csw,
int transfer_len)
check_CSW(usb_device_info *udi, usb_mass_CSW* csw, int transfer_len)
{
bool is_valid = false;
do{
@@ -208,9 +212,7 @@ check_CSW(usb_device_info *udi,
reads CSW from device as proposed in ([2] 5.3.3; Figure 2.).
*/
static status_t
read_status(usb_device_info *udi,
usb_mass_CSW *csw,
int transfer_len)
read_status(usb_device_info *udi, usb_mass_CSW* csw, int transfer_len)
{
status_t status = B_ERROR;
int try = 0;
@@ -314,16 +316,9 @@ bulk_only_reset(usb_device_info *udi)
[2]
*/
void
bulk_only_transfer(usb_device_info *udi,
uint8 *cmd,
uint8 cmdlen,
//sg_buffer *sgb,
iovec *sg_data,
int32 sg_count,
int32 transfer_len,
EDirection dir,
CCB_SCSIIO *ccbio,
ud_transfer_callback cb)
bulk_only_transfer(usb_device_info *udi, uint8 *cmd, uint8 cmdlen, //sg_buffer *sgb,
iovec *sg_data,int32 sg_count, int32 transfer_len,
EDirection dir, CCB_SCSIIO *ccbio, ud_transfer_callback cb)
{
status_t status = B_OK;
status_t command_status = B_OK;
@@ -381,3 +376,4 @@ protocol_module_info bulk_only_protocol_m = {
bulk_only_reset,
bulk_only_transfer,
};
@@ -1,9 +1,15 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
/** bulk-only protocol "standard" procedures */
+24 -20
View File
@@ -1,9 +1,15 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
/* References:
* USB Mass Storage Class specifications:
* http://www.usb.org/developers/data/devclass/usbmassover_11.pdf
@@ -55,6 +61,13 @@ typedef union _usb_mass_CBI_IDB{
#define CBI_IDB_VALUE_PERSISTENT 0x03
#define CBI_IDB_VALUE_STATUS_MASK 0x03
static void trace_CDB(usb_device_info *udi, const usb_mass_CBI_CB *cb, int len);
static status_t cbi_reset(usb_device_info *udi);
static status_t cbi_initialize(usb_device_info *udi);
static void cbi_transfer(usb_device_info *udi, uint8 *cmd, uint8 cmdlen, //sg_buffer *sgb,
iovec *sg_data, int32 sg_count, int32 transfer_len,
EDirection dir, CCB_SCSIIO *ccbio, ud_transfer_callback cb);
/** returns size of private protocol buffer */
//int cbi_buffer_length(){ return sizeof(usb_mass_CBI_CB) + sizeof(usb_mass_CBI_IDB); }
/** casts private protocol buffer to CBI_IDB */
@@ -72,9 +85,7 @@ void trace_CDB(usb_device_info *udi, const usb_mass_CBI_CB *cb, int len)
}
static status_t
send_request_adsc(usb_device_info *udi,
void *cb,
int length)
send_request_adsc(usb_device_info *udi, void *cb, int length)
{
status_t status = B_ERROR;
size_t len = 0;
@@ -88,8 +99,7 @@ send_request_adsc(usb_device_info *udi,
}
static status_t
request_interrupt(usb_device_info *udi,
usb_mass_CBI_IDB *idb)
request_interrupt(usb_device_info *udi, usb_mass_CBI_IDB *idb)
{
status_t status = B_ERROR;
status = (*udi->usb_m->queue_interrupt)(udi->pipe_intr, idb,
@@ -108,8 +118,7 @@ request_interrupt(usb_device_info *udi,
}
static status_t
parse_status(usb_device_info *udi,
usb_mass_CBI_IDB *idb)
parse_status(usb_device_info *udi, usb_mass_CBI_IDB *idb)
{
status_t command_status = B_OK;
if(CMDSET(udi->properties) == CMDSET_UFI){
@@ -196,16 +205,10 @@ cbi_initialize(usb_device_info *udi)
???
*/
void
cbi_transfer(usb_device_info *udi,
uint8 *cmd,
uint8 cmdlen,
cbi_transfer(usb_device_info *udi, uint8 *cmd, uint8 cmdlen,
//sg_buffer *sgb,
iovec *sg_data,
int32 sg_count,
int32 transfer_len,
EDirection dir,
CCB_SCSIIO *ccbio,
ud_transfer_callback cb)
iovec *sg_data, int32 sg_count, int32 transfer_len,
EDirection dir,CCB_SCSIIO *ccbio, ud_transfer_callback cb)
{
status_t status = B_OK;
status_t command_status = B_OK;
@@ -255,3 +258,4 @@ protocol_module_info cbi_protocol_m = {
cbi_reset,
cbi_transfer,
};
+10 -4
View File
@@ -1,9 +1,15 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
#ifndef _PROTO_CBI_H_
#define _PROTO_CBI_H_
@@ -1,9 +1,15 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
#include <string.h>
#include "usb_scsi.h"
@@ -24,10 +30,7 @@
???
*/
void bulk_callback(void *cookie,
uint32 status,
void *data,
uint32 actual_len)
void bulk_callback(void *cookie, uint32 status, void* data, uint32 actual_len)
{
TRACE_BULK_CALLBACK(status, actual_len);
if(cookie){
@@ -47,10 +50,8 @@ void bulk_callback(void *cookie,
???
*/
status_t process_data_io(usb_device_info *udi,
//sg_buffer *sgb,
iovec *sg_data, int32 sg_count,
EDirection dir)
status_t process_data_io(usb_device_info *udi, //sg_buffer *sgb,
iovec *sg_data, int32 sg_count, EDirection dir)
{
status_t status = B_OK;
usb_pipe pipe = (dir == eDirIn) ? udi->pipe_in : udi->pipe_out;
@@ -75,10 +76,8 @@ status_t process_data_io(usb_device_info *udi,
return status;
}
void transfer_callback(struct _usb_device_info *udi,
CCB_SCSIIO *ccbio,
int32 residue,
status_t status)
void transfer_callback(struct _usb_device_info *udi, CCB_SCSIIO *ccbio,
int32 residue, status_t status)
{
ccbio->cam_resid = residue;
switch(status){
@@ -120,10 +119,8 @@ void transfer_callback(struct _usb_device_info *udi,
}
}
void sense_callback(struct _usb_device_info *udi,
CCB_SCSIIO *ccbio,
int32 residue,
status_t status)
void sense_callback(struct _usb_device_info *udi, CCB_SCSIIO *ccbio,
int32 residue, status_t status)
{
ccbio->cam_sense_resid = residue;
switch(status){
@@ -1,6 +1,13 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
#ifndef _PROTO_COMMON_H_
@@ -10,19 +17,14 @@
#include "device_info.h"
#endif /* _DEVICE_INFO_H_ */
void bulk_callback(void *cookie,
uint32 status,
void *data,
uint32 actual_len);
void bulk_callback(void *cookie, uint32 status, void* data, uint32 actual_len);
status_t process_data_io(usb_device_info *udi, iovec *sg_data, int32 sg_count/*sg_buffer *sgb*/, EDirection dir);
void transfer_callback(usb_device_info *udi,
CCB_SCSIIO *ccbio,
int32 residue,
status_t status);
void sense_callback(usb_device_info *udi,
CCB_SCSIIO *ccbio,
int32 residue,
status_t status);
void transfer_callback(usb_device_info *udi, CCB_SCSIIO *ccbio,
int32 residue, status_t status);
void sense_callback(usb_device_info *udi, CCB_SCSIIO *ccbio,
int32 residue, status_t status);
#endif /*_PROTO_COMMON_H_*/
@@ -1,6 +1,13 @@
/*
* Copyright (c) 2003-2005 by Siarzhuk Zharski <[email protected]>
* Distributed under the terms of the BSD License.
/**
*
* TODO: description
*
* This file is a part of USB SCSI CAM for Haiku OS.
* May be used under terms of the MIT License
*
* Author(s):
* Siarzhuk Zharski <[email protected]>
*
*
*/
#ifndef _PROTO_MODULE_H_
@@ -79,3 +86,4 @@ typedef struct {
{ if(__udi->b_trace) __udi->trace(false, __x); }
#endif /* _PROTO_MODULE_H_ */