Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
3ad142f9
Commit
3ad142f9
authored
Sep 16, 2003
by
Stephen Hemminger
Committed by
Linus Torvalds
Sep 16, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] (2/2) drivers/char/misc -- seq_file
Use seq_file for /proc/misc
parent
1848d7bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
20 deletions
+60
-20
drivers/char/misc.c
drivers/char/misc.c
+60
-20
No files found.
drivers/char/misc.c
View file @
3ad142f9
...
...
@@ -43,6 +43,7 @@
#include <linux/major.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/stat.h>
#include <linux/init.h>
...
...
@@ -73,32 +74,65 @@ extern int pmu_device_init(void);
extern
int
tosh_init
(
void
);
extern
int
i8k_init
(
void
);
static
int
misc_read_proc
(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
len
,
int
*
eof
,
void
*
private
)
#ifdef CONFIG_PROC_FS
static
void
*
misc_seq_start
(
struct
seq_file
*
seq
,
loff_t
*
pos
)
{
struct
miscdevice
*
p
;
int
written
;
loff_t
off
=
0
;
written
=
0
;
down
(
&
misc_sem
)
;
list_for_each_entry
(
p
,
&
misc_list
,
list
)
{
if
(
written
>=
len
)
break
;
written
+=
sprintf
(
buf
+
written
,
"%3i %s
\n
"
,
p
->
minor
,
p
->
name
?:
""
);
if
(
written
<
offset
)
{
offset
-=
written
;
written
=
0
;
}
}
*
start
=
buf
+
offset
;
written
-=
offset
;
if
(
written
>
len
)
{
*
eof
=
0
;
return
len
;
if
(
*
pos
==
off
++
)
return
p
;
}
*
eof
=
1
;
return
(
written
<
0
)
?
0
:
written
;
return
NULL
;
}
static
void
*
misc_seq_next
(
struct
seq_file
*
seq
,
void
*
v
,
loff_t
*
pos
)
{
struct
list_head
*
n
=
((
struct
miscdevice
*
)
v
)
->
list
.
next
;
++*
pos
;
return
(
n
!=
&
misc_list
)
?
list_entry
(
n
,
struct
miscdevice
,
list
)
:
NULL
;
}
static
void
misc_seq_stop
(
struct
seq_file
*
seq
,
void
*
v
)
{
up
(
&
misc_sem
);
}
static
int
misc_seq_show
(
struct
seq_file
*
seq
,
void
*
v
)
{
const
struct
miscdevice
*
p
=
v
;
seq_printf
(
seq
,
"%3i %s
\n
"
,
p
->
minor
,
p
->
name
?
p
->
name
:
""
);
return
0
;
}
static
struct
seq_operations
misc_seq_ops
=
{
.
start
=
misc_seq_start
,
.
next
=
misc_seq_next
,
.
stop
=
misc_seq_stop
,
.
show
=
misc_seq_show
,
};
static
int
misc_seq_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
seq_open
(
file
,
&
misc_seq_ops
);
}
static
struct
file_operations
misc_proc_fops
=
{
.
owner
=
THIS_MODULE
,
.
open
=
misc_seq_open
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
seq_release
,
};
#endif
static
int
misc_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
int
minor
=
iminor
(
inode
);
...
...
@@ -245,7 +279,13 @@ EXPORT_SYMBOL(misc_deregister);
int
__init
misc_init
(
void
)
{
create_proc_read_entry
(
"misc"
,
0
,
0
,
misc_read_proc
,
NULL
);
#ifdef CONFIG_PROC_FS
struct
proc_dir_entry
*
ent
;
ent
=
create_proc_entry
(
"misc"
,
0
,
NULL
);
if
(
ent
)
ent
->
proc_fops
=
&
misc_proc_fops
;
#endif
#ifdef CONFIG_MVME16x
rtc_MK48T08_init
();
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment