Commit 0d2766b2 authored by Federico Vaga's avatar Federico Vaga

wrtd:lib: check rt-in version on open

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>


NOTE
This commit has been created by `git subtree` on the Mock Turtle repository
on tag mock-turtle-2.0

This commit will not compile
parent 2b9f8f78
......@@ -32,6 +32,8 @@ const char *wrtd_errors[] = {
"Trigger not found",
"No trigger condition",
"Invalid pulse width",
"Invalid input real-time application",
"Invalid output real-time application"
};
......@@ -92,6 +94,7 @@ void wrtd_exit()
static struct wrtd_node *wrtd_open(uint32_t device_id, unsigned int is_lun)
{
struct wrtd_desc *wrtd;
struct wrnc_rt_version version;
int err;
wrtd = malloc(sizeof(struct wrtd_desc));
......@@ -118,6 +121,15 @@ static struct wrtd_node *wrtd_open(uint32_t device_id, unsigned int is_lun)
if (err)
goto out;
err = wrtd_in_version((struct wrtd_node *)wrtd, &version);
if (err)
goto out;
if (version.rt_id != WRTD_IN_RT_ID) {
errno = EWRTD_INVALID_IN_APP;
goto out;
}
return (struct wrtd_node *)wrtd;
out:
......
......@@ -45,6 +45,8 @@ enum wrtd_error_list {
EWRTD_NOFOUND_TRIGGER,
EWRTD_NO_TRIGGER_CONDITION,
EWRTD_INVALID_PULSE_WIDTH,
EWRTD_INVALID_IN_APP,
EWRTD_INVALID_OUT_APP,
__EWRTD_MAX_ERROR_NUMBER,
};
......
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