From patchwork Sat Aug 31 09:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13786009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F3B0CD1293 for ; Sat, 31 Aug 2024 09:50:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45D9E8D0021; Sat, 31 Aug 2024 05:50:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 408BA8D0008; Sat, 31 Aug 2024 05:50:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 259BD8D0021; Sat, 31 Aug 2024 05:50:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0B5918D0008 for ; Sat, 31 Aug 2024 05:50:34 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8778140B6C for ; Sat, 31 Aug 2024 09:50:33 +0000 (UTC) X-FDA: 82512070746.01.AD72B73 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 272E1C0007 for ; Sat, 31 Aug 2024 09:50:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=lihongbo22@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725097740; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xevtnFxrFNx+IxIvJSXWm1eWTJiUmJBGup/yMvpHDhE=; b=oz5SA1CEjEXVvRFuglDYHOA3Vo57okoi48aTSDP7LaYWMRDS/1KFrnAPb6Pd1xVf37V6LV HOfpb8acFizhjHhadaprXXGDKQcIx/K87Kfz1As+fyg4tDoEcpoMdWDxqltG0Q/9SkM1J6 i5hfIxyVjXLGjPg6lLrx1B0u7ZCCfIs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725097740; a=rsa-sha256; cv=none; b=nCiOdUqvOXXOClB3PR0mutFnh02fzuIzyy2xuQwhA9tq7VF/PikMFeHGVO/e7GAzXvZXMQ kmR5xvzM8bcCedcElnwIj0NzFoXe7bSUXT4Ph/CMEhgS5SLLuuf4+jmk9tWAJZFhR7eQxR D7Whm/5mdiotsuC6hLko+XohQfkYoyo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of lihongbo22@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=lihongbo22@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WwqxY3TBzzyRJF; Sat, 31 Aug 2024 17:49:53 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 19283180100; Sat, 31 Aug 2024 17:50:27 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 31 Aug 2024 17:50:26 +0800 From: Hongbo Li To: , , , , , , , , CC: , , , Subject: [PATCH -next 1/4] lib/string_choices: Introduce several opposite string choice helpers Date: Sat, 31 Aug 2024 17:58:37 +0800 Message-ID: <20240831095840.4173362-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240831095840.4173362-1-lihongbo22@huawei.com> References: <20240831095840.4173362-1-lihongbo22@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-Stat-Signature: f99dbu4zcqswyctjzkypad7iky9x4pqx X-Rspamd-Queue-Id: 272E1C0007 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725097830-452095 X-HE-Meta: U2FsdGVkX19cS+eR/VH2WrwacgXTk2Zfl0COYJ+Sq0dmupdhJiUaArLUBbdQa91V24+236T0Qk8jrbOFrCAV6zvWmR3W6WlFjlEU9tJjYPqovJaZn0HoXh/4hi6hN2qfPtVl87avSN8zJcwI1muofJMBLixrsW92WfsXG9u9vDfsLJ7/3DcAmaUPqpOq1VKTW5ll6+nTXqz7MjXqIX1oGyFnmnJ7h8Yj0pPdFb5+vrx7EdH4YU1+pYhUn+mcRSH/qeSK0y0oJFMMCYmPdUr2kWmUfliPDwKVuTHNQ/349Q/+VMubETgjg5zOgqCm3VEZAGQEf1A577XdvHBKJg4t7yBy+fP2ki1Ra6jZI2mpd0kG9zcGQ0WXvtiLNSbn9ev3Z/U9Mac6dcx9wAI4HPMn4ijPr/pqVvNXZEszmWEaILJ2Anxctg+rJNP3eUB90JB/nTmlLkZOfyMLgOkivEs32qI0SKPaMP5MpmSY8WbHooZBkMUa9NoT4ZVtyD0ux16o/BqAfJNZo0L2y2skwW6Ur6QAmSP9Fcgm1Mz4rFItwDWSbVJx7CLwu04ReNdZlNLrVYX1goGLzJJiSWZocP8CECy0qj2WEiH8q6xZKHxE18JEifasgUkHkOXI0D/d10RnsB3yeBd8XnGtGpj5EAW1u7t1n/T9JfT/AeAenUocvLAZf/VXW0g/WpgcOLMr+9VXOxty1YSyr2z1YU84LoRWjISPY27RhoeCO3NvbP0oYclEgFDdq3CaPuAh6sLvvTUSSksdnfyz48EqxvdF2J630tSi5GeG9iNnylkYmHvUG52e3JT7tXsiGJad/brRcwTb5Q3vxkbVCpA+pj8hw42RG3PQvU5nuAodqsQ9AItWfe5KF7Rc2Gp257IR6+1ms7QWbSuMWiMBekIVTbmnJ4bEtcPQauVQQEStEPdYQjfudpiG3G85c/xLj00PteDe9ENo+y7Mk9ZFagVp3et5of7 6EtLmpEn MUrb/RXRmBpyBdRI4evtZoLjIrbzSloQorMsld40foJ5KmcPWXZZ37doR105m4bP00UnfaGomyrPliJl1Z4EsnDDDL17GR6QItQS84ORnINAE5Uoh3O2c21/m8g05rFIKykFk7QgGtDYunCCbOZ+5Zj1wfOysuYNiTh/XlTyiR0Sc+jx1yNpiqcqoGFMUlUzVF5b/UYv1/UgSikiQo0YsJ89iLndb1pUbAuT41jdRm1S9Ukfo6trDjveiS78a2eEgq6fjPxLno/fk55k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000143, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Similar to the exists helper: str_enable_disable/ str_enabled_disabled/str_on_off/str_yes_no helpers, we can add the opposite helpers. That's str_disable_enable, str_disabled_enabled, str_off_on and str_no_yes. There are more than 10 cases currently (expect str_disable_enable now has 3 use cases) exist in the code can be replaced with these helper. Signed-off-by: Hongbo Li --- include/linux/string_choices.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index f3670dbd1169..c2134eeda1fd 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -8,11 +8,13 @@ static inline const char *str_enable_disable(bool v) { return v ? "enable" : "disable"; } +#define str_disable_enable(v) str_enable_disable(!(v)) static inline const char *str_enabled_disabled(bool v) { return v ? "enabled" : "disabled"; } +#define str_disabled_enabled(v) str_enabled_disabled(!(v)) static inline const char *str_hi_lo(bool v) { @@ -36,11 +38,13 @@ static inline const char *str_on_off(bool v) { return v ? "on" : "off"; } +#define str_off_on(v) str_on_off(!(v)) static inline const char *str_yes_no(bool v) { return v ? "yes" : "no"; } +#define str_no_yes(v) str_yes_no(!(v)) static inline const char *str_true_false(bool v) {