From patchwork Thu Jul 26 14:26:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 10270 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 52CCD23E57 for ; Thu, 26 Jul 2012 14:28:55 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2337EA18F30 for ; Thu, 26 Jul 2012 14:28:55 +0000 (UTC) Received: by ghbz12 with SMTP id z12so2023378ghb.11 for ; Thu, 26 Jul 2012 07:28:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=h3VaWCXw15kF7+7bLlXFYTqFXPdbFxjP8X0PjeSLf7Q=; b=eEFlHJTr1Iy8L0jq94lcPHpTOlrPcORFctT7xjTJu5xPcD+vO5A+zVkmf8142Cm1jQ viC9hfaeE0KhiL6e9VvM2BhLi2ZvBcjLTVH9JF6LC1FVWg4DvrXhxxW7Z8iwA6HPK+hg wtvyUMbKzAkCckl2tOZUMzv058thu05Rz1KeEKqBzlLNAmTdfqsOKK/1OhSdQBshG5xP 9HkRHl5VEeVfkaNYT5ZCVRrB8gsqfWB1iAlwOAROu3C+WMUlqLhV1jbmhMADXtfIozVs KX1NltVj3a/vn7SQp4Q2fmclRVlmrqiYGO9Ap0jMNkX33qFcCMUGmUdPQknwWDXUY95q CLQg== Received: by 10.42.41.11 with SMTP id n11mr28481211ice.13.1343312934377; Thu, 26 Jul 2012 07:28:54 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp142661icc; Thu, 26 Jul 2012 07:28:54 -0700 (PDT) Received: by 10.236.75.132 with SMTP id z4mr27289781yhd.25.1343312933805; Thu, 26 Jul 2012 07:28:53 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id e22si21326433yhh.2.2012.07.26.07.28.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 07:28:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-yw0-f50.google.com with SMTP id j63so2356378yhj.37 for ; Thu, 26 Jul 2012 07:28:53 -0700 (PDT) Received: by 10.66.88.131 with SMTP id bg3mr21000971pab.16.1343312933148; Thu, 26 Jul 2012 07:28:53 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id gj10sm8082344pbc.18.2012.07.26.07.28.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 07:28:52 -0700 (PDT) From: Anton Vorontsov To: Jason Wessel Cc: Andrew Morton , Steven Rostedt , John Stultz , arve@android.com, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net Subject: [PATCH 4/7] kdb: Use KDB_REPEAT_* values as flags Date: Thu, 26 Jul 2012 07:26:28 -0700 Message-Id: <1343312791-9138-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120726142514.GA32158@lizard> References: <20120726142514.GA32158@lizard> X-Gm-Message-State: ALoCoQnbTSsA/El8ucT4hHwDXGd64pWpMbIdW35VD+R+jeQ/U2nnUkCyuc17dwo2gYSW8FGQBGBR The actual values of KDB_REPEAT_* enum values and overall logic stayed the same, but we now treat the values as flags. This makes it possible to add other flags and combine them, plus makes the code a lot simpler and shorter. But functionality-wise, there should be no changes. Signed-off-by: Anton Vorontsov --- include/linux/kdb.h | 4 ++-- kernel/debug/kdb/kdb_main.c | 21 +++++++-------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/linux/kdb.h b/include/linux/kdb.h index 4ab0936..0a047f9 100644 --- a/include/linux/kdb.h +++ b/include/linux/kdb.h @@ -34,8 +34,8 @@ extern atomic_t kdb_event; typedef enum { KDB_REPEAT_NONE = 0, /* Do not repeat this command */ - KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */ - KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */ + KDB_REPEAT_NO_ARGS = 0x1, /* Repeat the command w/o arguments */ + KDB_REPEAT_WITH_ARGS = 0x2, /* Repeat the command w/ its arguments */ } kdb_cmdflags_t; typedef int (*kdb_func_t)(int, const char **); diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index e9e33c1..c7d023a 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -991,20 +991,13 @@ int kdb_parse(const char *cmdstr) if (result && ignore_errors && result > KDB_CMD_GO) result = 0; KDB_STATE_CLEAR(CMD); - switch (tp->cmd_flags) { - case KDB_REPEAT_NONE: - argc = 0; - if (argv[0]) - *(argv[0]) = '\0'; - break; - case KDB_REPEAT_NO_ARGS: - argc = 1; - if (argv[1]) - *(argv[1]) = '\0'; - break; - case KDB_REPEAT_WITH_ARGS: - break; - } + + if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS) + return result; + + argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0; + if (argv[argc]) + *(argv[argc]) = '\0'; return result; }