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
nexedi
linux
Commits
1848d7bb
Commit
1848d7bb
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] drivers/char/misc -- use list() macros
Use list macros for misc_device list.
parent
69014ca5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
33 deletions
+32
-33
drivers/char/misc.c
drivers/char/misc.c
+31
-32
include/linux/miscdevice.h
include/linux/miscdevice.h
+1
-1
No files found.
drivers/char/misc.c
View file @
1848d7bb
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
/*
/*
* Head entry for the doubly linked miscdevice list
* Head entry for the doubly linked miscdevice list
*/
*/
static
struct
miscdevice
misc_list
=
{
0
,
"head"
,
NULL
,
&
misc_list
,
&
misc_list
}
;
static
LIST_HEAD
(
misc_list
)
;
static
DECLARE_MUTEX
(
misc_sem
);
static
DECLARE_MUTEX
(
misc_sem
);
/*
/*
...
@@ -80,7 +80,9 @@ static int misc_read_proc(char *buf, char **start, off_t offset,
...
@@ -80,7 +80,9 @@ static int misc_read_proc(char *buf, char **start, off_t offset,
int
written
;
int
written
;
written
=
0
;
written
=
0
;
for
(
p
=
misc_list
.
next
;
p
!=
&
misc_list
&&
written
<
len
;
p
=
p
->
next
)
{
list_for_each_entry
(
p
,
&
misc_list
,
list
)
{
if
(
written
>=
len
)
break
;
written
+=
sprintf
(
buf
+
written
,
"%3i %s
\n
"
,
p
->
minor
,
p
->
name
?:
""
);
written
+=
sprintf
(
buf
+
written
,
"%3i %s
\n
"
,
p
->
minor
,
p
->
name
?:
""
);
if
(
written
<
offset
)
{
if
(
written
<
offset
)
{
offset
-=
written
;
offset
-=
written
;
...
@@ -97,7 +99,6 @@ static int misc_read_proc(char *buf, char **start, off_t offset,
...
@@ -97,7 +99,6 @@ static int misc_read_proc(char *buf, char **start, off_t offset,
return
(
written
<
0
)
?
0
:
written
;
return
(
written
<
0
)
?
0
:
written
;
}
}
static
int
misc_open
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
misc_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
int
minor
=
iminor
(
inode
);
int
minor
=
iminor
(
inode
);
...
@@ -107,21 +108,27 @@ static int misc_open(struct inode * inode, struct file * file)
...
@@ -107,21 +108,27 @@ static int misc_open(struct inode * inode, struct file * file)
down
(
&
misc_sem
);
down
(
&
misc_sem
);
c
=
misc_list
.
next
;
list_for_each_entry
(
c
,
&
misc_list
,
list
)
{
if
(
c
->
minor
==
minor
)
{
while
((
c
!=
&
misc_list
)
&&
(
c
->
minor
!=
minor
))
new_fops
=
fops_get
(
c
->
fops
);
c
=
c
->
next
;
break
;
if
(
c
!=
&
misc_list
)
}
new_fops
=
fops_get
(
c
->
fops
);
}
if
(
!
new_fops
)
{
if
(
!
new_fops
)
{
up
(
&
misc_sem
);
up
(
&
misc_sem
);
request_module
(
"char-major-%d-%d"
,
MISC_MAJOR
,
minor
);
request_module
(
"char-major-%d-%d"
,
MISC_MAJOR
,
minor
);
down
(
&
misc_sem
);
down
(
&
misc_sem
);
c
=
misc_list
.
next
;
while
((
c
!=
&
misc_list
)
&&
(
c
->
minor
!=
minor
))
list_for_each_entry
(
c
,
&
misc_list
,
list
)
{
c
=
c
->
next
;
if
(
c
->
minor
==
minor
)
{
if
(
c
==
&
misc_list
||
(
new_fops
=
fops_get
(
c
->
fops
))
==
NULL
)
new_fops
=
fops_get
(
c
->
fops
);
goto
fail
;
if
(
!
new_fops
)
goto
fail
;
break
;
}
}
goto
fail
;
}
}
err
=
0
;
err
=
0
;
...
@@ -166,16 +173,12 @@ int misc_register(struct miscdevice * misc)
...
@@ -166,16 +173,12 @@ int misc_register(struct miscdevice * misc)
{
{
struct
miscdevice
*
c
;
struct
miscdevice
*
c
;
if
(
misc
->
next
||
misc
->
prev
)
return
-
EBUSY
;
down
(
&
misc_sem
);
down
(
&
misc_sem
);
c
=
misc_list
.
next
;
list_for_each_entry
(
c
,
&
misc_list
,
list
)
{
if
(
c
->
minor
==
misc
->
minor
)
{
while
((
c
!=
&
misc_list
)
&&
(
c
->
minor
!=
misc
->
minor
))
up
(
&
misc_sem
);
c
=
c
->
next
;
return
-
EBUSY
;
if
(
c
!=
&
misc_list
)
{
}
up
(
&
misc_sem
);
return
-
EBUSY
;
}
}
if
(
misc
->
minor
==
MISC_DYNAMIC_MINOR
)
{
if
(
misc
->
minor
==
MISC_DYNAMIC_MINOR
)
{
...
@@ -205,10 +208,7 @@ int misc_register(struct miscdevice * misc)
...
@@ -205,10 +208,7 @@ int misc_register(struct miscdevice * misc)
* Add it to the front, so that later devices can "override"
* Add it to the front, so that later devices can "override"
* earlier defaults
* earlier defaults
*/
*/
misc
->
prev
=
&
misc_list
;
list_add
(
&
misc
->
list
,
&
misc_list
);
misc
->
next
=
misc_list
.
next
;
misc
->
prev
->
next
=
misc
;
misc
->
next
->
prev
=
misc
;
up
(
&
misc_sem
);
up
(
&
misc_sem
);
return
0
;
return
0
;
}
}
...
@@ -226,13 +226,12 @@ int misc_register(struct miscdevice * misc)
...
@@ -226,13 +226,12 @@ int misc_register(struct miscdevice * misc)
int
misc_deregister
(
struct
miscdevice
*
misc
)
int
misc_deregister
(
struct
miscdevice
*
misc
)
{
{
int
i
=
misc
->
minor
;
int
i
=
misc
->
minor
;
if
(
!
misc
->
next
||
!
misc
->
prev
)
if
(
list_empty
(
&
misc
->
list
))
return
-
EINVAL
;
return
-
EINVAL
;
down
(
&
misc_sem
);
down
(
&
misc_sem
);
misc
->
prev
->
next
=
misc
->
next
;
list_del
(
&
misc
->
list
);
misc
->
next
->
prev
=
misc
->
prev
;
misc
->
next
=
NULL
;
misc
->
prev
=
NULL
;
devfs_remove
(
misc
->
devfs_name
);
devfs_remove
(
misc
->
devfs_name
);
if
(
i
<
DYNAMIC_MINORS
&&
i
>
0
)
{
if
(
i
<
DYNAMIC_MINORS
&&
i
>
0
)
{
misc_minors
[
i
>>
3
]
&=
~
(
1
<<
(
misc
->
minor
&
7
));
misc_minors
[
i
>>
3
]
&=
~
(
1
<<
(
misc
->
minor
&
7
));
...
...
include/linux/miscdevice.h
View file @
1848d7bb
...
@@ -43,7 +43,7 @@ struct miscdevice
...
@@ -43,7 +43,7 @@ struct miscdevice
int
minor
;
int
minor
;
const
char
*
name
;
const
char
*
name
;
struct
file_operations
*
fops
;
struct
file_operations
*
fops
;
struct
miscdevice
*
next
,
*
prev
;
struct
list_head
list
;
char
devfs_name
[
64
];
char
devfs_name
[
64
];
};
};
...
...
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