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
b55a9a52
Commit
b55a9a52
authored
Sep 21, 2002
by
Alexander Viro
Committed by
Linus Torvalds
Sep 21, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] gendisk for mtdblock
mtdblock switched to use of gendisks + compile fixes
parent
6ebe755c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
25 deletions
+16
-25
drivers/mtd/mtdblock.c
drivers/mtd/mtdblock.c
+16
-25
No files found.
drivers/mtd/mtdblock.c
View file @
b55a9a52
...
...
@@ -42,12 +42,12 @@ static struct mtdblk_dev {
unsigned
long
cache_offset
;
unsigned
int
cache_size
;
enum
{
STATE_EMPTY
,
STATE_CLEAN
,
STATE_DIRTY
}
cache_state
;
struct
gendisk
disk
;
char
name
[
7
];
}
*
mtdblks
[
MAX_MTD_DEVICES
];
static
spinlock_t
mtdblks_lock
;
static
int
mtd_sizes
[
MAX_MTD_DEVICES
];
/*
* Cache stuff...
*
...
...
@@ -257,20 +257,16 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
return
0
;
}
static
struct
block_device_operations
mtd_fops
;
static
int
mtdblock_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
mtdblk_dev
*
mtdblk
;
struct
mtd_info
*
mtd
;
int
dev
;
int
dev
=
minor
(
inode
->
i_rdev
)
;
DEBUG
(
MTD_DEBUG_LEVEL1
,
"mtdblock_open
\n
"
);
if
(
!
inode
)
return
-
EINVAL
;
dev
=
minor
(
inode
->
i_rdev
);
if
(
dev
>=
MAX_MTD_DEVICES
)
return
-
EINVAL
;
...
...
@@ -319,6 +315,12 @@ static int mtdblock_open(struct inode *inode, struct file *file)
return
-
ENOMEM
;
}
}
mtdblk
->
disk
.
major
=
MAJOR_NR
;
mtdblk
->
disk
.
first_minor
=
dev
;
mtdblk
->
disk
.
minor_shift
=
0
;
mtdblk
->
disk
.
fops
=
&
mtd_fops
;
mtdblk
->
disk
.
major_name
=
mtdblk
->
name
;
sprintf
(
mtdblk
->
name
,
"mtd%d"
,
dev
);
/* OK, we've created a new one. Add it to the list. */
...
...
@@ -335,7 +337,8 @@ static int mtdblock_open(struct inode *inode, struct file *file)
}
mtdblks
[
dev
]
=
mtdblk
;
mtd_sizes
[
dev
]
=
mtdblk
->
mtd
->
size
/
1024
;
set_capacity
(
&
mtdblk
->
disk
,
mtdblk
->
mtd
->
size
/
512
);
add_disk
(
&
mtdblk
->
disk
);
set_device_ro
(
inode
->
i_rdev
,
!
(
mtdblk
->
mtd
->
flags
&
MTD_WRITEABLE
));
spin_unlock
(
&
mtdblks_lock
);
...
...
@@ -366,6 +369,7 @@ static release_t mtdblock_release(struct inode *inode, struct file *file)
/* It was the last usage. Free the device */
mtdblks
[
dev
]
=
NULL
;
spin_unlock
(
&
mtdblks_lock
);
del_gendisk
(
&
mtdblk
->
disk
);
if
(
mtdblk
->
mtd
->
sync
)
mtdblk
->
mtd
->
sync
(
mtdblk
->
mtd
);
put_mtd_device
(
mtdblk
->
mtd
);
...
...
@@ -404,7 +408,7 @@ static void handle_mtdblock_request(void)
res
=
0
;
if
(
minor
(
req
->
rq_dev
)
>=
MAX_MTD_DEVICES
)
panic
(
__FUNCTION__
"
: minor out of bound"
);
panic
(
"handle_mtdblock_request
: minor out of bound"
);
if
(
!
(
req
->
flags
&
REQ_CMD
))
goto
end_req
;
...
...
@@ -490,7 +494,7 @@ int mtdblock_thread(void *dummy)
return
0
;
}
static
void
mtdblock_request
(
request_queue
*
q
)
static
void
mtdblock_request
(
struct
request_queue
*
q
)
{
/* Don't do anything, except wake the thread if necessary */
wake_up
(
&
thr_wq
);
...
...
@@ -510,11 +514,6 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
#endif
switch
(
cmd
)
{
case
BLKGETSIZE
:
/* Return device size */
return
put_user
((
mtdblk
->
mtd
->
size
>>
9
),
(
unsigned
long
*
)
arg
);
case
BLKGETSIZE64
:
return
put_user
((
u64
)
mtdblk
->
mtd
->
size
,
(
u64
*
)
arg
);
case
BLKFLSBUF
:
if
(
!
capable
(
CAP_SYS_ADMIN
))
return
-
EACCES
;
...
...
@@ -571,8 +570,6 @@ static spinlock_t mtddev_lock = SPIN_LOCK_UNLOCKED;
int
__init
init_mtdblock
(
void
)
{
int
i
;
spin_lock_init
(
&
mtdblks_lock
);
if
(
register_blkdev
(
MAJOR_NR
,
DEVICE_NAME
,
&
mtd_fops
))
{
printk
(
KERN_NOTICE
"Can't allocate major number %d for Memory Technology Devices.
\n
"
,
...
...
@@ -584,12 +581,7 @@ int __init init_mtdblock(void)
register_mtd_user
(
&
notifier
);
#endif
/* We fill it in at open() time. */
for
(
i
=
0
;
i
<
MAX_MTD_DEVICES
;
i
++
)
mtd_sizes
[
i
]
=
0
;
init_waitqueue_head
(
&
thr_wq
);
blk_size
[
MAJOR_NR
]
=
mtd_sizes
;
blk_init_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
),
&
mtdblock_request
,
&
mtddev_lock
);
kernel_thread
(
mtdblock_thread
,
NULL
,
CLONE_FS
|
CLONE_FILES
|
CLONE_SIGHAND
);
return
0
;
...
...
@@ -606,7 +598,6 @@ static void __exit cleanup_mtdblock(void)
#endif
unregister_blkdev
(
MAJOR_NR
,
DEVICE_NAME
);
blk_cleanup_queue
(
BLK_DEFAULT_QUEUE
(
MAJOR_NR
));
blk_size
[
MAJOR_NR
]
=
NULL
;
}
module_init
(
init_mtdblock
);
...
...
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