Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
6071239e
Commit
6071239e
authored
May 15, 2008
by
Jonathan Corbet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtdchar: cdev lock_kernel() pushdown
Signed-off-by:
Jonathan Corbet
<
corbet@lwn.net
>
parent
ea2959a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
drivers/mtd/mtdchar.c
drivers/mtd/mtdchar.c
+16
-6
No files found.
drivers/mtd/mtdchar.c
View file @
6071239e
...
...
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/compatmac.h>
...
...
@@ -86,6 +87,7 @@ static int mtd_open(struct inode *inode, struct file *file)
{
int
minor
=
iminor
(
inode
);
int
devnum
=
minor
>>
1
;
int
ret
=
0
;
struct
mtd_info
*
mtd
;
struct
mtd_file_info
*
mfi
;
...
...
@@ -98,31 +100,39 @@ static int mtd_open(struct inode *inode, struct file *file)
if
((
file
->
f_mode
&
2
)
&&
(
minor
&
1
))
return
-
EACCES
;
lock_kernel
();
mtd
=
get_mtd_device
(
NULL
,
devnum
);
if
(
IS_ERR
(
mtd
))
return
PTR_ERR
(
mtd
);
if
(
IS_ERR
(
mtd
))
{
ret
=
PTR_ERR
(
mtd
);
goto
out
;
}
if
(
MTD_ABSENT
==
mtd
->
type
)
{
put_mtd_device
(
mtd
);
return
-
ENODEV
;
ret
=
-
ENODEV
;
goto
out
;
}
/* You can't open it RW if it's not a writeable device */
if
((
file
->
f_mode
&
2
)
&&
!
(
mtd
->
flags
&
MTD_WRITEABLE
))
{
put_mtd_device
(
mtd
);
return
-
EACCES
;
ret
=
-
EACCES
;
goto
out
;
}
mfi
=
kzalloc
(
sizeof
(
*
mfi
),
GFP_KERNEL
);
if
(
!
mfi
)
{
put_mtd_device
(
mtd
);
return
-
ENOMEM
;
ret
=
-
ENOMEM
;
goto
out
;
}
mfi
->
mtd
=
mtd
;
file
->
private_data
=
mfi
;
return
0
;
out:
unlock_kernel
();
return
ret
;
}
/* mtd_open */
/*====================================================================*/
...
...
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