Date: Tue, 29 Apr 2025 11:42:10 GMT From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 85bd58055f8b - stable/14 - LinuxKPI: sysfs: implement sysfs_match_string() Message-ID: <202504291142.53TBgAuO049144@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=85bd58055f8b244584ddc6188c1770fb0246e28d commit 85bd58055f8b244584ddc6188c1770fb0246e28d Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-04-24 14:09:08 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-04-29 10:49:33 +0000 LinuxKPI: sysfs: implement sysfs_match_string() Use a macro to automatically gather the length of the array while we can. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D50007 (cherry picked from commit f94d7319540b9b2256be60c2c666efe0b6e635ef) --- sys/compat/linuxkpi/common/include/linux/sysfs.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h index b5ad73e4460b..67aab7703dc7 100644 --- a/sys/compat/linuxkpi/common/include/linux/sysfs.h +++ b/sys/compat/linuxkpi/common/include/linux/sysfs.h @@ -348,6 +348,24 @@ sysfs_emit_at(char *buf, int at, const char *fmt, ...) return (i); } +static inline int +_sysfs_match_string(const char * const *a, size_t l, const char *s) +{ + const char *p; + int i; + + for (i = 0; i < l; i++) { + p = a[i]; + if (p == NULL) + break; + if (sysfs_streq(p, s)) + return (i); + } + + return (-ENOENT); +} +#define sysfs_match_string(a, s) _sysfs_match_string(a, ARRAY_SIZE(a), s) + #define sysfs_attr_init(attr) do {} while(0) #endif /* _LINUXKPI_LINUX_SYSFS_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504291142.53TBgAuO049144>