From patchwork Fri Nov 23 00:53:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 13101 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 B869223E08 for ; Fri, 23 Nov 2012 00:57:32 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6A371A18BD3 for ; Fri, 23 Nov 2012 00:57:32 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so1228520ieb.11 for ; Thu, 22 Nov 2012 16:57:32 -0800 (PST) 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=8wYGoDRTVn0TyHtjMAFgcwOULPL8B/PY502Ct764dek=; b=FGjhm3jRVv9vQodUobF656vhvYAdIJpYXmnb4S0IJkExMAGzwtci4pCo7l+DvbScud fAPDcKiM0mBHa2GfZqccjLAYb1yVCNJf5cOfkSzWpP5ONuFR/mPavsemjlUVgRpRNeXi VEjTlLH6WdFaneEK0/VBU+TcBu+WpHH3hi1gQgRDdIg6TFxkk/t6Ma/9Zr7fphnbbANu vkaTirpnR4Irg9cTkOrtc0+oi9iVlI4cYI1meF974WxC8dTb1ojxHMrawjZeXe3mTYBR XH2xbvcwpXq3aONqHix7ibUwQ/pPZJV3WCwWKv2et4dRI68MMAOY+eYkwt7LXM5+Kx2p SSKQ== Received: by 10.50.42.168 with SMTP id p8mr2058117igl.57.1353632252215; Thu, 22 Nov 2012 16:57:32 -0800 (PST) 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 n20csp282679igt; Thu, 22 Nov 2012 16:57:31 -0800 (PST) Received: by 10.60.31.241 with SMTP id d17mr1615501oei.107.1353632250909; Thu, 22 Nov 2012 16:57:30 -0800 (PST) Received: from mail-ob0-f171.google.com (mail-ob0-f171.google.com [209.85.214.171]) by mx.google.com with ESMTPS id p7si4283227obj.94.2012.11.22.16.57.30 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 16:57:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.171 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.214.171; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.171 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-ob0-f171.google.com with SMTP id dn14so8871947obc.2 for ; Thu, 22 Nov 2012 16:57:30 -0800 (PST) Received: by 10.60.13.198 with SMTP id j6mr1659414oec.51.1353632250771; Thu, 22 Nov 2012 16:57:30 -0800 (PST) Received: from localhost (ip-64-134-239-153.public.wayport.net. [64.134.239.153]) by mx.google.com with ESMTPS id aw4sm3537759oec.9.2012.11.22.16.57.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Nov 2012 16:57:30 -0800 (PST) From: Anton Vorontsov To: Andrew Morton Cc: Jason Wessel , 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: Thu, 22 Nov 2012 16:53:53 -0800 Message-Id: <1353632036-5354-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.8.0 In-Reply-To: <20121123005315.GA12690@lizard.mcd25758.sjc.wayport.net> References: <20121123005315.GA12690@lizard.mcd25758.sjc.wayport.net> X-Gm-Message-State: ALoCoQm4w/gGFFIlMabvEjwH228vV9oCHFdkNC/zt3aQggXyaAmcuA6rDCytIPLq2Fl5p11c/iKB 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; }