From patchwork Sat Mar 15 13:26:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shukla X-Patchwork-Id: 26334 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 40526202DD for ; Sat, 15 Mar 2014 13:26:31 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j7sf7580369qaq.10 for ; Sat, 15 Mar 2014 06:26:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=4g3m1DECfQsKgbS2CRAseEnH5nxTD8qsWDJC73N4zh0=; b=hqBeyoGXSQ4xn/PgSrzoEHXV4/cQ0pnp7tAoo8bSdJ2dsDGquTfXxYlvkQ2gF54CSi pGlOzGHeo9Mlb60p6oc87tFxLT4/xFVqAk79HfpT7rTrYbMalgRTnc3EEO0aG17x9t9W WomCjUX8dqGKQQ6ZPKpBfPyfjn7js/Ip/4+/13uuV1aLV9bwtIXZaD6qmMDf67Artfdu gWC3OcaUAAiAQUcnPeXVIPIHLCDbyRQA8AMRFZFFDZE4w6qZk+X36VCV3+UHlQfLLyg+ Q2r+1Yj5aOiwEURHEouS8qCwWK57fLr7N4t0No2S0Hn0jvqtKdxb8hNoMFnaOppXZbhJ 4XNg== X-Gm-Message-State: ALoCoQkn8Z2D79yvoP84ri2+R9nDr0XB6fKMtQRq3PpRCfGr5ZioXTLhz+wGlPbIaO0LBvRRWC4y X-Received: by 10.236.84.141 with SMTP id s13mr5123265yhe.5.1394889990697; Sat, 15 Mar 2014 06:26:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.51.18.68 with SMTP id gk4ls337640igd.29.gmail; Sat, 15 Mar 2014 06:26:30 -0700 (PDT) X-Received: by 10.68.135.137 with SMTP id ps9mr1562752pbb.160.1394889990270; Sat, 15 Mar 2014 06:26:30 -0700 (PDT) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx.google.com with ESMTPS id zt8si8772539pbc.315.2014.03.15.06.26.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Mar 2014 06:26:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of santosh.shukla@linaro.org) client-ip=209.85.192.178; Received: by mail-pd0-f178.google.com with SMTP id x10so3695603pdj.23 for ; Sat, 15 Mar 2014 06:26:30 -0700 (PDT) X-Received: by 10.68.185.1 with SMTP id ey1mr15084754pbc.33.1394889989900; Sat, 15 Mar 2014 06:26:29 -0700 (PDT) Received: from santosh-Latitude-E5530-non-vPro.mvista.com ([115.119.134.194]) by mx.google.com with ESMTPSA id ix2sm26051661pbc.45.2014.03.15.06.26.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Mar 2014 06:26:29 -0700 (PDT) From: Santosh Shukla To: lng-odp@linaro.org Cc: santosh shukla Subject: [lng-odp] [ODP/PATCH 1/2] timer : add cancel_tmo function. Date: Sat, 15 Mar 2014 18:56:16 +0530 Message-Id: <1394889977-31193-1-git-send-email-santosh.shukla@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Original-Sender: santosh.shukla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of santosh.shukla@linaro.org) smtp.mail=santosh.shukla@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: santosh shukla Signed-off-by: santosh shukla --- platform/linux-generic/source/odp_timer.c | 35 +++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/source/odp_timer.c b/platform/linux-generic/source/odp_timer.c index 4bcc479..b35d5e4 100644 --- a/platform/linux-generic/source/odp_timer.c +++ b/platform/linux-generic/source/odp_timer.c @@ -92,6 +92,39 @@ static timeout_t *rem_tmo(tick_t *tick) } +/** + * Cancel a timeout + * + * @param timer Timer + * @param tmo Timeout to cancel + * + * @return 0 if successful + */ +int odp_timer_cancel_tmo(odp_timer_t timer, odp_timer_tmo_t tmo) +{ + int id; + uint64_t abs_tick; + timeout_t *new_tmo; + tick_t *tick; + + /* get id */ + id = timer - 1; + + /* get tmo_buf to cancel */ + new_tmo = (timeout_t *)odp_buffer_addr(tmo); + new_tmo->tmo_tick = 0; /* reset tmo */ + abs_tick = new_tmo->tick; /* get the absolute + tick setted by prev add_tmo call */ + + tick = &odp_timer.timer[id].tick[abs_tick]; + if (rem_tmo(tick) == NULL) { + ODP_ERR("rem_tmo failed for timer-id %d tmo-id :%d tick-idx %lu\n", id, tmo, abs_tick); + return -1; + } + + return 0; +} + static void notify_function(union sigval sigval) { @@ -167,8 +200,6 @@ int odp_timer_init_global(void) odp_spinlock_init(&odp_timer.timer[0].tick[i].lock); timer_init(); - - return 0; }