/* XXX Could be per-host device, per-module, or even per-connection */
static DEFINE_SPINLOCK(gb_operations_lock);
-static void gb_operation_result_set(struct gb_operation *operation, int result)
+static bool gb_operation_result_set(struct gb_operation *operation, int result)
{
+ if (operation->errno)
+ return false;
operation->errno = result;
+ return true;
}
int gb_operation_result(struct gb_operation *operation)
gb_connection_err(operation->connection,
"unexpected incoming request type 0x%02hhx\n", header->type);
- gb_operation_result_set(operation, -EPROTONOSUPPORT);
+ (void)gb_operation_result_set(operation, -EPROTONOSUPPORT);
}
#endif
/* XXX Right now we assume we're an outgoing request */
message = gb_hd_message_find(hd, header);
operation = message->operation;
- gb_operation_result_set(operation, status);
- queue_work(gb_operation_workqueue, &operation->work);
+ if (gb_operation_result_set(operation, status))
+ queue_work(gb_operation_workqueue, &operation->work);
}
EXPORT_SYMBOL_GPL(greybus_data_sent);
memcpy(operation->request->header, data, size);
/* XXX Right now this will just complete the operation */
- gb_operation_result_set(operation, -ENOSYS);
- queue_work(gb_operation_workqueue, &operation->work);
+ if (gb_operation_result_set(operation, -ENOSYS))
+ queue_work(gb_operation_workqueue, &operation->work);
}
/*
memcpy(message->header, data, size);
/* The rest will be handled in work queue context */
- gb_operation_result_set(operation, result);
- queue_work(gb_operation_workqueue, &operation->work);
+ if (gb_operation_result_set(operation, result))
+ queue_work(gb_operation_workqueue, &operation->work);
}
/*
*/
void gb_operation_cancel(struct gb_operation *operation, int errno)
{
- gb_operation_result_set(operation, errno);
- gb_message_cancel(operation->request);
- gb_message_cancel(operation->response);
+ if (gb_operation_result_set(operation, errno)) {
+ gb_message_cancel(operation->request);
+ gb_message_cancel(operation->response);
+ }
}
/**