From patchwork Tue Oct 16 01:18:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 12258 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 7882F23E29 for ; Tue, 16 Oct 2012 01:21:21 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 22321A1914B for ; Tue, 16 Oct 2012 01:21:21 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so4084969iag.11 for ; Mon, 15 Oct 2012 18:21:20 -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=aHR2phN9w510xMmRR+GC+gax49T2CuYOKzlZTuuaoQ8=; b=B+x8oc2sARsO6vBOITB8+NS3VJ0fMbW+iGR2k9nzx64qTxE4SDYKqxy2QuAtQJMu/i /aN77H47+iEIn0lBmYD0IsEqYVk+zWk4LYERx1pripXcmR0EIlR1QdUy/tNLdqH5Xzet mEN3M9nLmzId8POa46v3jbXRy1JYqD3PTu63MFswkfIZfVxeZK5ws/tXQ5M6UeI8KFfr NEI4GnkHSyOnnvFDdaqDxXPbnWEnlEw0owJRWzQmeikGU/Qzf51yVJkthgQaswM5UBfq JJ6yDqlAZI3Gz/6GmRfF91WEH7+ykif/f8EUl5AOo7z3neXck9xZkEPvaguIJyTuC7I6 6QNw== Received: by 10.50.161.169 with SMTP id xt9mr8866144igb.62.1350350480927; Mon, 15 Oct 2012 18:21:20 -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.50.67.148 with SMTP id n20csp659665igt; Mon, 15 Oct 2012 18:21:20 -0700 (PDT) Received: by 10.68.238.34 with SMTP id vh2mr42668494pbc.6.1350350480194; Mon, 15 Oct 2012 18:21:20 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id bo5si24221630pab.189.2012.10.15.18.21.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 18:21:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.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-pa0-f50.google.com with SMTP id hz11so5970977pad.37 for ; Mon, 15 Oct 2012 18:21:20 -0700 (PDT) Received: by 10.66.84.131 with SMTP id z3mr3826415pay.34.1350350479984; Mon, 15 Oct 2012 18:21:19 -0700 (PDT) Received: from localhost (ip-64-134-230-8.public.wayport.net. [64.134.230.8]) by mx.google.com with ESMTPS id e9sm8866785paz.28.2012.10.15.18.21.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 18:21:19 -0700 (PDT) From: Anton Vorontsov To: Jason Wessel Cc: Colin Cross , Alan Cox , John Stultz , 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: Mon, 15 Oct 2012 18:18:02 -0700 Message-Id: <1350350285-3095-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.12.3 In-Reply-To: <20121016011724.GB23146@lizard> References: <20121016011724.GB23146@lizard> X-Gm-Message-State: ALoCoQkhGHMgULegW4HlDvuxai9fh4KIYj04rep8bboqZIJznIKzbmF1OsAHgzRtGcCOZt91mby8 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 0142cd3..c6f1ec3 100644 --- a/include/linux/kdb.h +++ b/include/linux/kdb.h @@ -15,8 +15,8 @@ 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 bae9a1d..7245bab 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -992,20 +992,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; }