Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
d700518a
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d700518a
编写于
2月 17, 2010
作者:
D
Dominik Brodowski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pcmcia: use read_cis_mem return value
Signed-off-by:
N
Dominik Brodowski
<
linux@dominikbrodowski.net
>
上级
a78621bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
19 deletion
+44
-19
drivers/pcmcia/cistpl.c
drivers/pcmcia/cistpl.c
+44
-19
未找到文件。
drivers/pcmcia/cistpl.c
浏览文件 @
d700518a
...
...
@@ -283,30 +283,32 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
======================================================================*/
static
void
read_cis_cache
(
struct
pcmcia_socket
*
s
,
int
attr
,
u_int
addr
,
size_t
len
,
void
*
ptr
)
static
int
read_cis_cache
(
struct
pcmcia_socket
*
s
,
int
attr
,
u_int
addr
,
size_t
len
,
void
*
ptr
)
{
struct
cis_cache_entry
*
cis
;
int
ret
;
int
ret
=
0
;
if
(
s
->
state
&
SOCKET_CARDBUS
)
return
;
return
-
EINVAL
;
mutex_lock
(
&
s
->
ops_mutex
);
if
(
s
->
fake_cis
)
{
if
(
s
->
fake_cis_len
>=
addr
+
len
)
memcpy
(
ptr
,
s
->
fake_cis
+
addr
,
len
);
else
else
{
memset
(
ptr
,
0xff
,
len
);
ret
=
-
EINVAL
;
}
mutex_unlock
(
&
s
->
ops_mutex
);
return
;
return
ret
;
}
list_for_each_entry
(
cis
,
&
s
->
cis_cache
,
node
)
{
if
(
cis
->
addr
==
addr
&&
cis
->
len
==
len
&&
cis
->
attr
==
attr
)
{
memcpy
(
ptr
,
cis
->
cache
,
len
);
mutex_unlock
(
&
s
->
ops_mutex
);
return
;
return
0
;
}
}
mutex_unlock
(
&
s
->
ops_mutex
);
...
...
@@ -326,6 +328,7 @@ static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
mutex_unlock
(
&
s
->
ops_mutex
);
}
}
return
ret
;
}
static
void
...
...
@@ -374,6 +377,7 @@ int verify_cis_cache(struct pcmcia_socket *s)
{
struct
cis_cache_entry
*
cis
;
char
*
buf
;
int
ret
;
if
(
s
->
state
&
SOCKET_CARDBUS
)
return
-
EINVAL
;
...
...
@@ -390,9 +394,8 @@ int verify_cis_cache(struct pcmcia_socket *s)
if
(
len
>
256
)
len
=
256
;
pcmcia_read_cis_mem
(
s
,
cis
->
attr
,
cis
->
addr
,
len
,
buf
);
if
(
memcmp
(
buf
,
cis
->
cache
,
len
)
!=
0
)
{
ret
=
pcmcia_read_cis_mem
(
s
,
cis
->
attr
,
cis
->
addr
,
len
,
buf
);
if
(
ret
||
memcmp
(
buf
,
cis
->
cache
,
len
)
!=
0
)
{
kfree
(
buf
);
return
-
1
;
}
...
...
@@ -425,6 +428,7 @@ int pcmcia_replace_cis(struct pcmcia_socket *s,
}
s
->
fake_cis_len
=
len
;
memcpy
(
s
->
fake_cis
,
data
,
len
);
dev_info
(
&
s
->
dev
,
"Using replacement CIS
\n
"
);
mutex_unlock
(
&
s
->
ops_mutex
);
return
0
;
}
...
...
@@ -478,11 +482,14 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
{
u_char
link
[
5
];
u_int
ofs
;
int
ret
;
if
(
MFC_FN
(
tuple
->
Flags
))
{
/* Get indirect link from the MFC tuple */
read_cis_cache
(
s
,
LINK_SPACE
(
tuple
->
Flags
),
re
t
=
re
ad_cis_cache
(
s
,
LINK_SPACE
(
tuple
->
Flags
),
tuple
->
LinkOffset
,
5
,
link
);
if
(
ret
)
return
-
1
;
ofs
=
get_unaligned_le32
(
link
+
1
);
SPACE
(
tuple
->
Flags
)
=
(
link
[
0
]
==
CISTPL_MFC_ATTR
);
/* Move to the next indirect link */
...
...
@@ -498,7 +505,9 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
if
(
SPACE
(
tuple
->
Flags
))
{
/* This is ugly, but a common CIS error is to code the long
link offset incorrectly, so we check the right spot... */
read_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
ofs
,
5
,
link
);
ret
=
read_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
ofs
,
5
,
link
);
if
(
ret
)
return
-
1
;
if
((
link
[
0
]
==
CISTPL_LINKTARGET
)
&&
(
link
[
1
]
>=
3
)
&&
(
strncmp
(
link
+
2
,
"CIS"
,
3
)
==
0
))
return
ofs
;
...
...
@@ -506,7 +515,9 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
/* Then, we try the wrong spot... */
ofs
=
ofs
>>
1
;
}
read_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
ofs
,
5
,
link
);
ret
=
read_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
ofs
,
5
,
link
);
if
(
ret
)
return
-
1
;
if
((
link
[
0
]
==
CISTPL_LINKTARGET
)
&&
(
link
[
1
]
>=
3
)
&&
(
strncmp
(
link
+
2
,
"CIS"
,
3
)
==
0
))
return
ofs
;
...
...
@@ -518,6 +529,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
{
u_char
link
[
2
],
tmp
;
int
ofs
,
i
,
attr
;
int
ret
;
if
(
!
s
)
return
-
EINVAL
;
...
...
@@ -532,7 +544,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
if
(
link
[
1
]
==
0xff
)
{
link
[
0
]
=
CISTPL_END
;
}
else
{
read_cis_cache
(
s
,
attr
,
ofs
,
2
,
link
);
ret
=
read_cis_cache
(
s
,
attr
,
ofs
,
2
,
link
);
if
(
ret
)
return
-
1
;
if
(
link
[
0
]
==
CISTPL_NULL
)
{
ofs
++
;
continue
;
}
...
...
@@ -544,7 +558,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
if
(
ofs
<
0
)
return
-
ENOSPC
;
attr
=
SPACE
(
tuple
->
Flags
);
read_cis_cache
(
s
,
attr
,
ofs
,
2
,
link
);
ret
=
read_cis_cache
(
s
,
attr
,
ofs
,
2
,
link
);
if
(
ret
)
return
-
1
;
}
/* Is this a link tuple? Make a note of it */
...
...
@@ -558,12 +574,16 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
case
CISTPL_LONGLINK_A
:
HAS_LINK
(
tuple
->
Flags
)
=
1
;
LINK_SPACE
(
tuple
->
Flags
)
=
attr
|
IS_ATTR
;
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
4
,
&
tuple
->
LinkOffset
);
ret
=
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
4
,
&
tuple
->
LinkOffset
);
if
(
ret
)
return
-
1
;
break
;
case
CISTPL_LONGLINK_C
:
HAS_LINK
(
tuple
->
Flags
)
=
1
;
LINK_SPACE
(
tuple
->
Flags
)
=
attr
&
~
IS_ATTR
;
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
4
,
&
tuple
->
LinkOffset
);
ret
=
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
4
,
&
tuple
->
LinkOffset
);
if
(
ret
)
return
-
1
;
break
;
case
CISTPL_INDIRECT
:
HAS_LINK
(
tuple
->
Flags
)
=
1
;
...
...
@@ -575,7 +595,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
LINK_SPACE
(
tuple
->
Flags
)
=
attr
;
if
(
function
==
BIND_FN_ALL
)
{
/* Follow all the MFC links */
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
1
,
&
tmp
);
ret
=
read_cis_cache
(
s
,
attr
,
ofs
+
2
,
1
,
&
tmp
);
if
(
ret
)
return
-
1
;
MFC_FN
(
tuple
->
Flags
)
=
tmp
;
}
else
{
/* Follow exactly one of the links */
...
...
@@ -616,6 +638,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
int
pccard_get_tuple_data
(
struct
pcmcia_socket
*
s
,
tuple_t
*
tuple
)
{
u_int
len
;
int
ret
;
if
(
!
s
)
return
-
EINVAL
;
...
...
@@ -626,9 +649,11 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
tuple
->
TupleDataLen
=
tuple
->
TupleLink
;
if
(
len
==
0
)
return
0
;
read_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
re
t
=
re
ad_cis_cache
(
s
,
SPACE
(
tuple
->
Flags
),
tuple
->
CISOffset
+
tuple
->
TupleOffset
,
_MIN
(
len
,
tuple
->
TupleDataMax
),
tuple
->
TupleData
);
if
(
ret
)
return
-
1
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录