* [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant
@ 2021-10-01 12:31 Andy Shevchenko
2021-10-01 13:31 ` Joe Perches
2021-10-05 18:23 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-10-01 12:31 UTC (permalink / raw)
To: Andy Shevchenko, Cai Huoqing, linux-rdma, linux-kernel
Cc: Mike Marciniszyn, Dennis Dalessandro, Doug Ledford, Jason Gunthorpe
Use string_upper() from string helper module instead of open coded variant.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fixed compilation error (Jason)
drivers/infiniband/hw/hfi1/efivar.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/efivar.c b/drivers/infiniband/hw/hfi1/efivar.c
index f275dd1abed8..e8ed05516bf2 100644
--- a/drivers/infiniband/hw/hfi1/efivar.c
+++ b/drivers/infiniband/hw/hfi1/efivar.c
@@ -3,7 +3,9 @@
* Copyright(c) 2015, 2016 Intel Corporation.
*/
-#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/string_helpers.h>
+
#include "efivar.h"
/* GUID for HFI1 variables in EFI */
@@ -112,7 +114,6 @@ int read_hfi1_efi_var(struct hfi1_devdata *dd, const char *kind,
char prefix_name[64];
char name[64];
int result;
- int i;
/* create a common prefix */
snprintf(prefix_name, sizeof(prefix_name), "%04x:%02x:%02x.%x",
@@ -128,10 +129,7 @@ int read_hfi1_efi_var(struct hfi1_devdata *dd, const char *kind,
* variable.
*/
if (result) {
- /* Converting to uppercase */
- for (i = 0; prefix_name[i]; i++)
- if (isalpha(prefix_name[i]))
- prefix_name[i] = toupper(prefix_name[i]);
+ string_upper(prefix_name, prefix_name);
snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
result = read_efi_var(name, size, return_data);
}
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant
2021-10-01 12:31 [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant Andy Shevchenko
@ 2021-10-01 13:31 ` Joe Perches
2021-10-01 13:48 ` Andy Shevchenko
2021-10-05 18:23 ` Jason Gunthorpe
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2021-10-01 13:31 UTC (permalink / raw)
To: Andy Shevchenko, Cai Huoqing, linux-rdma, linux-kernel, Vadim Pasternak
Cc: Mike Marciniszyn, Dennis Dalessandro, Doug Ledford, Jason Gunthorpe
On Fri, 2021-10-01 at 15:31 +0300, Andy Shevchenko wrote:
> Use string_upper() from string helper module instead of open coded variant.
Perhaps these string_upper and string_lower utility functions
should return dst not void so these functions could be used in
output calls.
So instead of:
+ string_upper(prefix_name, prefix_name);
snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
this could be consolidated:
snprintf(name, sizeof(name), "%s-%s", string_upper(prefix_name), kind);
Perhaps:
---
include/linux/string_helpers.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 68189c4a2eb11..ef92a9471f2a9 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -81,18 +81,26 @@ static inline int string_escape_str_any_np(const char *src, char *dst,
return string_escape_str(src, dst, sz, ESCAPE_ANY_NP, only);
}
-static inline void string_upper(char *dst, const char *src)
+static inline char *string_upper(char *dst, const char *src)
{
+ char *rtn = dst;
+
do {
*dst++ = toupper(*src);
} while (*src++);
+
+ return rtn;
}
-static inline void string_lower(char *dst, const char *src)
+static inline char *string_lower(char *dst, const char *src)
{
+ char *rtn = dst;
+
do {
*dst++ = tolower(*src);
} while (*src++);
+
+ return rtn;
}
char *kstrdup_quotable(const char *src, gfp_t gfp);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant
2021-10-01 13:31 ` Joe Perches
@ 2021-10-01 13:48 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-10-01 13:48 UTC (permalink / raw)
To: Joe Perches
Cc: Cai Huoqing, linux-rdma, linux-kernel, Vadim Pasternak,
Mike Marciniszyn, Dennis Dalessandro, Doug Ledford,
Jason Gunthorpe
On Fri, Oct 01, 2021 at 06:31:21AM -0700, Joe Perches wrote:
> On Fri, 2021-10-01 at 15:31 +0300, Andy Shevchenko wrote:
> > Use string_upper() from string helper module instead of open coded variant.
>
> Perhaps these string_upper and string_lower utility functions
> should return dst not void so these functions could be used in
> output calls.
Perhaps.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant
2021-10-01 12:31 [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant Andy Shevchenko
2021-10-01 13:31 ` Joe Perches
@ 2021-10-05 18:23 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2021-10-05 18:23 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Cai Huoqing, linux-rdma, linux-kernel, Mike Marciniszyn,
Dennis Dalessandro, Doug Ledford
On Fri, Oct 01, 2021 at 03:31:53PM +0300, Andy Shevchenko wrote:
> Use string_upper() from string helper module instead of open coded variant.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: fixed compilation error (Jason)
> drivers/infiniband/hw/hfi1/efivar.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-05 18:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 12:31 [PATCH v2 1/1] infiniband: hf1: Use string_upper() instead of open coded variant Andy Shevchenko
2021-10-01 13:31 ` Joe Perches
2021-10-01 13:48 ` Andy Shevchenko
2021-10-05 18:23 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).