From fca2e14e1d57d7b89d1a6de07075cc0e6e157ca7 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Mon, 23 May 2016 14:26:54 +0200 Subject: Setting and checking LOA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I02c3795c6e212491605861228eb60b731be78537 Signed-off-by: José Bollo --- src/afb-context.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/afb-context.c') diff --git a/src/afb-context.c b/src/afb-context.c index a7010dbb..0492ecbf 100644 --- a/src/afb-context.c +++ b/src/afb-context.c @@ -138,16 +138,19 @@ int afb_context_check_loa(struct afb_context *context, unsigned loa) return context->loa_in >= loa; } -void afb_context_change_loa(struct afb_context *context, unsigned loa) +int afb_context_change_loa(struct afb_context *context, unsigned loa) { - assert(context->validated); + if (!context->validated || loa > 7) + return 0; - if (loa == context->loa_in) + if (loa == context->loa_in && !context->loa_changed) context->loa_changing = 0; else { - context->loa_changing = 1; context->loa_out = loa & 7; + context->loa_changing = 1; + context->loa_changed = 0; } + return 1; } -- cgit 1.2.3-korg