Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
8c541b11
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看板
提交
8c541b11
编写于
1月 26, 2017
作者:
L
Linus Walleij
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'ib-gpiod-flags' into devel
上级
49cec4d8
b2987d74
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
64 addition
and
46 deletion
+64
-46
drivers/gpio/devres.c
drivers/gpio/devres.c
+8
-2
drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.c
+18
-5
drivers/input/keyboard/gpio_keys.c
drivers/input/keyboard/gpio_keys.c
+2
-8
drivers/input/keyboard/gpio_keys_polled.c
drivers/input/keyboard/gpio_keys_polled.c
+3
-9
drivers/leds/leds-gpio.c
drivers/leds/leds-gpio.c
+7
-6
drivers/video/fbdev/amba-clcd-nomadik.c
drivers/video/fbdev/amba-clcd-nomadik.c
+9
-10
include/linux/gpio/consumer.h
include/linux/gpio/consumer.h
+17
-6
未找到文件。
drivers/gpio/devres.c
浏览文件 @
8c541b11
...
@@ -129,13 +129,19 @@ EXPORT_SYMBOL(devm_gpiod_get_index);
...
@@ -129,13 +129,19 @@ EXPORT_SYMBOL(devm_gpiod_get_index);
* @dev: GPIO consumer
* @dev: GPIO consumer
* @con_id: function within the GPIO consumer
* @con_id: function within the GPIO consumer
* @child: firmware node (child of @dev)
* @child: firmware node (child of @dev)
* @flags: GPIO initialization flags
*
*
* GPIO descriptors returned from this function are automatically disposed on
* GPIO descriptors returned from this function are automatically disposed on
* driver detach.
* driver detach.
*
* On successfull request the GPIO pin is configured in accordance with
* provided @flags.
*/
*/
struct
gpio_desc
*
devm_get_gpiod_from_child
(
struct
device
*
dev
,
struct
gpio_desc
*
devm_get_gpiod_from_child
(
struct
device
*
dev
,
const
char
*
con_id
,
const
char
*
con_id
,
struct
fwnode_handle
*
child
)
struct
fwnode_handle
*
child
,
enum
gpiod_flags
flags
,
const
char
*
label
)
{
{
char
prop_name
[
32
];
/* 32 is max size of property name */
char
prop_name
[
32
];
/* 32 is max size of property name */
struct
gpio_desc
**
dr
;
struct
gpio_desc
**
dr
;
...
@@ -155,7 +161,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
...
@@ -155,7 +161,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
snprintf
(
prop_name
,
sizeof
(
prop_name
),
"%s"
,
snprintf
(
prop_name
,
sizeof
(
prop_name
),
"%s"
,
gpio_suffixes
[
i
]);
gpio_suffixes
[
i
]);
desc
=
fwnode_get_named_gpiod
(
child
,
prop_name
);
desc
=
fwnode_get_named_gpiod
(
child
,
prop_name
,
flags
,
label
);
if
(
!
IS_ERR
(
desc
)
||
(
PTR_ERR
(
desc
)
!=
-
ENOENT
))
if
(
!
IS_ERR
(
desc
)
||
(
PTR_ERR
(
desc
)
!=
-
ENOENT
))
break
;
break
;
}
}
...
...
drivers/gpio/gpiolib.c
浏览文件 @
8c541b11
...
@@ -3301,6 +3301,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
...
@@ -3301,6 +3301,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
* fwnode_get_named_gpiod - obtain a GPIO from firmware node
* fwnode_get_named_gpiod - obtain a GPIO from firmware node
* @fwnode: handle of the firmware node
* @fwnode: handle of the firmware node
* @propname: name of the firmware property representing the GPIO
* @propname: name of the firmware property representing the GPIO
* @dflags: GPIO initialization flags
*
*
* This function can be used for drivers that get their configuration
* This function can be used for drivers that get their configuration
* from firmware.
* from firmware.
...
@@ -3309,12 +3310,18 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
...
@@ -3309,12 +3310,18 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
* underlying firmware interface and then makes sure that the GPIO
* underlying firmware interface and then makes sure that the GPIO
* descriptor is requested before it is returned to the caller.
* descriptor is requested before it is returned to the caller.
*
*
* On successfull request the GPIO pin is configured in accordance with
* provided @dflags.
*
* In case of error an ERR_PTR() is returned.
* In case of error an ERR_PTR() is returned.
*/
*/
struct
gpio_desc
*
fwnode_get_named_gpiod
(
struct
fwnode_handle
*
fwnode
,
struct
gpio_desc
*
fwnode_get_named_gpiod
(
struct
fwnode_handle
*
fwnode
,
const
char
*
propname
)
const
char
*
propname
,
enum
gpiod_flags
dflags
,
const
char
*
label
)
{
{
struct
gpio_desc
*
desc
=
ERR_PTR
(
-
ENODEV
);
struct
gpio_desc
*
desc
=
ERR_PTR
(
-
ENODEV
);
unsigned
long
lflags
=
0
;
bool
active_low
=
false
;
bool
active_low
=
false
;
bool
single_ended
=
false
;
bool
single_ended
=
false
;
int
ret
;
int
ret
;
...
@@ -3342,18 +3349,24 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
...
@@ -3342,18 +3349,24 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
if
(
IS_ERR
(
desc
))
if
(
IS_ERR
(
desc
))
return
desc
;
return
desc
;
ret
=
gpiod_request
(
desc
,
NULL
);
ret
=
gpiod_request
(
desc
,
label
);
if
(
ret
)
if
(
ret
)
return
ERR_PTR
(
ret
);
return
ERR_PTR
(
ret
);
if
(
active_low
)
if
(
active_low
)
set_bit
(
FLAG_ACTIVE_LOW
,
&
desc
->
flags
)
;
lflags
|=
GPIO_ACTIVE_LOW
;
if
(
single_ended
)
{
if
(
single_ended
)
{
if
(
active_low
)
if
(
active_low
)
set_bit
(
FLAG_OPEN_DRAIN
,
&
desc
->
flags
)
;
lflags
|=
GPIO_OPEN_DRAIN
;
else
else
set_bit
(
FLAG_OPEN_SOURCE
,
&
desc
->
flags
);
lflags
|=
GPIO_OPEN_SOURCE
;
}
ret
=
gpiod_configure_flags
(
desc
,
propname
,
lflags
,
dflags
);
if
(
ret
<
0
)
{
gpiod_put
(
desc
);
return
ERR_PTR
(
ret
);
}
}
return
desc
;
return
desc
;
...
...
drivers/input/keyboard/gpio_keys.c
浏览文件 @
8c541b11
...
@@ -481,7 +481,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
...
@@ -481,7 +481,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
spin_lock_init
(
&
bdata
->
lock
);
spin_lock_init
(
&
bdata
->
lock
);
if
(
child
)
{
if
(
child
)
{
bdata
->
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
child
);
bdata
->
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
child
,
GPIOD_IN
,
desc
);
if
(
IS_ERR
(
bdata
->
gpiod
))
{
if
(
IS_ERR
(
bdata
->
gpiod
))
{
error
=
PTR_ERR
(
bdata
->
gpiod
);
error
=
PTR_ERR
(
bdata
->
gpiod
);
if
(
error
==
-
ENOENT
)
{
if
(
error
==
-
ENOENT
)
{
...
@@ -496,13 +497,6 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
...
@@ -496,13 +497,6 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
error
);
error
);
return
error
;
return
error
;
}
}
}
else
{
error
=
gpiod_direction_input
(
bdata
->
gpiod
);
if
(
error
)
{
dev_err
(
dev
,
"Failed to configure GPIO %d as input: %d
\n
"
,
desc_to_gpio
(
bdata
->
gpiod
),
error
);
return
error
;
}
}
}
}
else
if
(
gpio_is_valid
(
button
->
gpio
))
{
}
else
if
(
gpio_is_valid
(
button
->
gpio
))
{
/*
/*
...
...
drivers/input/keyboard/gpio_keys_polled.c
浏览文件 @
8c541b11
...
@@ -304,7 +304,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
...
@@ -304,7 +304,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
}
}
bdata
->
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
bdata
->
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
child
);
child
,
GPIOD_IN
,
button
->
desc
);
if
(
IS_ERR
(
bdata
->
gpiod
))
{
if
(
IS_ERR
(
bdata
->
gpiod
))
{
error
=
PTR_ERR
(
bdata
->
gpiod
);
error
=
PTR_ERR
(
bdata
->
gpiod
);
if
(
error
!=
-
EPROBE_DEFER
)
if
(
error
!=
-
EPROBE_DEFER
)
...
@@ -314,14 +316,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
...
@@ -314,14 +316,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
fwnode_handle_put
(
child
);
fwnode_handle_put
(
child
);
return
error
;
return
error
;
}
}
error
=
gpiod_direction_input
(
bdata
->
gpiod
);
if
(
error
)
{
dev_err
(
dev
,
"Failed to configure GPIO %d as input: %d
\n
"
,
desc_to_gpio
(
bdata
->
gpiod
),
error
);
fwnode_handle_put
(
child
);
return
error
;
}
}
else
if
(
gpio_is_valid
(
button
->
gpio
))
{
}
else
if
(
gpio_is_valid
(
button
->
gpio
))
{
/*
/*
* Legacy GPIO number so request the GPIO here and
* Legacy GPIO number so request the GPIO here and
...
...
drivers/leds/leds-gpio.c
浏览文件 @
8c541b11
...
@@ -174,12 +174,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
...
@@ -174,12 +174,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
const
char
*
state
=
NULL
;
const
char
*
state
=
NULL
;
struct
device_node
*
np
=
to_of_node
(
child
);
struct
device_node
*
np
=
to_of_node
(
child
);
led
.
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
child
);
if
(
IS_ERR
(
led
.
gpiod
))
{
fwnode_handle_put
(
child
);
return
ERR_CAST
(
led
.
gpiod
);
}
ret
=
fwnode_property_read_string
(
child
,
"label"
,
&
led
.
name
);
ret
=
fwnode_property_read_string
(
child
,
"label"
,
&
led
.
name
);
if
(
ret
&&
IS_ENABLED
(
CONFIG_OF
)
&&
np
)
if
(
ret
&&
IS_ENABLED
(
CONFIG_OF
)
&&
np
)
led
.
name
=
np
->
name
;
led
.
name
=
np
->
name
;
...
@@ -188,6 +182,13 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
...
@@ -188,6 +182,13 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
return
ERR_PTR
(
-
EINVAL
);
return
ERR_PTR
(
-
EINVAL
);
}
}
led
.
gpiod
=
devm_get_gpiod_from_child
(
dev
,
NULL
,
child
,
GPIOD_ASIS
,
led
.
name
);
if
(
IS_ERR
(
led
.
gpiod
))
{
fwnode_handle_put
(
child
);
return
ERR_CAST
(
led
.
gpiod
);
}
fwnode_property_read_string
(
child
,
"linux,default-trigger"
,
fwnode_property_read_string
(
child
,
"linux,default-trigger"
,
&
led
.
default_trigger
);
&
led
.
default_trigger
);
...
...
drivers/video/fbdev/amba-clcd-nomadik.c
浏览文件 @
8c541b11
...
@@ -184,32 +184,31 @@ static void tpg110_init(struct device *dev, struct device_node *np,
...
@@ -184,32 +184,31 @@ static void tpg110_init(struct device *dev, struct device_node *np,
{
{
dev_info
(
dev
,
"TPG110 display init
\n
"
);
dev_info
(
dev
,
"TPG110 display init
\n
"
);
grestb
=
devm_get_gpiod_from_child
(
dev
,
"grestb"
,
&
np
->
fwnode
);
/* This asserts the GRESTB signal, putting the display into reset */
grestb
=
devm_get_gpiod_from_child
(
dev
,
"grestb"
,
&
np
->
fwnode
,
GPIOD_OUT_HIGH
,
"grestb"
);
if
(
IS_ERR
(
grestb
))
{
if
(
IS_ERR
(
grestb
))
{
dev_err
(
dev
,
"no GRESTB GPIO
\n
"
);
dev_err
(
dev
,
"no GRESTB GPIO
\n
"
);
return
;
return
;
}
}
/* This asserts the GRESTB signal, putting the display into reset */
scen
=
devm_get_gpiod_from_child
(
dev
,
"scen"
,
&
np
->
fwnode
,
gpiod_direction_output
(
grestb
,
1
);
GPIOD_OUT_LOW
,
"scen"
);
scen
=
devm_get_gpiod_from_child
(
dev
,
"scen"
,
&
np
->
fwnode
);
if
(
IS_ERR
(
scen
))
{
if
(
IS_ERR
(
scen
))
{
dev_err
(
dev
,
"no SCEN GPIO
\n
"
);
dev_err
(
dev
,
"no SCEN GPIO
\n
"
);
return
;
return
;
}
}
gpiod_direction_output
(
scen
,
0
);
scl
=
devm_get_gpiod_from_child
(
dev
,
"scl"
,
&
np
->
fwnode
,
GPIOD_OUT_LOW
,
scl
=
devm_get_gpiod_from_child
(
dev
,
"scl"
,
&
np
->
fwnode
);
"scl"
);
if
(
IS_ERR
(
scl
))
{
if
(
IS_ERR
(
scl
))
{
dev_err
(
dev
,
"no SCL GPIO
\n
"
);
dev_err
(
dev
,
"no SCL GPIO
\n
"
);
return
;
return
;
}
}
gpiod_direction_output
(
scl
,
0
);
sda
=
devm_get_gpiod_from_child
(
dev
,
"sda"
,
&
np
->
fwnode
,
GPIOD_OUT_LOW
,
sda
=
devm_get_gpiod_from_child
(
dev
,
"sda"
,
&
np
->
fwnode
);
"sda"
);
if
(
IS_ERR
(
sda
))
{
if
(
IS_ERR
(
sda
))
{
dev_err
(
dev
,
"no SDA GPIO
\n
"
);
dev_err
(
dev
,
"no SDA GPIO
\n
"
);
return
;
return
;
}
}
gpiod_direction_output
(
sda
,
0
);
board
->
enable
=
tpg110_enable
;
board
->
enable
=
tpg110_enable
;
board
->
disable
=
tpg110_disable
;
board
->
disable
=
tpg110_disable
;
}
}
...
...
include/linux/gpio/consumer.h
浏览文件 @
8c541b11
...
@@ -135,10 +135,14 @@ int desc_to_gpio(const struct gpio_desc *desc);
...
@@ -135,10 +135,14 @@ int desc_to_gpio(const struct gpio_desc *desc);
struct
fwnode_handle
;
struct
fwnode_handle
;
struct
gpio_desc
*
fwnode_get_named_gpiod
(
struct
fwnode_handle
*
fwnode
,
struct
gpio_desc
*
fwnode_get_named_gpiod
(
struct
fwnode_handle
*
fwnode
,
const
char
*
propname
);
const
char
*
propname
,
enum
gpiod_flags
dflags
,
const
char
*
label
);
struct
gpio_desc
*
devm_get_gpiod_from_child
(
struct
device
*
dev
,
struct
gpio_desc
*
devm_get_gpiod_from_child
(
struct
device
*
dev
,
const
char
*
con_id
,
const
char
*
con_id
,
struct
fwnode_handle
*
child
);
struct
fwnode_handle
*
child
,
enum
gpiod_flags
flags
,
const
char
*
label
);
#else
/* CONFIG_GPIOLIB */
#else
/* CONFIG_GPIOLIB */
static
inline
int
gpiod_count
(
struct
device
*
dev
,
const
char
*
con_id
)
static
inline
int
gpiod_count
(
struct
device
*
dev
,
const
char
*
con_id
)
...
@@ -411,14 +415,21 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
...
@@ -411,14 +415,21 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
/* Child properties interface */
/* Child properties interface */
struct
fwnode_handle
;
struct
fwnode_handle
;
static
inline
struct
gpio_desc
*
fwnode_get_named_gpiod
(
static
inline
struct
fwnode_handle
*
fwnode
,
const
char
*
propname
)
struct
gpio_desc
*
fwnode_get_named_gpiod
(
struct
fwnode_handle
*
fwnode
,
const
char
*
propname
,
enum
gpiod_flags
dflags
,
const
char
*
label
)
{
{
return
ERR_PTR
(
-
ENOSYS
);
return
ERR_PTR
(
-
ENOSYS
);
}
}
static
inline
struct
gpio_desc
*
devm_get_gpiod_from_child
(
static
inline
struct
device
*
dev
,
const
char
*
con_id
,
struct
fwnode_handle
*
child
)
struct
gpio_desc
*
devm_get_gpiod_from_child
(
struct
device
*
dev
,
const
char
*
con_id
,
struct
fwnode_handle
*
child
,
enum
gpiod_flags
flags
,
const
char
*
label
)
{
{
return
ERR_PTR
(
-
ENOSYS
);
return
ERR_PTR
(
-
ENOSYS
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录