From patchwork Wed Mar 11 12:15:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 45629 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B598E214BF for ; Wed, 11 Mar 2015 12:16:29 +0000 (UTC) Received: by lbvn10 with SMTP id n10sf6376658lbv.1 for ; Wed, 11 Mar 2015 05:16:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=D4xSaHYPPmwMYuzDSf07uQymESrPaj7V7xQHUcrUGR0=; b=bNoh5Sc17y8woac8MrxxM7W59pdTu/CAkS75QoTHiTSFzS6bg1EFZYbqLBscSYTajH g4bOezwtwlW64e602cUS+dozt6+SoIqEKskjzQc/xIErsoXypqTKopHb6v0aM7O29gcT ePE5WuwSYOkD3B2OSpGADit9SKSc7xK50ZyM9fV1OedzU6A3wEnma2TV7nAP8PUu7LQg mqPFgfk1Py0Tgbx98PXESHrOS+iI2qGprI4OHP/NGWSOphnUjSFuD8I3NobitngTJVtE dk3eRrXEdVhcmYwhd7Gzs+B20qtogRkErOj/DjWQaoNb0nyp3m6fsVygKDBN7Plwd/VR bR0g== X-Gm-Message-State: ALoCoQlvbystfrV6TEazQcQ2v7SEZ37LEL25RC73SD+zLqQMFXsFJAbzT7xoQah/ZelsQ7JyaSJN X-Received: by 10.152.27.134 with SMTP id t6mr5438113lag.5.1426076188702; Wed, 11 Mar 2015 05:16:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.99 with SMTP id lf3ls152653lac.4.gmail; Wed, 11 Mar 2015 05:16:28 -0700 (PDT) X-Received: by 10.152.10.209 with SMTP id k17mr4907199lab.50.1426076188422; Wed, 11 Mar 2015 05:16:28 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id w3si2218420lag.108.2015.03.11.05.16.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 05:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labge10 with SMTP id ge10so7850177lab.10 for ; Wed, 11 Mar 2015 05:16:28 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr34559266lab.86.1426076187994; Wed, 11 Mar 2015 05:16:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2737638lbj; Wed, 11 Mar 2015 05:16:26 -0700 (PDT) X-Received: by 10.140.41.113 with SMTP id y104mr45161766qgy.25.1426076185995; Wed, 11 Mar 2015 05:16:25 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id e184si3209150qhc.78.2015.03.11.05.16.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Mar 2015 05:16:25 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVfYh-0005lg-1I; Wed, 11 Mar 2015 12:16:19 +0000 Received: from mail-la0-f50.google.com ([209.85.215.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVfYY-0005ko-8Q for lng-odp@lists.linaro.org; Wed, 11 Mar 2015 12:16:10 +0000 Received: by labgd6 with SMTP id gd6so8313826lab.3 for ; Wed, 11 Mar 2015 05:16:04 -0700 (PDT) X-Received: by 10.112.92.198 with SMTP id co6mr6278661lbb.101.1426076164495; Wed, 11 Mar 2015 05:16:04 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-169-66.pppoe.mtu-net.ru. [91.76.169.66]) by mx.google.com with ESMTPSA id a2sm615477lbm.32.2015.03.11.05.16.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Mar 2015 05:16:03 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 11 Mar 2015 15:15:46 +0300 Message-Id: <1426076147-10053-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426076147-10053-1-git-send-email-maxim.uvarov@linaro.org> References: <1426076147-10053-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCH 2/3] linux-geneirc: timer: remove ifdefs inside function from timer_cancel X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Using ifdefs inside function make it hard to read. No functional changes. Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_timer.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 8b04bd2..33c2758 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -467,15 +467,16 @@ static bool timer_reset(uint32_t idx, return success; } + +#ifdef ODP_ATOMIC_U128 static odp_buffer_t timer_cancel(odp_timer_pool *tp, uint32_t idx, uint64_t new_state) { tick_buf_t *tb = &tp->tick_buf[idx]; odp_buffer_t old_buf; - -#ifdef ODP_ATOMIC_U128 tick_buf_t new, old; + /* Update the timer state (e.g. cancel the current timeout) */ new.exp_tck.v = new_state; /* Swap out the old buffer */ @@ -485,7 +486,18 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, (_uint128_t *)&new, (_uint128_t *)&old, _ODP_MEMMODEL_RLX); old_buf = old.tmo_buf; + + /* Return the old buffer */ + return old_buf; +} #else +static odp_buffer_t timer_cancel(odp_timer_pool *tp, + uint32_t idx, + uint64_t new_state) +{ + tick_buf_t *tb = &tp->tick_buf[idx]; + odp_buffer_t old_buf; + /* Take a related lock */ while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ @@ -501,10 +513,11 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, /* Release the lock */ _odp_atomic_flag_clear(IDX2LOCK(idx)); -#endif + /* Return the old buffer */ return old_buf; } +#endif static int post_timeout_to_queue(odp_queue_t queue, odp_buffer_t tmo_buf, uint64_t exp_tck)