The return value of strcmp(3) being reversed makes it prone to mistakes. Since most of the time we're only interested in simple equality, add this API for those cases. This removes some driver-specific definitions of streq(3). Signed-off-by: Alejandro Colomar --- drivers/clk/socfpga/clk-gate-a10.c | 2 -- drivers/clk/socfpga/clk.h | 1 - include/linux/string.h | 12 ++++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c index ba12179061b3..df9f660db8a0 100644 --- a/drivers/clk/socfpga/clk-gate-a10.c +++ b/drivers/clk/socfpga/clk-gate-a10.c @@ -11,8 +11,6 @@ #include "clk.h" -#define streq(a, b) (strcmp((a), (b)) == 0) - #define to_socfpga_gate_clk(p) container_of(p, struct socfpga_gate_clk, hw.hw) /* SDMMC Group for System Manager defines */ diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h index 9a2fb2dde5b8..2008e6f34a5d 100644 --- a/drivers/clk/socfpga/clk.h +++ b/drivers/clk/socfpga/clk.h @@ -19,7 +19,6 @@ #define SOCFPGA_MAX_PARENTS 5 -#define streq(a, b) (strcmp((a), (b)) == 0) #define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \ ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0)) diff --git a/include/linux/string.h b/include/linux/string.h index 6cb5cdd01158..9b3e578d9aca 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -14,6 +14,18 @@ #include #include +/** + * streq - strings equal + * + * @s1: string to compare + * @s2: string to compare + * + * Compare two strings for equality. + * + * Return: true iff the strings are equal + */ +#define streq(s1, s2) (strcmp(s1, s2) == 0) + extern char *strndup_user(const char __user *, long); extern void *memdup_user(const void __user *, size_t) __realloc_size(2); extern void *vmemdup_user(const void __user *, size_t) __realloc_size(2); -- 2.55.0