Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
1db7c89c
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看板
提交
1db7c89c
编写于
11月 29, 2011
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-3.2' into for-3.3
上级
7b282cbb
bda63586
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
32 deletion
+62
-32
drivers/firmware/sigma.c
drivers/firmware/sigma.c
+58
-23
include/linux/sigma.h
include/linux/sigma.h
+4
-9
未找到文件。
drivers/firmware/sigma.c
浏览文件 @
1db7c89c
...
...
@@ -14,13 +14,34 @@
#include <linux/module.h>
#include <linux/sigma.h>
/* Return: 0==OK, <0==error, =1 ==no more actions */
static
size_t
sigma_action_size
(
struct
sigma_action
*
sa
)
{
size_t
payload
=
0
;
switch
(
sa
->
instr
)
{
case
SIGMA_ACTION_WRITEXBYTES
:
case
SIGMA_ACTION_WRITESINGLE
:
case
SIGMA_ACTION_WRITESAFELOAD
:
payload
=
sigma_action_len
(
sa
);
break
;
default:
break
;
}
payload
=
ALIGN
(
payload
,
2
);
return
payload
+
sizeof
(
struct
sigma_action
);
}
/*
* Returns a negative error value in case of an error, 0 if processing of
* the firmware should be stopped after this action, 1 otherwise.
*/
static
int
process_sigma_action
(
struct
i2c_client
*
client
,
struct
sigma_
firmware
*
ssfw
)
process_sigma_action
(
struct
i2c_client
*
client
,
struct
sigma_
action
*
sa
)
{
struct
sigma_action
*
sa
=
(
void
*
)(
ssfw
->
fw
->
data
+
ssfw
->
pos
);
size_t
len
=
sigma_action_len
(
sa
);
int
ret
=
0
;
int
ret
;
pr_debug
(
"%s: instr:%i addr:%#x len:%zu
\n
"
,
__func__
,
sa
->
instr
,
sa
->
addr
,
len
);
...
...
@@ -29,44 +50,50 @@ process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw)
case
SIGMA_ACTION_WRITEXBYTES
:
case
SIGMA_ACTION_WRITESINGLE
:
case
SIGMA_ACTION_WRITESAFELOAD
:
if
(
ssfw
->
fw
->
size
<
ssfw
->
pos
+
len
)
return
-
EINVAL
;
ret
=
i2c_master_send
(
client
,
(
void
*
)
&
sa
->
addr
,
len
);
if
(
ret
<
0
)
return
-
EINVAL
;
break
;
case
SIGMA_ACTION_DELAY
:
ret
=
0
;
udelay
(
len
);
len
=
0
;
break
;
case
SIGMA_ACTION_END
:
return
1
;
return
0
;
default:
return
-
EINVAL
;
}
/* when arrive here ret=0 or sent data */
ssfw
->
pos
+=
sigma_action_size
(
sa
,
len
);
return
ssfw
->
pos
==
ssfw
->
fw
->
size
;
return
1
;
}
static
int
process_sigma_actions
(
struct
i2c_client
*
client
,
struct
sigma_firmware
*
ssfw
)
{
pr_debug
(
"%s: processing %p
\n
"
,
__func__
,
ssfw
);
struct
sigma_action
*
sa
;
size_t
size
;
int
ret
;
while
(
ssfw
->
pos
+
sizeof
(
*
sa
)
<=
ssfw
->
fw
->
size
)
{
sa
=
(
struct
sigma_action
*
)(
ssfw
->
fw
->
data
+
ssfw
->
pos
);
size
=
sigma_action_size
(
sa
);
ssfw
->
pos
+=
size
;
if
(
ssfw
->
pos
>
ssfw
->
fw
->
size
||
size
==
0
)
break
;
ret
=
process_sigma_action
(
client
,
sa
);
while
(
1
)
{
int
ret
=
process_sigma_action
(
client
,
ssfw
);
pr_debug
(
"%s: action returned %i
\n
"
,
__func__
,
ret
);
if
(
ret
==
1
)
return
0
;
else
if
(
ret
)
if
(
ret
<=
0
)
return
ret
;
}
if
(
ssfw
->
pos
!=
ssfw
->
fw
->
size
)
return
-
EINVAL
;
return
0
;
}
int
process_sigma_firmware
(
struct
i2c_client
*
client
,
const
char
*
name
)
...
...
@@ -89,16 +116,24 @@ int process_sigma_firmware(struct i2c_client *client, const char *name)
/* then verify the header */
ret
=
-
EINVAL
;
if
(
fw
->
size
<
sizeof
(
*
ssfw_head
))
/*
* Reject too small or unreasonable large files. The upper limit has been
* chosen a bit arbitrarily, but it should be enough for all practical
* purposes and having the limit makes it easier to avoid integer
* overflows later in the loading process.
*/
if
(
fw
->
size
<
sizeof
(
*
ssfw_head
)
||
fw
->
size
>=
0x4000000
)
goto
done
;
ssfw_head
=
(
void
*
)
fw
->
data
;
if
(
memcmp
(
ssfw_head
->
magic
,
SIGMA_MAGIC
,
ARRAY_SIZE
(
ssfw_head
->
magic
)))
goto
done
;
crc
=
crc32
(
0
,
fw
->
data
,
fw
->
size
);
crc
=
crc32
(
0
,
fw
->
data
+
sizeof
(
*
ssfw_head
),
fw
->
size
-
sizeof
(
*
ssfw_head
));
pr_debug
(
"%s: crc=%x
\n
"
,
__func__
,
crc
);
if
(
crc
!=
ssfw_head
->
crc
)
if
(
crc
!=
le32_to_cpu
(
ssfw_head
->
crc
)
)
goto
done
;
ssfw
.
pos
=
sizeof
(
*
ssfw_head
);
...
...
include/linux/sigma.h
浏览文件 @
1db7c89c
...
...
@@ -24,7 +24,7 @@ struct sigma_firmware {
struct
sigma_firmware_header
{
unsigned
char
magic
[
7
];
u8
version
;
u
32
crc
;
__le
32
crc
;
};
enum
{
...
...
@@ -40,19 +40,14 @@ enum {
struct
sigma_action
{
u8
instr
;
u8
len_hi
;
u
16
len
;
u
16
addr
;
__le
16
len
;
__be
16
addr
;
unsigned
char
payload
[];
};
static
inline
u32
sigma_action_len
(
struct
sigma_action
*
sa
)
{
return
(
sa
->
len_hi
<<
16
)
|
sa
->
len
;
}
static
inline
size_t
sigma_action_size
(
struct
sigma_action
*
sa
,
u32
payload_len
)
{
return
sizeof
(
*
sa
)
+
payload_len
+
(
payload_len
%
2
);
return
(
sa
->
len_hi
<<
16
)
|
le16_to_cpu
(
sa
->
len
);
}
extern
int
process_sigma_firmware
(
struct
i2c_client
*
client
,
const
char
*
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录