@@ -28,6 +28,7 @@
#include <linux/list.h>
#include <linux/overflow.h>
#include <linux/sched.h>
+#include <linux/string-choice.h>
#include <linux/types.h>
#include <linux/workqueue.h>
@@ -395,21 +396,6 @@ wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms)
#define MBps(x) KBps(1000 * (x))
#define GBps(x) ((u64)1000 * MBps((x)))
-static inline const char *yesno(bool v)
-{
- return v ? "yes" : "no";
-}
-
-static inline const char *onoff(bool v)
-{
- return v ? "on" : "off";
-}
-
-static inline const char *enableddisabled(bool v)
-{
- return v ? "enabled" : "disabled";
-}
-
static inline void add_taint_for_CI(unsigned int taint)
{
/*
@@ -35,6 +35,7 @@
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/string_helpers.h>
+#include <linux/string-choice.h>
#include <linux/sort.h>
#include <linux/ctype.h>
@@ -2023,17 +2024,6 @@ static const struct file_operations rss_debugfs_fops = {
/* RSS Configuration.
*/
-/* Small utility function to return the strings "yes" or "no" if the supplied
- * argument is non-zero.
- */
-static const char *yesno(int x)
-{
- static const char *yes = "yes";
- static const char *no = "no";
-
- return x ? yes : no;
-}
-
static int rss_config_show(struct seq_file *seq, void *v)
{
struct adapter *adapter = seq->private;
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/device.h>
+#include <linux/string-choice.h>
#include <asm/byteorder.h>
#include "usb.h"
@@ -19,11 +20,6 @@
#define USB_MAXCONFIG 8 /* Arbitrary limit */
-static inline const char *plural(int n)
-{
- return (n == 1 ? "" : "s");
-}
-
static int find_next_descriptor(unsigned char *buffer, int size,
int dt1, int dt2, int *num_skipped)
{
@@ -21,14 +21,10 @@
#include <linux/usb.h>
#include <linux/usb/hcd.h>
+#include <linux/string-choice.h>
#include <uapi/linux/usb/audio.h>
#include "usb.h"
-static inline const char *plural(int n)
-{
- return (n == 1 ? "" : "s");
-}
-
static int is_rndis(struct usb_interface_descriptor *desc)
{
return desc->bInterfaceClass == USB_CLASS_COMM
@@ -1029,4 +1029,5 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
/* OTHER_WRITABLE? Generally considered a bad idea. */ \
BUILD_BUG_ON_ZERO((perms) & 2) + \
(perms))
+
#endif
new file mode 100644
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __STRING_CHOICE_H__
+#define __STRING_CHOICE_H__
+
+#include <linux/types.h>
+
+const char *yesno(bool v);
+const char *onoff(bool v);
+const char *enableddisabled(bool v);
+const char *plural(long v);
+
+#endif /* __STRING_CHOICE_H__ */
@@ -46,7 +46,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
bsearch.o find_bit.o llist.o memweight.o kfifo.o \
percpu-refcount.o rhashtable.o \
once.o refcount.o usercopy.o errseq.o bucket_locks.o \
- generic-radix-tree.o
+ generic-radix-tree.o string-choice.o
obj-$(CONFIG_STRING_SELFTEST) += test_string.o
obj-y += string_helpers.o
obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
new file mode 100644
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include <linux/export.h>
+#include <linux/string-choice.h>
+
+const char *yesno(bool v)
+{
+ return v ? "yes" : "no";
+}
+EXPORT_SYMBOL(yesno);
+
+const char *onoff(bool v)
+{
+ return v ? "on" : "off";
+}
+EXPORT_SYMBOL(onoff);
+
+const char *enableddisabled(bool v)
+{
+ return v ? "enabled" : "disabled";
+}
+EXPORT_SYMBOL(enableddisabled);
+
+const char *plural(long v)
+{
+ return v == 1 ? "" : "s";
+}
+EXPORT_SYMBOL(plural);