Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
93339070
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
93339070
编写于
3月 23, 2007
作者:
D
David Woodhouse
浏览文件
操作
浏览文件
下载
差异文件
Merge
git://git.kernel.org/pub/scm/linux/kernel/git/joern/misc
上级
118af321
21d31f1f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
9 addition
and
58 deletion
+9
-58
drivers/mtd/devices/block2mtd.c
drivers/mtd/devices/block2mtd.c
+9
-58
未找到文件。
drivers/mtd/devices/block2mtd.c
浏览文件 @
93339070
...
...
@@ -40,56 +40,9 @@ struct block2mtd_dev {
static
LIST_HEAD
(
blkmtd_device_list
);
#define PAGE_READAHEAD 64
static
void
cache_readahead
(
struct
address_space
*
mapping
,
int
index
)
static
struct
page
*
page_read
(
struct
address_space
*
mapping
,
int
index
)
{
filler_t
*
filler
=
(
filler_t
*
)
mapping
->
a_ops
->
readpage
;
int
i
,
pagei
;
unsigned
ret
=
0
;
unsigned
long
end_index
;
struct
page
*
page
;
LIST_HEAD
(
page_pool
);
struct
inode
*
inode
=
mapping
->
host
;
loff_t
isize
=
i_size_read
(
inode
);
if
(
!
isize
)
{
INFO
(
"iSize=0 in cache_readahead
\n
"
);
return
;
}
end_index
=
((
isize
-
1
)
>>
PAGE_CACHE_SHIFT
);
read_lock_irq
(
&
mapping
->
tree_lock
);
for
(
i
=
0
;
i
<
PAGE_READAHEAD
;
i
++
)
{
pagei
=
index
+
i
;
if
(
pagei
>
end_index
)
{
INFO
(
"Overrun end of disk in cache readahead
\n
"
);
break
;
}
page
=
radix_tree_lookup
(
&
mapping
->
page_tree
,
pagei
);
if
(
page
&&
(
!
i
))
break
;
if
(
page
)
continue
;
read_unlock_irq
(
&
mapping
->
tree_lock
);
page
=
page_cache_alloc_cold
(
mapping
);
read_lock_irq
(
&
mapping
->
tree_lock
);
if
(
!
page
)
break
;
page
->
index
=
pagei
;
list_add
(
&
page
->
lru
,
&
page_pool
);
ret
++
;
}
read_unlock_irq
(
&
mapping
->
tree_lock
);
if
(
ret
)
read_cache_pages
(
mapping
,
&
page_pool
,
filler
,
NULL
);
}
static
struct
page
*
page_readahead
(
struct
address_space
*
mapping
,
int
index
)
{
filler_t
*
filler
=
(
filler_t
*
)
mapping
->
a_ops
->
readpage
;
cache_readahead
(
mapping
,
index
);
return
read_cache_page
(
mapping
,
index
,
filler
,
NULL
);
}
...
...
@@ -105,14 +58,14 @@ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
u_long
*
max
;
while
(
pages
)
{
page
=
page_read
ahead
(
mapping
,
index
);
page
=
page_read
(
mapping
,
index
);
if
(
!
page
)
return
-
ENOMEM
;
if
(
IS_ERR
(
page
))
return
PTR_ERR
(
page
);
max
=
(
u_long
*
)
page_address
(
page
)
+
PAGE_SIZE
;
for
(
p
=
(
u_long
*
)
page_address
(
page
);
p
<
max
;
p
++
)
max
=
page_address
(
page
)
+
PAGE_SIZE
;
for
(
p
=
page_address
(
page
);
p
<
max
;
p
++
)
if
(
*
p
!=
-
1UL
)
{
lock_page
(
page
);
memset
(
page_address
(
page
),
0xff
,
PAGE_SIZE
);
...
...
@@ -174,8 +127,7 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
cpylen
=
len
;
// this page
len
=
len
-
cpylen
;
// Get page
page
=
page_readahead
(
dev
->
blkdev
->
bd_inode
->
i_mapping
,
index
);
page
=
page_read
(
dev
->
blkdev
->
bd_inode
->
i_mapping
,
index
);
if
(
!
page
)
return
-
ENOMEM
;
if
(
IS_ERR
(
page
))
...
...
@@ -213,8 +165,7 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
cpylen
=
len
;
// this page
len
=
len
-
cpylen
;
// Get page
page
=
page_readahead
(
mapping
,
index
);
page
=
page_read
(
mapping
,
index
);
if
(
!
page
)
return
-
ENOMEM
;
if
(
IS_ERR
(
page
))
...
...
@@ -308,9 +259,9 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
/* We might not have rootfs mounted at this point. Try
to resolve the device name by other means. */
dev_t
dev
=
name_to_dev_t
(
devname
);
if
(
dev
!=
0
)
{
bdev
=
open_by_devnum
(
dev
,
FMODE_WRITE
|
FMODE_READ
);
dev_t
dev
t
=
name_to_dev_t
(
devname
);
if
(
dev
t
)
{
bdev
=
open_by_devnum
(
dev
t
,
FMODE_WRITE
|
FMODE_READ
);
}
}
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录