return;
}
-/*
- This function returns pointer to the flow data structure
- that contains the given id
+/**
+ * sep_find_flow_context - find a flow
+ * @sep: the SEP we are working with
+ * @flow_id: flow identifier
+ *
+ * Returns a pointer the matching flow, or NULL if the flow does not
+ * exist.
+ */
- FIXME: Daft API
-*/
-static int sep_find_flow_context(struct sep_device *sep,
- unsigned long flow_id,
- struct sep_flow_context_t **flow_data_ptr)
+static struct sep_flow_context_t *sep_find_flow_context(struct sep_device *sep,
+ unsigned long flow_id)
{
- unsigned long count;
- int error = 0;
-
+ int count;
/*
- always search for flow with id default first - in case we
- already started working on the flow there can be no situation
- when 2 flows are with default flag
+ * always search for flow with id default first - in case we
+ * already started working on the flow there can be no situation
+ * when 2 flows are with default flag
*/
for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) {
- if (sep->flows[count].flow_id == flow_id) {
- *flow_data_ptr = &sep->flows[count];
- break;
- }
+ if (sep->flows[count].flow_id == flow_id)
+ return &sep->flows[count];
}
-
- if (count == SEP_DRIVER_NUM_FLOWS)
- /* no flow found */
- error = -ENOMEM;
-
- return error;
+ return NULL;
}
first_table_data.physical_address = 0xffffffff;
/* find the free structure for flow data */
- error = sep_find_flow_context(sep, SEP_FREE_FLOW_ID, &flow_context_ptr);
- if (error)
+ flow_context_ptr = sep_find_flow_context(sep, SEP_FREE_FLOW_ID);
+ if (flow_context_ptr == NULL)
goto end_function;
error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_flow_table_t));
goto end_function;
/* find the flow structure for the flow id */
- error = sep_find_flow_context(sep, command_args.flow_id, &flow_context_ptr);
- if (error)
+ flow_context_ptr = sep_find_flow_context(sep, command_args.flow_id);
+ if (flow_context_ptr == NULL)
goto end_function;
/* prepare the flow dma tables */
}
/* find the flow context */
- error = sep_find_flow_context(sep, command_args.flow_id, &flow_context_ptr);
- if (error)
+ flow_context_ptr = sep_find_flow_context(sep, command_args.flow_id);
+ if (flow_context_ptr == NULL)
goto end_function;
/* copy the message into context */
/* find the flow data structure that was just used for creating new flow
- its id should be default */
- error = sep_find_flow_context(sep, SEP_TEMP_FLOW_ID, &flow_data_ptr);
- if (error)
+ flow_data_ptr = sep_find_flow_context(sep, SEP_TEMP_FLOW_ID);
+ if (flow_data_ptr == NULL)
goto end_function;
/* set flow id */
static irqreturn_t sep_inthandler(int irq, void *dev_id)
{
irqreturn_t int_error;
- unsigned long error;
unsigned long reg_val;
unsigned long flow_id;
struct sep_flow_context_t *flow_context_ptr;
flow_id = sep_read_reg(sep, HW_HOST_IRR_REG_ADDR);
/* find the contex of the flow */
- error = sep_find_flow_context(sep, flow_id >> 28, &flow_context_ptr);
- if (error)
+ flow_context_ptr = sep_find_flow_context(sep, flow_id >> 28);
+ if (flow_context_ptr == NULL)
goto end_function_with_error;
- INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler);
-
/* queue the work */
+ INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler);
queue_work(sep->flow_wq, &flow_context_ptr->flow_wq);
} else {
if (reg_val & (0x1 << 13)) {
/* update the counter of reply messages */
sep->reply_ct++;
-
/* wake up the waiting process */
wake_up(&sep_event);
} else {