lib/string: add memrchr function
PATCH 1/2 lib/string: add memrchr function
Here is the detailed description for memrchr:
void *memrchr(const void *s, int c, size_t n);
The memrchr() function is like the memchr() function, except that it searches backward from the end of the n bytes pointed to by s instead of forward from the beginning.
The memrchr() functions return a pointer to the matching byte or NULL if the character does not occur in the given memory area.
--- include/linux/string.h | 1 + lib/string.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+)
include/linux/string.h +1 -0
@@ -167,6 +167,7 @@ static inline void memcpy_flushcache(void *dst, const void *src, size_t cnt) memcpy(dst, src, cnt); }#endif +void *memrchr (const void *s,int c,size_t n);void *memchr_inv (const void *s,int c,size_t n);char *strreplace (char *s,char old,char new);
lib/string.c +21 -0
@@ -964,6 +964,27 @@ void *memchr(const void *s, int c, size_t n)EXPORT_SYMBOL (memchr);#endif +/** +* memrchr - Find a character in an area of memory. +* @s: The memory area +* @c: The byte to search for +* @n: The size of the area. +* +* returns the address of the last occurrence of @c, or %NULL +* if @c is not found +*/ +void *memrchr (const void *s,int c,size_t n) +{ +const unsigned char *p = s + n; + +while (n-- !=0 ) { +if ((unsigned char )c == *--p) +return (void *)p; + } +return NULL ; +} +EXPORT_SYMBOL (memrchr); +static void *check_bytes8 (const u8 *start,u8 value,unsigned int bytes) {while (bytes) {
Signature · 1 line
2.7.4
PATCH 2/2 rpmsg: add syslog redirection driver
From: Guiding Li <[email protected]>
This driver allows the remote processor redirect the output of syslog/printf into the kernel log, which is very useful to see what happen in the remote side.
--- drivers/rpmsg/Kconfig | 12 ++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 163 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.c
drivers/rpmsg/Kconfig +12 -0
@@ -15,6 +15,18 @@ config RPMSG_CHAR in /dev. They make it possible for user-space programs to send and receive rpmsg packets. +config RPMSG_SYSLOG + tristate "RPMSG syslog redirection" + depends on RPMSG + help + Say Y here to redirect the syslog/printf from remote processor into + the kernel log which is very useful to see what happen in the remote + side. + + If the remote processor hang during bootup or panic at the runtime, + We can even cat /sys/kernel/debug/remoteproc/remoteprocX/trace0 to + get the last log which doesn't output yet. + config RPMSG_QCOM_GLINK_NATIVE tristate select RPMSG
drivers/rpmsg/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_RPMSG) += rpmsg_core.o obj-$(CONFIG_RPMSG_CHAR) += rpmsg_char.o +obj-$(CONFIG_RPMSG_SYSLOG) += rpmsg_syslog.o obj-$(CONFIG_RPMSG_QCOM_GLINK_RPM) += qcom_glink_rpm.o obj-$(CONFIG_RPMSG_QCOM_GLINK_NATIVE) += qcom_glink_native.o obj-$(CONFIG_RPMSG_QCOM_GLINK_SMEM) += qcom_glink_smem.o
drivers/rpmsg/rpmsg_syslog.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 2/2] rpmsg: add syslog redirection driver
Quoted 3 lines · Xiang Xiao
From: Guiding Li <[email protected]>
This driver allows the remote processor redirect the output of
processor to redirect
Quoted 16 lines
syslog/printf into the kernel log, which is very useful to see what happen in the remote side.
Signed-off-by Guiding Li <[email protected]>--- drivers/rpmsg/Kconfig | 12 ++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 163 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +0
-0
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 23
Quoted 9 lines
drivers/rpmsg/Kconfig +6
-0@@ -15,6 +15,18 @@ config RPMSG_CHAR in /dev. They make it possible for user-space programs to send and receive rpmsg packets. +config RPMSG_SYSLOG + tristate "RPMSG syslog redirection" + depends on RPMSG + help + Say Y here to redirect the syslog/printf from remote processor into + the kernel log which is very useful to see what happen in the remote
see what happens
or see what happened
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 26
Quoted 3 lines
drivers/rpmsg/Kconfig +3
-0+ side. + + If the remote processor hang during bootup or panic at the runtime,
hangs during bootup or panics during runtime,
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 27
Quoted 1 line
drivers/rpmsg/Kconfig +1
-0+ We can even cat /sys/kernel/debug/remoteproc/remoteprocX/trace0 to
we
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 28
Quoted 1 line
drivers/rpmsg/Kconfig +1
-0+ get the last log which doesn't output yet.
get the last log which hasn't been output yet.
Quoted 4 lines
drivers/rpmsg/Kconfig +1
-0+ config RPMSG_QCOM_GLINK_NATIVE tristate select RPMSG
Signature · 1 line
~Randy
Re: [PATCH 2/2] rpmsg: add syslog redirection driver
Thanks, will fix all typo in the next patch.
Quoted 66 lines · Randy Dunlap
Quoted 3 lines · Xiang Xiao
From: Guiding Li <[email protected]>
This driver allows the remote processor redirect the output of
processor to redirect
Quoted 8 lines
syslog/printf into the kernel log, which is very useful to see what happen in the remote side.
Signed-off-by Guiding Li <[email protected]>--- drivers/rpmsg/Kconfig | 12 ++++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_syslog.c | 163+++++++++++++++++++++++++++++++++++++++++++
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 15
Quoted 9 lines
3 files changed, 176 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_syslog.cdrivers/rpmsg/Kconfig +0
-0@@ -15,6 +15,18 @@ config RPMSG_CHAR in /dev. They make it possible for user-space programs to sendand
drivers/rpmsg/Kconfig config RPMSG_CHAR
Quoted 7 lines
drivers/rpmsg/Kconfig +5
-0receive rpmsg packets. +config RPMSG_SYSLOG + tristate "RPMSG syslog redirection" + depends on RPMSG + help + Say Y here to redirect the syslog/printf from remote processorinto
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 23
Quoted 1 line
drivers/rpmsg/Kconfig +1
-0+ the kernel log which is very useful to see what happen in theremote
see what happens
or see what happeneddrivers/rpmsg/Kconfig config RPMSG_CHAR
Quoted 3 lines
drivers/rpmsg/Kconfig +3
-0+ side. + + If the remote processor hang during bootup or panic at theruntime,
hangs during bootup or panics during
runtime,drivers/rpmsg/Kconfig config RPMSG_CHAR · line 27
Quoted 1 line
drivers/rpmsg/Kconfig +1
-0+ We can even cat /sys/kernel/debug/remoteproc/remoteprocX/trace0to
we
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 28
Quoted 1 line
drivers/rpmsg/Kconfig +1
-0+ get the last log which doesn't output yet.get the last log which hasn't been output yet.
drivers/rpmsg/Kconfig config RPMSG_CHAR · line 32
Quoted 4 lines
drivers/rpmsg/Kconfig +1
-0+ config RPMSG_QCOM_GLINK_NATIVE tristate select RPMSG--
~Randy
Quoted 35 lines · Xiang Xiao
Here is the detailed description for memrchr:
void *memrchr(const void *s, int c,
size_tn);The
memrchr()function is like thememchr()function, except that it searches backward from the end of the n bytes pointed to by s instead of forward from the beginning.The
memrchr()functions return a pointer to the matching byte or NULL if the character does not occur in the given memory area.Signed-off-by Xiang Xiao <[email protected]>--- include/linux/string.h | 1 + lib/string.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+)include/linux/string.h +1
-0@@ -167,6 +167,7 @@ static inline void memcpy_flushcache(void *dst, const void *src, size_t cnt) memcpy(dst, src, cnt); }#endif +void *memrchr (const void *s,int c,size_t n);void *memchr_inv (const void *s,int c,size_t n);char *strreplace (char *s,char old,char new);lib/string.c +0
-0
lib/string.c void *memchr(const void *s, int c, size_t n) · line 968
Quoted 5 lines
lib/string.c +2
-0@@ -964,6 +964,27 @@ void *memchr(const void *s, int c, size_t n)EXPORT_SYMBOL (memchr);#endif +/** +* memrchr - Find a character in an area of memory.
This should say up front that this is a reverse search, from the end of the memory area backwards.
lib/string.c void *memchr(const void *s, int c, size_t n) · line 973
Quoted 5 lines
lib/string.c +5
-0+* @s: The memory area +* @c: The byte to search for +* @n: The size of the area. +* +* returns the address of the last occurrence of @c, or %NULL
* Return: the address of the last occurrence of @c, or %NULL
Quoted 18 lines
lib/string.c +14
-0+* if @c is not found +*/ +void *memrchr (const void *s,int c,size_t n) +{ +const unsigned char *p = s + n; + +while (n-- !=0 ) { +if ((unsigned char )c == *--p) +return (void *)p; + } +return NULL ; +} +EXPORT_SYMBOL (memrchr); +static void *check_bytes8 (const u8 *start,u8 value,unsigned int bytes) {while (bytes) {
Signature · 1 line
~Randy
Thanks, will fix all issues in the next review.
Quoted 77 lines · Randy Dunlap
include/linux/string.h static inline void memcpy_flushcache(void *dst,
Quoted 23 lines · Xiang Xiao
Here is the detailed description for memrchr:
void *memrchr(const void *s, int c,
size_tn);The
memrchr()function is like thememchr()function, except that it searches backward from the end of the n bytes pointed to by s instead of forward from the beginning.The
memrchr()functions return a pointer to the matching byte or NULL if the character does not occur in the given memory area.Signed-off-by Xiang Xiao <[email protected]>--- include/linux/string.h | 1 + lib/string.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+)include/linux/string.h +0
-0@@ -167,6 +167,7 @@ static inline void memcpy_flushcache(void *dst,const void *src,
size_tcnt)Quoted 12 lines
include/linux/string.h +1
-0memcpy(dst, src, cnt); }#endif +void *memrchr (const void *s,int c,size_t n);void *memchr_inv (const void *s,int c,size_t n);char *strreplace (char *s,char old,char new);lib/string.c +0
-0lib/string.c void *memchr(const void *s, int c, size_t n) · line 968
Quoted 5 lines
lib/string.c +2
-0@@ -964,6 +964,27 @@ void *memchr(const void *s, int c, size_t n)EXPORT_SYMBOL (memchr);#endif +/** +* memrchr - Find a character in an area of memory. This should say up front that this is a reverse search, from the end of the memory area backwards.
lib/string.c void *memchr(const void *s, int c, size_t n) · line 973
Quoted 5 lines
lib/string.c +5
-0+* @s: The memory area +* @c: The byte to search for +* @n: The size of the area. +* +* returns the address of the last occurrence of @c, or %NULL * Return: the address of the last occurrence of @c, or %NULL
Quoted 8 lines
lib/string.c +7
-0+* if @c is not found +*/ +void *memrchr (const void *s,int c,size_t n) +{ +const unsigned char *p = s + n; + +while (n-- !=0 ) {lib/string.c void *memchr(const void *s, int c, size_t n) · line 990
Quoted 10 lines
lib/string.c +7
-0+if ((unsigned char )c == *--p) +return (void *)p; + } +return NULL ; +} +EXPORT_SYMBOL (memrchr); +static void *check_bytes8 (const u8 *start,u8 value,unsigned int bytes) {while (bytes) {--
~Randy