Commit 3ba041cf authored by Bruno Gomes's avatar Bruno Gomes

LIBIOP: uniformize libiop drivers init and open error return

TODO: create libiop feedback and/or error handling

refs #112663
parent f1093ccf
......@@ -55,6 +55,7 @@ uint32_t gr1553b_initialize(iop_device_driver_t *iop_dev, void *arg)
/* kill this process */
iop_raise_error(CONFIGURATION_ERROR);
return AIR_INVALID_CONFIG;
}
/* Clear pointers. These fields will be filled later*/
......
......@@ -85,6 +85,9 @@ void gr1553bc_device_init(grb_priv *priv)
/* start the list */
gr1553bc_start_sync(priv);
/* Device is ready */
priv->open = 1;
}
......@@ -313,19 +316,12 @@ static inline uint32_t create_descriptor_word1(bc_command_t *ul, int timeout, in
}
static inline air_status_code_e bc_verify_command_status(uint32_t sw)
{
air_status_code_e status = AIR_SUCCESSFUL;
{
/* verify transfer status */
if((sw & 0x7) != 0){
status = AIR_INTERNAL_ERROR;
/* something has gone wrong with the transfer */
iop_raise_error(HW_PROBLEM);
}
return status;
if((sw & 0x7) != 0)
return AIR_INTERNAL_ERROR;
return AIR_SUCCESSFUL;
}
static inline void dummy_command(volatile uint32_t *cw)
......@@ -462,6 +458,7 @@ static int update_command(grb_priv *priv, iop_buffer_t *buf){
*
* @return status of the operation:
* - AIR_SUCCESSFUL: Data was successfully read.
* - AIR_INVALID_CONFIG: Device was not open
* - AIR_TIMED_OUT: End of list.
*
* This function will obtain the list that is currently being processed by
......@@ -481,7 +478,7 @@ uint32_t gr1553bc_read(iop_device_driver_t *iop_dev, void *arg)
iop_wrapper_t *wrapper = (iop_wrapper_t *) arg;
/* return code */
air_status_code_e status;
air_status_code_e status = AIR_SUCCESSFUL;
/* indicates if data was sucessfully read or if the list has ended */
int end = 0;
......@@ -489,7 +486,8 @@ uint32_t gr1553bc_read(iop_device_driver_t *iop_dev, void *arg)
/* current bc descriptor */
struct gr1553bc_bd_tr *current;
status = AIR_SUCCESSFUL;
if(!priv->open)
return AIR_INVALID_CONFIG;
/* @todo place a limit in the number of reads... */
while(end == 0){
......@@ -543,6 +541,7 @@ uint32_t gr1553bc_read(iop_device_driver_t *iop_dev, void *arg)
*
* @return air_status_code_e; status of the operation:
* - AIR_SUCCESSFUL: Data was successfully written to the list
* - AIR_INVALID_CONFIG: Device not open
* - AIR_NOT_AVAILABLE: this data is not linked to any command in the list
*
* This function inserts incoming user data in the bc command list. For that
......@@ -560,6 +559,9 @@ uint32_t gr1553bc_write(iop_device_driver_t *iop_dev, void *arg)
iop_wrapper_t *wrapper = (iop_wrapper_t *) arg;
if(!priv->open)
return AIR_INVALID_CONFIG;
/* return code */
air_status_code_e status;
......
......@@ -760,7 +760,7 @@ int iop_grcan_device_init(iop_device_driver_t *iop_dev)
device->can_core,
&grcandev) != 1)
{
return -1;
return AIR_DEVICE_NOT_FOUND;
}
#if 0
......@@ -835,7 +835,7 @@ int iop_grcan_device_init(iop_device_driver_t *iop_dev)
}
DBG("dev_sem created with ID: %d\n", (int) pDev->dev_sem);
#endif
return 0;
return AIR_SUCCESSFUL;
}
/*
......@@ -854,7 +854,7 @@ uint32_t iop_grcan_initialize(iop_device_driver_t *iop_dev, void *arg){
/* Enable CAN Clock gate */
clock_gating_enable(&amba_confarea, GATE_CAN);
if( iop_grcan_device_init(iop_dev) == AIR_INTERNAL_ERROR){
if(AIR_SUCCESSFUL != iop_grcan_device_init(iop_dev)){
// Couldn't initialize the device
DBG("Internal error on grcan_device_init\n");
return AIR_DEVICE_ERROR;
......@@ -871,7 +871,6 @@ air_status_code_e iop_grcan_open_internal(iop_device_driver_t *iop_dev, void *ar
{
iop_can_device_t *device = (iop_can_device_t *) iop_dev;
grcan_priv *pDev = (grcan_priv *) (device->dev.driver);
air_status_code_e ret = AIR_SUCCESSFUL;
FUNCDBG();
DBG("CAN core %d\n", device->can_core);
......@@ -886,15 +885,6 @@ air_status_code_e iop_grcan_open_internal(iop_device_driver_t *iop_dev, void *ar
DBG("Semaphore taken\n");
#endif
/* is device busy/taken? */
if ( pDev->open ) {
DBG("Device taken\n");
ret = AIR_DEVICE_ERROR;
goto out;
}
/* Mark device taken */
pDev->open = 1;
pDev->txblock = pDev->rxblock = 0;
pDev->txcomplete = pDev->rxcomplete = 0;
......@@ -927,11 +917,10 @@ air_status_code_e iop_grcan_open_internal(iop_device_driver_t *iop_dev, void *ar
memset(&pDev->stats,0,sizeof(struct grcan_stats));
out:
#if 0
rtems_semaphore_release(pDev->dev_sem);
#endif
return ret;
return AIR_SUCCESSFUL;
}
/*
......@@ -1004,9 +993,6 @@ uint32_t iop_grcan_close(iop_device_driver_t * iop_dev, void *arg)
//~ grcan_free_buffers(pDev,1,1);
/* Mark Device as closed */
pDev->open = 0;
return AIR_SUCCESSFUL;
}
......
......@@ -217,7 +217,6 @@ typedef struct grcan_priv_ {
struct grcan_regs *regs;
int irq;
int minor;
int open;
int started;
unsigned int channel;
int flushing;
......
......@@ -757,7 +757,7 @@ uint32_t greth_initialize(iop_device_driver_t *iop_dev, void *arg) {
if (amba_get_apb_slave(ptrarea, VENDOR_GAISLER, GAISLER_ETHMAC,
device->id, &apbgreth) != 1){
iop_debug(" GRETH device not found...\n");
return AIR_INTERNAL_ERROR;
return AIR_DEVICE_NOT_FOUND;
}
/* Store configuration parameters */
......
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