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: 13786015 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35217175D2D; Sat, 31 Aug 2024 09:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097830; cv=none; b=jzBqOPCBUo7nUqgQ82DS672e+67prN/AcyAWejdWWgacEXQVYEiKLJqDeHD0zt8xZELAuxivGjJyGIXC3Fce44BCuHQCGJZN/LE/wt7WyzuJ3xry+nOsbhB+9aK1JGKHpjIusshCIYxbZLaElz/tmV/JKIjNV6G3rbGEi3Q+9ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097830; c=relaxed/simple; bh=yXFV9kxjDtuf8D75RcUN9npkhbqNaK2uQv+W214LqnA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W7EyopWs5kRXNMTSn6K3be1d6bfhvd3GAa4kTe2QlclBBv2ydJS3oXRADCO4uEou6SSIAaA9xwB1+XU4+FvcA0cyB4EMY3AeKsGSjZ9IDraDAKp5NgwXdLK8AAgIE6OVwphHW8HME8pjl+kijgVkmRPPsmozyufiyIe18xitI/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) 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) { From patchwork Sat Aug 31 09:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13786014 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3526B176AD0; Sat, 31 Aug 2024 09:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097830; cv=none; b=FOlylB7H12BSL9q6lIDJOOe7mSzSqabgRQxNF0E8kqeGt7SypDJ03nBGzCSUPx0P+E+Cl1QBu3n3v4RP6vT1ocX/t1W96s662YVlaeH9ruieaCY8E2AyIQDcXk6L8oQHjXvZ9rJybObGzMwBosPErXfbarmlBHmnWtkK3zBcAuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097830; c=relaxed/simple; bh=dvDnNfvlrmikGC1g3M2IDw79MLn4ccZWUJEaVJ87jq0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d8y6SnE9ZRrGmeGsMwgkF4FpNFXYjCkoIH34QIik+kVHAAIfJKfcU7nR/ihddmrZ34oe9c3BRYPkTAGgyCCU7yFZIbJKcVIxyLbVzPc3YPkA5KwZdCnFXGT/lsjsds9GPzRoAihS6D9tjOFdKqgDAbnQOA8qs+3c4O5fm91/ev8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WwqxB6N7fzyQxV; Sat, 31 Aug 2024 17:49:34 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 439BD1800CF; 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:27 +0800 From: Hongbo Li To: , , , , , , , , CC: , , , Subject: [PATCH -next 2/4] tun: Make use of str_disabled_enabled helper Date: Sat, 31 Aug 2024 17:58:38 +0800 Message-ID: <20240831095840.4173362-3-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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-Patchwork-Delegate: kuba@kernel.org Use str_disabled_enabled() helper instead of open coding the same. Signed-off-by: Hongbo Li --- drivers/net/tun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 6fe5e8f7017c..29647704bda8 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3178,7 +3178,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, /* [unimplemented] */ netif_info(tun, drv, tun->dev, "ignored: set checksum %s\n", - arg ? "disabled" : "enabled"); + str_disabled_enabled(arg)); break; case TUNSETPERSIST: From patchwork Sat Aug 31 09:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13786016 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E70D178381; Sat, 31 Aug 2024 09:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097832; cv=none; b=G+a3mgDTr6Bg2eAlB+hY1KoD7Fnx9Ss7WH09ZqX/LBpwWBSagE2N3tVGU3HcNuNanZstYCjq9KylZ02jFLzxT1PMrmduaiTkkmR/qK4bvgRY9tdRrO7rG//GISLYnTRVhSfvvXbatS4ZRzRt2wLPvBsfKK9oLnTrhEbKGDQxluU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097832; c=relaxed/simple; bh=mdDMrlLBsuu4XFK1sszaYnYvrYYq6Nt1llkaa/8V4pA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iG1aA96oCgxSud1xBosxCKICZeQ/vNm1g6FlckYbeF45i/WU190eaIJeYuTdQf5t2cwxGOYQaUC9Kz2DvuRP1eSLfSs+6giv4upZOpcI8TkLPGuorhr4HR4vnOcmlnhgasQmpJVWGUXG+nm2LqFrUSTucIerDuryl0O443Nn/28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WwqxC0Vg7zyQxW; Sat, 31 Aug 2024 17:49:35 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 6D07D18006C; 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:27 +0800 From: Hongbo Li To: , , , , , , , , CC: , , , Subject: [PATCH -next 3/4] mm: page_alloc: Make use of str_off_on helper Date: Sat, 31 Aug 2024 17:58:39 +0800 Message-ID: <20240831095840.4173362-4-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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) The helper str_off_on is introduced to reback "off/on" string literal. We can use str_off_on() helper instead of open coding the same. Signed-off-by: Hongbo Li --- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 04a90dfbce09..8adda0b67253 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5517,10 +5517,9 @@ void __ref build_all_zonelists(pg_data_t *pgdat) page_group_by_mobility_disabled = 1; else page_group_by_mobility_disabled = 0; - pr_info("Built %u zonelists, mobility grouping %s. Total pages: %ld\n", nr_online_nodes, - page_group_by_mobility_disabled ? "off" : "on", + str_off_on(page_group_by_mobility_disabled), vm_total_pages); #ifdef CONFIG_NUMA pr_info("Policy zone: %s\n", zone_names[policy_zone]); From patchwork Sat Aug 31 09:58:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13786017 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B53F9176AD0; Sat, 31 Aug 2024 09:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097833; cv=none; b=rELqUa+9Azys7dFYWdk5lBq4tl2oABXev1f+Lw5ee84Uso0YhF3Tj4JDBew89jKDXBe72GhcxgIr/fSj3wjeyvx/9Z6Rqa8cslOWj4QzaZY4bvhrdRe2/9gy1ORhmEJanRkW2GOGL3VSjbTrgaQIOcx70SFZ1zUGbHJr9IDYMng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725097833; c=relaxed/simple; bh=zU+OpwBs8xhHjPAevDr+3dwi/iy2BW9P6RL91Jj4ua8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=plUqU2gGd6H+pRT1eA95HyTkrSx2ymzB71IcMrAaPWeAkZMVwN8NW/LfRKoynDYAgif1+CJCx2P8B5N7MGxTxIzY68oWohulPlnDbP5dlhMV2+ojCESTAzaObwbsuQvePYAyDUq5KfCbicXkdrndNMm+pjjiAS7w0xocftylr+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Wwqxv6JD6z1S8Kb; Sat, 31 Aug 2024 17:50:11 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 98D901A016C; 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:27 +0800 From: Hongbo Li To: , , , , , , , , CC: , , , Subject: [PATCH net-next 4/4] net: sock: Make use of str_no_yes() helper Date: Sat, 31 Aug 2024 17:58:40 +0800 Message-ID: <20240831095840.4173362-5-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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500022.china.huawei.com (7.185.36.66) X-Patchwork-Delegate: kuba@kernel.org The helper str_no_yes is introduced to reback "no/yes" string literal. We can use str_no_yes() helper instead of open coding the same. Signed-off-by: Hongbo Li --- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index 542bc5462cb5..f976bb4a402f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -4086,7 +4086,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto) sock_prot_memory_allocated(proto), sock_prot_memory_pressure(proto), proto->max_header, - proto->slab == NULL ? "no" : "yes", + str_no_yes(proto->slab == NULL), module_name(proto->owner), proto_method_implemented(proto->close), proto_method_implemented(proto->connect),