Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
8f737d61
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8f737d61
编写于
10月 25, 2013
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'spi/topic/core' into spi-next
上级
d42b70f5
5fe5f05e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
41 deletion
+36
-41
drivers/spi/spi.c
drivers/spi/spi.c
+36
-41
未找到文件。
drivers/spi/spi.c
浏览文件 @
8f737d61
...
...
@@ -58,11 +58,13 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf)
return
sprintf
(
buf
,
"%s%s
\n
"
,
SPI_MODULE_PREFIX
,
spi
->
modalias
);
}
static
DEVICE_ATTR_RO
(
modalias
);
static
struct
device_attribute
spi_dev_attrs
[]
=
{
__ATTR_RO
(
modalias
)
,
__ATTR_
NULL
,
static
struct
attribute
*
spi_dev_attrs
[]
=
{
&
dev_attr_modalias
.
attr
,
NULL
,
};
ATTRIBUTE_GROUPS
(
spi_dev
);
/* modalias support makes "modprobe $MODALIAS" new-style hotplug work,
* and the sysfs version makes coldplug work too.
...
...
@@ -229,7 +231,7 @@ static const struct dev_pm_ops spi_pm = {
struct
bus_type
spi_bus_type
=
{
.
name
=
"spi"
,
.
dev_
attrs
=
spi_dev_attr
s
,
.
dev_
groups
=
spi_dev_group
s
,
.
match
=
spi_match_device
,
.
uevent
=
spi_uevent
,
.
pm
=
&
spi_pm
,
...
...
@@ -323,7 +325,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master)
if
(
!
spi_master_get
(
master
))
return
NULL
;
spi
=
kzalloc
(
sizeof
*
spi
,
GFP_KERNEL
);
spi
=
kzalloc
(
sizeof
(
*
spi
)
,
GFP_KERNEL
);
if
(
!
spi
)
{
dev_err
(
dev
,
"cannot alloc spi_device
\n
"
);
spi_master_put
(
master
);
...
...
@@ -838,10 +840,8 @@ static void of_register_spi_devices(struct spi_master *master)
{
struct
spi_device
*
spi
;
struct
device_node
*
nc
;
const
__be32
*
prop
;
char
modalias
[
SPI_NAME_SIZE
+
4
];
int
rc
;
int
len
;
u32
value
;
if
(
!
master
->
dev
.
of_node
)
return
;
...
...
@@ -866,14 +866,14 @@ static void of_register_spi_devices(struct spi_master *master)
}
/* Device address */
prop
=
of_get_property
(
nc
,
"reg"
,
&
len
);
if
(
!
prop
||
len
<
sizeof
(
*
prop
)
)
{
dev_err
(
&
master
->
dev
,
"%s has no
'reg' property
\n
"
,
nc
->
full_name
);
rc
=
of_property_read_u32
(
nc
,
"reg"
,
&
value
);
if
(
rc
)
{
dev_err
(
&
master
->
dev
,
"%s has no
valid 'reg' property (%d)
\n
"
,
nc
->
full_name
,
rc
);
spi_dev_put
(
spi
);
continue
;
}
spi
->
chip_select
=
be32_to_cpup
(
prop
)
;
spi
->
chip_select
=
value
;
/* Mode (clock phase/polarity/etc.) */
if
(
of_find_property
(
nc
,
"spi-cpha"
,
NULL
))
...
...
@@ -886,55 +886,53 @@ static void of_register_spi_devices(struct spi_master *master)
spi
->
mode
|=
SPI_3WIRE
;
/* Device DUAL/QUAD mode */
prop
=
of_get_property
(
nc
,
"spi-tx-bus-width"
,
&
len
);
if
(
prop
&&
len
==
sizeof
(
*
prop
))
{
switch
(
be32_to_cpup
(
prop
))
{
case
SPI_NBITS_SINGLE
:
if
(
!
of_property_read_u32
(
nc
,
"spi-tx-bus-width"
,
&
value
))
{
switch
(
value
)
{
case
1
:
break
;
case
SPI_NBITS_DUAL
:
case
2
:
spi
->
mode
|=
SPI_TX_DUAL
;
break
;
case
SPI_NBITS_QUAD
:
case
4
:
spi
->
mode
|=
SPI_TX_QUAD
;
break
;
default:
dev_err
(
&
master
->
dev
,
"spi-tx-bus-width %d not supported
\n
"
,
be32_to_cpup
(
prop
)
);
value
);
spi_dev_put
(
spi
);
continue
;
}
}
prop
=
of_get_property
(
nc
,
"spi-rx-bus-width"
,
&
len
);
if
(
prop
&&
len
==
sizeof
(
*
prop
))
{
switch
(
be32_to_cpup
(
prop
))
{
case
SPI_NBITS_SINGLE
:
if
(
!
of_property_read_u32
(
nc
,
"spi-rx-bus-width"
,
&
value
))
{
switch
(
value
)
{
case
1
:
break
;
case
SPI_NBITS_DUAL
:
case
2
:
spi
->
mode
|=
SPI_RX_DUAL
;
break
;
case
SPI_NBITS_QUAD
:
case
4
:
spi
->
mode
|=
SPI_RX_QUAD
;
break
;
default:
dev_err
(
&
master
->
dev
,
"spi-rx-bus-width %d not supported
\n
"
,
be32_to_cpup
(
prop
)
);
value
);
spi_dev_put
(
spi
);
continue
;
}
}
/* Device speed */
prop
=
of_get_property
(
nc
,
"spi-max-frequency"
,
&
len
);
if
(
!
prop
||
len
<
sizeof
(
*
prop
)
)
{
dev_err
(
&
master
->
dev
,
"%s has no
'spi-max-frequency' property
\n
"
,
nc
->
full_name
);
rc
=
of_property_read_u32
(
nc
,
"spi-max-frequency"
,
&
value
);
if
(
rc
)
{
dev_err
(
&
master
->
dev
,
"%s has no
valid 'spi-max-frequency' property (%d)
\n
"
,
nc
->
full_name
,
rc
);
spi_dev_put
(
spi
);
continue
;
}
spi
->
max_speed_hz
=
be32_to_cpup
(
prop
)
;
spi
->
max_speed_hz
=
value
;
/* IRQ */
spi
->
irq
=
irq_of_parse_and_map
(
nc
,
0
);
...
...
@@ -944,9 +942,7 @@ static void of_register_spi_devices(struct spi_master *master)
spi
->
dev
.
of_node
=
nc
;
/* Register the new device */
snprintf
(
modalias
,
sizeof
(
modalias
),
"%s%s"
,
SPI_MODULE_PREFIX
,
spi
->
modalias
);
request_module
(
modalias
);
request_module
(
"%s%s"
,
SPI_MODULE_PREFIX
,
spi
->
modalias
);
rc
=
spi_add_device
(
spi
);
if
(
rc
)
{
dev_err
(
&
master
->
dev
,
"spi_device register error %s
\n
"
,
...
...
@@ -1097,7 +1093,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
if
(
!
dev
)
return
NULL
;
master
=
kzalloc
(
size
+
sizeof
*
master
,
GFP_KERNEL
);
master
=
kzalloc
(
size
+
sizeof
(
*
master
)
,
GFP_KERNEL
);
if
(
!
master
)
return
NULL
;
...
...
@@ -1122,7 +1118,7 @@ static int of_spi_register_master(struct spi_master *master)
return
0
;
nb
=
of_gpio_named_count
(
np
,
"cs-gpios"
);
master
->
num_chipselect
=
max
(
nb
,
(
int
)
master
->
num_chipselect
);
master
->
num_chipselect
=
max
_t
(
int
,
nb
,
master
->
num_chipselect
);
/* Return error only for an incorrectly formed cs-gpios property */
if
(
nb
==
0
||
nb
==
-
ENOENT
)
...
...
@@ -1437,8 +1433,7 @@ int spi_setup(struct spi_device *spi)
if
(
spi
->
master
->
setup
)
status
=
spi
->
master
->
setup
(
spi
);
dev_dbg
(
&
spi
->
dev
,
"setup mode %d, %s%s%s%s"
"%u bits/w, %u Hz max --> %d
\n
"
,
dev_dbg
(
&
spi
->
dev
,
"setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d
\n
"
,
(
int
)
(
spi
->
mode
&
(
SPI_CPOL
|
SPI_CPHA
)),
(
spi
->
mode
&
SPI_CS_HIGH
)
?
"cs_high, "
:
""
,
(
spi
->
mode
&
SPI_LSB_FIRST
)
?
"lsb, "
:
""
,
...
...
@@ -1797,7 +1792,7 @@ int spi_bus_unlock(struct spi_master *master)
EXPORT_SYMBOL_GPL
(
spi_bus_unlock
);
/* portable code must never pass more than 32 bytes */
#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
#define SPI_BUFSIZ max(32,
SMP_CACHE_BYTES)
static
u8
*
buf
;
...
...
@@ -1846,7 +1841,7 @@ int spi_write_then_read(struct spi_device *spi,
}
spi_message_init
(
&
message
);
memset
(
x
,
0
,
sizeof
x
);
memset
(
x
,
0
,
sizeof
(
x
)
);
if
(
n_tx
)
{
x
[
0
].
len
=
n_tx
;
spi_message_add_tail
(
&
x
[
0
],
&
message
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录