Commit 40e61d12 authored by Matthias Beyer's avatar Matthias Beyer Committed by Greg Kroah-Hartman

Staging: bcm: InterfaceMisc.c: Outsourced doubled error checking

Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8e7e2805
#include "headers.h" #include "headers.h"
int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter, static int adapter_err_occurred(const struct bcm_interface_adapter *ad)
unsigned int addr,
void *buff,
int len)
{ {
int bytes; if (ad->psAdapter->device_removed == TRUE) {
BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_PRINTK, 0, 0,
if (!psIntfAdapter)
return -EINVAL;
if (psIntfAdapter->psAdapter->device_removed == TRUE) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
"Device got removed"); "Device got removed");
return -ENODEV; return -ENODEV;
} }
if ((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && if ((ad->psAdapter->StopAllXaction == TRUE) &&
(psIntfAdapter->psAdapter->chip_id >= T3LPB)) { (ad->psAdapter->chip_id >= T3LPB)) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM, BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
DBG_LVL_ALL, DBG_LVL_ALL,
"Currently Xaction is not allowed on the bus"); "Currently Xaction is not allowed on the bus");
return -EACCES; return -EACCES;
} }
if (psIntfAdapter->bSuspended == TRUE || if (ad->bSuspended == TRUE || ad->bPreparingForBusSuspend == TRUE) {
psIntfAdapter->bPreparingForBusSuspend == TRUE) { BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM,
DBG_LVL_ALL, DBG_LVL_ALL,
"Bus is in suspended states hence RDM not allowed.."); "Bus is in suspended states hence RDM not allowed..");
return -EACCES; return -EACCES;
} }
return 0;
}
int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter,
unsigned int addr,
void *buff,
int len)
{
int bytes;
int err = 0;
if (!psIntfAdapter)
return -EINVAL;
err = adapter_err_occurred(psIntfAdapter);
if (err)
return err;
psIntfAdapter->psAdapter->DeviceAccess = TRUE; psIntfAdapter->psAdapter->DeviceAccess = TRUE;
bytes = usb_control_msg(psIntfAdapter->udev, bytes = usb_control_msg(psIntfAdapter->udev,
...@@ -63,31 +73,14 @@ int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, ...@@ -63,31 +73,14 @@ int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,
int len) int len)
{ {
int retval = 0; int retval = 0;
int err = 0;
if (!psIntfAdapter) if (!psIntfAdapter)
return -EINVAL; return -EINVAL;
if (psIntfAdapter->psAdapter->device_removed == TRUE) { err = adapter_err_occurred(psIntfAdapter);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, if (err)
"Device got removed"); return err;
return -ENODEV;
}
if ((psIntfAdapter->psAdapter->StopAllXaction == TRUE) &&
(psIntfAdapter->psAdapter->chip_id >= T3LPB)) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
DBG_LVL_ALL,
"Currently Xaction is not allowed on the bus...");
return -EACCES;
}
if (psIntfAdapter->bSuspended == TRUE ||
psIntfAdapter->bPreparingForBusSuspend == TRUE) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
DBG_LVL_ALL,
"Bus is in suspended states hence RDM not allowed..");
return -EACCES;
}
psIntfAdapter->psAdapter->DeviceAccess = TRUE; psIntfAdapter->psAdapter->DeviceAccess = TRUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment