From patchwork Wed Jan 7 22:24:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 42857 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F8AE2055F for ; Wed, 7 Jan 2015 22:24:46 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf3305678lam.2 for ; Wed, 07 Jan 2015 14:24:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=W3ntWOFHssuC47+KAw9szfJgKHcEcANThWfxbeMy2X0=; b=ccngSvWVMOR3eXw3MASNZSUDPTHkNG9zZ26odGIKdk0aOxyp8AZ3sfCkPU1nFvVS6Q R+pIVMhM3FpmHEZJNZjB0QDEQc808lYZpETb6rlxvhDZI/pvAa5EhfD2Mcwb6r2Ip4Xh qgNvoV/0hTTVOpah4xSLeFE8OV87Byh8rLGpplmaII75jS90a7guSlRGtZVbUvc5bDjI SwRipF9FnSAJUDRibUVZ565ZA77y8qDWCO7j6qPTJVtybdDpNjHk4vVDuLVlb171fWxw soRGKHQiHXuYtju2JP6mCwCHr7CkwHdkRmo5AtjqQTTXsrtRjFqg1jkCWKAMxQ7mLujz m+Gg== X-Gm-Message-State: ALoCoQnbsXaOWJZCa06gJldvBFgOPwwNKf6H5ZyvngLXJZoqkeUzn05hc9uLUhW6CxTGXAbGXEIT X-Received: by 10.152.120.194 with SMTP id le2mr10386lab.8.1420669484841; Wed, 07 Jan 2015 14:24:44 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.195 with SMTP id da3ls263229lac.32.gmail; Wed, 07 Jan 2015 14:24:44 -0800 (PST) X-Received: by 10.112.72.168 with SMTP id e8mr8812741lbv.83.1420669484700; Wed, 07 Jan 2015 14:24:44 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id v3si5288298lal.96.2015.01.07.14.24.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 14:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so6272762lab.12 for ; Wed, 07 Jan 2015 14:24:44 -0800 (PST) X-Received: by 10.152.26.201 with SMTP id n9mr8980365lag.50.1420669484518; Wed, 07 Jan 2015 14:24:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp80467lbb; Wed, 7 Jan 2015 14:24:43 -0800 (PST) X-Received: by 10.68.203.195 with SMTP id ks3mr9576088pbc.104.1420669482588; Wed, 07 Jan 2015 14:24:42 -0800 (PST) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com. [209.85.192.175]) by mx.google.com with ESMTPS id f2si5334974pas.147.2015.01.07.14.24.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 14:24:42 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.175 as permitted sender) client-ip=209.85.192.175; Received: by mail-pd0-f175.google.com with SMTP id g10so7254924pdj.6 for ; Wed, 07 Jan 2015 14:24:41 -0800 (PST) X-Received: by 10.70.34.196 with SMTP id b4mr9351687pdj.120.1420669481612; Wed, 07 Jan 2015 14:24:41 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id gm8sm2683866pbc.25.2015.01.07.14.24.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 14:24:40 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Corey Minyard , openipmi-developer@lists.sourceforge.net, Arnd Bergmann Subject: [PATCH v2 1/2] ipmi: Cleanup DEBUG_TIMING ifdef usage Date: Wed, 7 Jan 2015 14:24:28 -0800 Message-Id: <1420669469-3218-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420663910-6406-1-git-send-email-john.stultz@linaro.org> References: <1420663910-6406-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@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.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The driver uses #ifdef DEBUG_TIMING in order to conditionally print out timestamped debug messages. Unfortunately it adds the ifdefs all over the usage sites. This patch cleans it up by adding a debug_timestamp() function which is compiled out if DEBUG_TIMING isn't present. This cleans up all the ugly ifdefs in the function logic. Cc: Corey Minyard Cc: openipmi-developer@lists.sourceforge.net Cc: Arnd Bergmann Signed-off-by: John Stultz --- v2: Caught a missed DEBUG_TIMING ifdef drivers/char/ipmi/ipmi_si_intf.c | 61 ++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 967b73a..e54c02b 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -321,6 +321,18 @@ static int try_smi_init(struct smi_info *smi); static void cleanup_one_si(struct smi_info *to_clean); static void cleanup_ipmi_si(void); +#ifdef DEBUG_TIMING +void debug_timestamp(char *msg) +{ + struct timeval t; + + do_gettimeofday(&t); + pr_debug("**%s: %d.%9.9d\n", msg, t.tv_sec, t.tv_usec); +} +#else +#define debug_timestamp(x) +#endif + static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); static int register_xaction_notifier(struct notifier_block *nb) { @@ -358,9 +370,6 @@ static void return_hosed_msg(struct smi_info *smi_info, int cCode) static enum si_sm_result start_next_msg(struct smi_info *smi_info) { int rv; -#ifdef DEBUG_TIMING - struct timeval t; -#endif if (!smi_info->waiting_msg) { smi_info->curr_msg = NULL; @@ -370,10 +379,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) smi_info->curr_msg = smi_info->waiting_msg; smi_info->waiting_msg = NULL; -#ifdef DEBUG_TIMING - do_gettimeofday(&t); - printk(KERN_DEBUG "**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("Start2"); err = atomic_notifier_call_chain(&xaction_notifier_list, 0, smi_info); if (err & NOTIFY_STOP_MASK) { @@ -582,12 +588,8 @@ static void check_bt_irq(struct smi_info *smi_info, bool irq_on) static void handle_transaction_done(struct smi_info *smi_info) { struct ipmi_smi_msg *msg; -#ifdef DEBUG_TIMING - struct timeval t; - do_gettimeofday(&t); - printk(KERN_DEBUG "**Done: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("Done"); switch (smi_info->si_state) { case SI_NORMAL: if (!smi_info->curr_msg) @@ -929,17 +931,11 @@ static void sender(void *send_info, struct smi_info *smi_info = send_info; enum si_sm_result result; unsigned long flags; -#ifdef DEBUG_TIMING - struct timeval t; -#endif BUG_ON(smi_info->waiting_msg); smi_info->waiting_msg = msg; -#ifdef DEBUG_TIMING - do_gettimeofday(&t); - printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("Enqueue"); if (smi_info->run_to_completion) { /* @@ -1128,15 +1124,10 @@ static void smi_timeout(unsigned long data) unsigned long jiffies_now; long time_diff; long timeout; -#ifdef DEBUG_TIMING - struct timeval t; -#endif spin_lock_irqsave(&(smi_info->si_lock), flags); -#ifdef DEBUG_TIMING - do_gettimeofday(&t); - printk(KERN_DEBUG "**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("Timer"); + jiffies_now = jiffies; time_diff = (((long)jiffies_now - (long)smi_info->last_timeout_jiffies) * SI_USEC_PER_JIFFY); @@ -1173,18 +1164,13 @@ static irqreturn_t si_irq_handler(int irq, void *data) { struct smi_info *smi_info = data; unsigned long flags; -#ifdef DEBUG_TIMING - struct timeval t; -#endif spin_lock_irqsave(&(smi_info->si_lock), flags); smi_inc_stat(smi_info, interrupts); -#ifdef DEBUG_TIMING - do_gettimeofday(&t); - printk(KERN_DEBUG "**Interrupt: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("Interrupt"); + smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags); return IRQ_HANDLED; @@ -2038,18 +2024,13 @@ static u32 ipmi_acpi_gpe(acpi_handle gpe_device, { struct smi_info *smi_info = context; unsigned long flags; -#ifdef DEBUG_TIMING - struct timeval t; -#endif spin_lock_irqsave(&(smi_info->si_lock), flags); smi_inc_stat(smi_info, interrupts); -#ifdef DEBUG_TIMING - do_gettimeofday(&t); - printk("**ACPI_GPE: %d.%9.9d\n", t.tv_sec, t.tv_usec); -#endif + debug_timestamp("ACPI_GPE"); + smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags);