Author: axeld Date: 2011-01-12 19:24:43 +0100 (Wed, 12 Jan 2011) New Revision: 40222 Changeset: http://dev.haiku-os.org/changeset/40222 Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/wrapper.h Log: * Removed *_BEN() macros. * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,10 +1,11 @@ /* - * Copyright 2004-2008, Haiku, Inc. All RightsReserved. + * Copyright 2004-2011, Haiku, Inc. All RightsReserved. * Copyright 2002-2003, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. */ + //! Handling of block device (currently, only a capacity check is provided) @@ -51,13 +52,13 @@ return B_DEV_MEDIA_CHANGED; } - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); if (res == B_OK && request->data_resid == 0) { capacity = B_BENDIAN_TO_HOST_INT32(capacityResult.lba); if (capacity == UINT_MAX) { - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); scsi_cmd_read_capacity_long *cmd = (scsi_cmd_read_capacity_long *)request->cdb; @@ -73,7 +74,7 @@ res = periph_safe_exec(device, request); - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); if (res == B_OK && request->data_resid == 0) { capacity = B_BENDIAN_TO_HOST_INT64(capacityLongResult.lba); @@ -105,7 +106,7 @@ return ERR_DEV_GENERAL; }*/ - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); SHOW_FLOW(3, "done (%s)", strerror(res)); Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,10 +1,11 @@ /* - * Copyright 2004-2008, Haiku, Inc. All RightsReserved. + * Copyright 2004-2011, Haiku, Inc. All RightsReserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. */ + //! Basic handling of device. @@ -52,26 +53,21 @@ status_t -periph_register_device(periph_device_cookie periph_device, scsi_periph_callbacks *callbacks, - scsi_device scsi_device, scsi_device_interface *scsi, device_node *node, +periph_register_device(periph_device_cookie periph_device, + scsi_periph_callbacks *callbacks, scsi_device scsi_device, + scsi_device_interface *scsi, device_node *node, bool removable, int preferredCcbSize, scsi_periph_device *driver) { - scsi_periph_device_info *device; - status_t res; + SHOW_FLOW0(3, ""); - SHOW_FLOW0( 3, "" ); - - device = (scsi_periph_device_info *)malloc(sizeof(*device)); + scsi_periph_device_info *device + = (scsi_periph_device_info *)malloc(sizeof(*device)); if (device == NULL) return B_NO_MEMORY; memset(device, 0, sizeof(*device)); - if (INIT_BEN(&device->mutex, "SCSI_PERIPH") != B_OK) { - res = B_NO_MEMORY; - goto err1; - } - + mutex_init(&device->mutex, "SCSI_PERIPH"); device->scsi_device = scsi_device; device->scsi = scsi; device->periph_device = periph_device; @@ -87,9 +83,10 @@ device->rw10_enabled = true; // launch sync daemon - res = register_kernel_daemon(periph_sync_queue_daemon, device, 60*10); - if (res != B_OK) - goto err2; + status_t status = register_kernel_daemon(periph_sync_queue_daemon, device, + 60*10); + if (status != B_OK) + goto err1; *driver = device; @@ -97,11 +94,10 @@ return B_OK; -err2: - DELETE_BEN(&device->mutex); err1: + mutex_destroy(&device->mutex); free(device); - return res; + return status; } Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.cpp 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.cpp 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,20 +1,17 @@ /* - * Copyright 2002/03, Thomas Kurschel. All rights reserved. + * Copyright 2011, Haiku, Inc. All RightsReserved. + * Copyright 2002-03, Thomas Kurschel. All rights reserved. * Distributed under the terms of the MIT License. */ -/* - Part of Open SCSI Peripheral Driver - Error handling -*/ +//! Error handling #include "scsi_periph_int.h" -/** decode sense data and generate error code */ - +/*! Decode sense data and generate error code. */ static err_res check_sense(scsi_periph_device_info *device, scsi_ccb *request) { @@ -86,9 +83,9 @@ case SCSIS_ASC_REMOVAL_REQUESTED: SHOW_INFO0(2, "Removal requested"); - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); device->removal_requested = true; - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); return MK_ERROR(err_act_retry, B_DEV_MEDIA_CHANGE_REQUESTED); @@ -207,8 +204,7 @@ } -/** check scsi status, using sense if available */ - +/*! Check scsi status, using sense if available. */ static err_res check_scsi_status(scsi_periph_device_info *device, scsi_ccb *request) { @@ -238,12 +234,11 @@ } -/** check result of request +/*! Check result of request * 1. check SCSI subsystem problems * 2. if request hit device, check SCSI status * 3. if request got executed, check sense */ - err_res periph_check_error(scsi_periph_device_info *device, scsi_ccb *request) { Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.cpp 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.cpp 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,24 +1,23 @@ /* -** Copyright 2002/03, Thomas Kurschel. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2011, Haiku, Inc. All RightsReserved. + * Copyright 2002-03, Thomas Kurschel. All rights reserved. + * Distributed under the terms of the MIT License. + */ -/* - Part of Open SCSI Peripheral Driver - Basic handling of file handles. -*/ +//! Basic handling of file handles. #include "scsi_periph_int.h" +#include <stdlib.h> + #include "dl_list.h" -#include <malloc.h> status_t -periph_handle_open(scsi_periph_device_info *device, periph_handle_cookie periph_handle, - scsi_periph_handle_info **res_handle) +periph_handle_open(scsi_periph_device_info *device, + periph_handle_cookie periph_handle, scsi_periph_handle_info **res_handle) { scsi_periph_handle_info *handle; @@ -32,9 +31,9 @@ handle->device = device; handle->pending_error = B_OK; - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); ADD_DL_LIST_HEAD(handle, device->handles, ); - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); *res_handle = handle; @@ -59,9 +58,9 @@ // SHOW_FLOW( 3, "handle=%p, device=%p", handle, handle->device ); - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); REMOVE_DL_LIST(handle, device->handles, ); - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); free(handle); Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.cpp 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.cpp 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,10 +1,11 @@ /* - * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Copyright 2004-2011, Haiku, Inc. All RightsReserved. * Copyright 2002-2003, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. */ + //! Handling of removable media. @@ -70,14 +71,14 @@ { scsi_periph_handle_info *handle; - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); // when medium has changed, tell all handles // (this must be atomic for each handle!) for (handle = device->handles; handle; handle = handle->next) handle->pending_error = B_DEV_MEDIA_CHANGED; - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); } @@ -151,7 +152,7 @@ err_res res; status_t err; - ACQUIRE_BEN(&device->mutex); + mutex_lock(&device->mutex); // removal requests are returned to exactly one handle // (no real problem, as noone check medias status "by mistake") @@ -170,7 +171,7 @@ SHOW_FLOW0( 3, "" ); - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); // finally, ask the device itself @@ -187,7 +188,7 @@ return res.error_code; err: - RELEASE_BEN(&device->mutex); + mutex_unlock(&device->mutex); return err; } Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/wrapper.h =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/wrapper.h 2011-01-12 18:06:04 UTC (rev 40221) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/wrapper.h 2011-01-12 18:24:43 UTC (rev 40222) @@ -1,18 +1,11 @@ #ifndef _WRAPPER_H #define _WRAPPER_H + #include <KernelExport.h> #include <lock.h> -// benaphores - -#define INIT_BEN(x, prefix) (mutex_init_etc(x, prefix, MUTEX_FLAG_CLONE_NAME), \ - B_OK) -#define DELETE_BEN(x) mutex_destroy(x) -#define ACQUIRE_BEN(x) mutex_lock(x) -#define RELEASE_BEN(x) mutex_unlock(x) - // debug output #ifdef DEBUG_WAIT_ON_MSG @@ -87,4 +80,5 @@ dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \ }} while( 0 ) -#endif /* _BENAPHORE_H */ + +#endif /* _WRAPPER_H */