-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fbdev/core: Move procfs code to separate file
Move fbdev's procfs code into a separate file and contain it in init and cleanup helpers. For the cleanup, replace remove_proc_entry() with proc_remove(). It is equivalent in functionality, but looks more like an inverse of proc_create_seq(). v2: * document proc_remove() usage (Sam) * revert unrelated removal of for_each_registered_fb() Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230613110953.24176-36-tzimmermann@suse.de
- Loading branch information
Thomas Zimmermann
committed
Jun 27, 2023
1 parent
e2af003
commit abcc2f3
Showing
4 changed files
with
80 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/proc_fs.h> | ||
|
||
#include "fb_internal.h" | ||
|
||
static struct proc_dir_entry *fb_proc_dir_entry; | ||
|
||
static void *fb_seq_start(struct seq_file *m, loff_t *pos) | ||
{ | ||
mutex_lock(®istration_lock); | ||
|
||
return (*pos < FB_MAX) ? pos : NULL; | ||
} | ||
|
||
static void fb_seq_stop(struct seq_file *m, void *v) | ||
{ | ||
mutex_unlock(®istration_lock); | ||
} | ||
|
||
static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos) | ||
{ | ||
(*pos)++; | ||
|
||
return (*pos < FB_MAX) ? pos : NULL; | ||
} | ||
|
||
static int fb_seq_show(struct seq_file *m, void *v) | ||
{ | ||
int i = *(loff_t *)v; | ||
struct fb_info *fi = registered_fb[i]; | ||
|
||
if (fi) | ||
seq_printf(m, "%d %s\n", fi->node, fi->fix.id); | ||
|
||
return 0; | ||
} | ||
|
||
static const struct seq_operations __maybe_unused fb_proc_seq_ops = { | ||
.start = fb_seq_start, | ||
.stop = fb_seq_stop, | ||
.next = fb_seq_next, | ||
.show = fb_seq_show, | ||
}; | ||
|
||
int fb_init_procfs(void) | ||
{ | ||
struct proc_dir_entry *proc; | ||
|
||
proc = proc_create_seq("fb", 0, NULL, &fb_proc_seq_ops); | ||
if (!proc) | ||
return -ENOMEM; | ||
|
||
fb_proc_dir_entry = proc; | ||
|
||
return 0; | ||
} | ||
|
||
void fb_cleanup_procfs(void) | ||
{ | ||
proc_remove(fb_proc_dir_entry); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters