git: efeb199fc6de - stable/13 - LinuxKPI: seq_file add "private" versions.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Nov 2022 17:26:57 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=efeb199fc6de3072e21144fd151591507e3eaac2 commit efeb199fc6de3072e21144fd151591507e3eaac2 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-10-22 18:07:37 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-11-28 16:30:16 +0000 LinuxKPI: seq_file add "private" versions. Add __seq_open_private() and seq_release_private() needed by iwlwifi debugfs support. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37089 (cherry picked from commit b5a81075903b3d97265151960b731210c0e80244) --- .../linuxkpi/common/include/linux/seq_file.h | 3 ++ sys/compat/linuxkpi/common/src/linux_seq_file.c | 33 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/seq_file.h b/sys/compat/linuxkpi/common/include/linux/seq_file.h index 9ab5ecce7768..4e7582b7acc2 100644 --- a/sys/compat/linuxkpi/common/include/linux/seq_file.h +++ b/sys/compat/linuxkpi/common/include/linux/seq_file.h @@ -71,6 +71,9 @@ struct seq_operations { ssize_t seq_read(struct linux_file *, char *, size_t, off_t *); int seq_write(struct seq_file *seq, const void *data, size_t len); +void *__seq_open_private(struct linux_file *, const struct seq_operations *, int); +int seq_release_private(struct inode *, struct linux_file *); + int seq_open(struct linux_file *f, const struct seq_operations *op); int seq_release(struct inode *inode, struct linux_file *file); diff --git a/sys/compat/linuxkpi/common/src/linux_seq_file.c b/sys/compat/linuxkpi/common/src/linux_seq_file.c index ed23bf8d010f..3ac8315a425f 100644 --- a/sys/compat/linuxkpi/common/src/linux_seq_file.c +++ b/sys/compat/linuxkpi/common/src/linux_seq_file.c @@ -113,6 +113,29 @@ seq_open(struct linux_file *f, const struct seq_operations *op) return (0); } +void * +__seq_open_private(struct linux_file *f, const struct seq_operations *op, int size) +{ + struct seq_file *seq_file; + void *private; + int error; + + private = malloc(size, M_LSEQ, M_NOWAIT|M_ZERO); + if (private == NULL) + return (NULL); + + error = seq_open(f, op); + if (error < 0) { + free(private, M_LSEQ); + return (NULL); + } + + seq_file = (struct seq_file *)f->private_data; + seq_file->private = private; + + return (private); +} + int single_open(struct linux_file *f, int (*show)(struct seq_file *, void *), void *d) { @@ -144,6 +167,16 @@ seq_release(struct inode *inode __unused, struct linux_file *file) return (0); } +int +seq_release_private(struct inode *inode __unused, struct linux_file *f) +{ + struct seq_file *seq; + + seq = (struct seq_file *)f->private_data; + free(seq->private, M_LSEQ); + return (seq_release(inode, f)); +} + int single_release(struct vnode *v, struct linux_file *f) {