public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCH v1 1/1] s390: Use string_upper() instead of open coded variant
Date: Fri,  1 Oct 2021 16:02:01 +0300	[thread overview]
Message-ID: <20211001130201.72545-1-andriy.shevchenko@linux.intel.com> (raw)

Use string_upper() from string helper module instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/s390/mm/cmm.c    | 11 ++++-------
 arch/s390/mm/extmem.c | 21 ++++++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index 1141c8d5c0d0..2203164b39da 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -14,8 +14,8 @@
 #include <linux/moduleparam.h>
 #include <linux/gfp.h>
 #include <linux/sched.h>
+#include <linux/string_helpers.h>
 #include <linux/sysctl.h>
-#include <linux/ctype.h>
 #include <linux/swap.h>
 #include <linux/kthread.h>
 #include <linux/oom.h>
@@ -394,13 +394,10 @@ static int __init cmm_init(void)
 		goto out_sysctl;
 #ifdef CONFIG_CMM_IUCV
 	/* convert sender to uppercase characters */
-	if (sender) {
-		int len = strlen(sender);
-		while (len--)
-			sender[len] = toupper(sender[len]);
-	} else {
+	if (sender)
+		string_upper(sender, sender);
+	else
 		sender = cmm_default_sender;
-	}
 
 	rc = smsg_register_callback(SMSG_PREFIX, cmm_smsg_target);
 	if (rc < 0)
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index 5060956b8e7d..2c8c5dc52472 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -12,12 +12,12 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/string_helpers.h>
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
-#include <linux/ctype.h>
 #include <linux/ioport.h>
 #include <linux/refcount.h>
 #include <linux/pgtable.h>
@@ -89,15 +89,18 @@ static int segext_scode = DCSS_SEGEXTX;
 static void
 dcss_mkname(char *name, char *dcss_name)
 {
+	/* Segment name is limited by 8 characters + NUL */
+	char tmp[8 + 1];
 	int i;
 
-	for (i = 0; i < 8; i++) {
-		if (name[i] == '\0')
-			break;
-		dcss_name[i] = toupper(name[i]);
-	}
-	for (; i < 8; i++)
-		dcss_name[i] = ' ';
+	/*
+	 * This snprintf() call does two things:
+	 * - makes a NUL-terminated copy of the input string
+	 * - pads it with spaces
+	 */
+	snprintf(tmp, sizeof(tmp), "%s        ", name);
+	string_upper(dcss_name, tmp);
+
 	ASCEBC(dcss_name, 8);
 }
 
@@ -109,7 +112,7 @@ dcss_mkname(char *name, char *dcss_name)
 static struct dcss_segment *
 segment_by_name (char *name)
 {
-	char dcss_name[9];
+	char dcss_name[8];
 	struct list_head *l;
 	struct dcss_segment *tmp, *retval = NULL;
 
-- 
2.33.0


             reply	other threads:[~2021-10-01 13:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 13:02 Andy Shevchenko [this message]
2021-10-04 20:31 ` [PATCH v1 1/1] s390: Use string_upper() instead of open coded variant Heiko Carstens
2021-10-05  8:18   ` Andy Shevchenko
2021-10-05  8:54     ` Heiko Carstens
2021-10-05 12:09       ` Andy Shevchenko
2021-10-11  8:21   ` David Laight
2021-10-11 10:09     ` Heiko Carstens
2021-10-12  8:04       ` David Laight
2021-10-12  9:12         ` Heiko Carstens
2021-10-07 18:07 ` Heiko Carstens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211001130201.72545-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=borntraeger@de.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox