Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
78a8ad79
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
161
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
78a8ad79
编写于
8月 20, 2018
作者:
J
Jiri Kosina
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-4.19/sony' into for-linus
devm_* API conversion for hid-sony
上级
16501e84
ea58c33d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
136 deletion
+28
-136
drivers/hid/hid-sony.c
drivers/hid/hid-sony.c
+28
-136
未找到文件。
drivers/hid/hid-sony.c
浏览文件 @
78a8ad79
...
...
@@ -1353,7 +1353,7 @@ static int sony_register_touchpad(struct sony_sc *sc, int touch_count,
char
*
name
;
int
ret
;
sc
->
touchpad
=
input_allocate_device
(
);
sc
->
touchpad
=
devm_input_allocate_device
(
&
sc
->
hdev
->
dev
);
if
(
!
sc
->
touchpad
)
return
-
ENOMEM
;
...
...
@@ -1370,11 +1370,9 @@ static int sony_register_touchpad(struct sony_sc *sc, int touch_count,
* DS4 compatible non-Sony devices with different names.
*/
name_sz
=
strlen
(
sc
->
hdev
->
name
)
+
sizeof
(
DS4_TOUCHPAD_SUFFIX
);
name
=
kzalloc
(
name_sz
,
GFP_KERNEL
);
if
(
!
name
)
{
ret
=
-
ENOMEM
;
goto
err
;
}
name
=
devm_kzalloc
(
&
sc
->
hdev
->
dev
,
name_sz
,
GFP_KERNEL
);
if
(
!
name
)
return
-
ENOMEM
;
snprintf
(
name
,
name_sz
,
"%s"
DS4_TOUCHPAD_SUFFIX
,
sc
->
hdev
->
name
);
sc
->
touchpad
->
name
=
name
;
...
...
@@ -1403,34 +1401,13 @@ static int sony_register_touchpad(struct sony_sc *sc, int touch_count,
ret
=
input_mt_init_slots
(
sc
->
touchpad
,
touch_count
,
INPUT_MT_POINTER
);
if
(
ret
<
0
)
goto
err
;
return
ret
;
ret
=
input_register_device
(
sc
->
touchpad
);
if
(
ret
<
0
)
goto
err
;
return
ret
;
return
0
;
err:
kfree
(
sc
->
touchpad
->
name
);
sc
->
touchpad
->
name
=
NULL
;
input_free_device
(
sc
->
touchpad
);
sc
->
touchpad
=
NULL
;
return
ret
;
}
static
void
sony_unregister_touchpad
(
struct
sony_sc
*
sc
)
{
if
(
!
sc
->
touchpad
)
return
;
kfree
(
sc
->
touchpad
->
name
);
sc
->
touchpad
->
name
=
NULL
;
input_unregister_device
(
sc
->
touchpad
);
sc
->
touchpad
=
NULL
;
}
static
int
sony_register_sensors
(
struct
sony_sc
*
sc
)
...
...
@@ -1440,7 +1417,7 @@ static int sony_register_sensors(struct sony_sc *sc)
int
ret
;
int
range
;
sc
->
sensor_dev
=
input_allocate_device
(
);
sc
->
sensor_dev
=
devm_input_allocate_device
(
&
sc
->
hdev
->
dev
);
if
(
!
sc
->
sensor_dev
)
return
-
ENOMEM
;
...
...
@@ -1457,11 +1434,9 @@ static int sony_register_sensors(struct sony_sc *sc)
* DS4 compatible non-Sony devices with different names.
*/
name_sz
=
strlen
(
sc
->
hdev
->
name
)
+
sizeof
(
SENSOR_SUFFIX
);
name
=
kzalloc
(
name_sz
,
GFP_KERNEL
);
if
(
!
name
)
{
ret
=
-
ENOMEM
;
goto
err
;
}
name
=
devm_kzalloc
(
&
sc
->
hdev
->
dev
,
name_sz
,
GFP_KERNEL
);
if
(
!
name
)
return
-
ENOMEM
;
snprintf
(
name
,
name_sz
,
"%s"
SENSOR_SUFFIX
,
sc
->
hdev
->
name
);
sc
->
sensor_dev
->
name
=
name
;
...
...
@@ -1503,33 +1478,11 @@ static int sony_register_sensors(struct sony_sc *sc)
ret
=
input_register_device
(
sc
->
sensor_dev
);
if
(
ret
<
0
)
goto
err
;
return
ret
;
return
0
;
err:
kfree
(
sc
->
sensor_dev
->
name
);
sc
->
sensor_dev
->
name
=
NULL
;
input_free_device
(
sc
->
sensor_dev
);
sc
->
sensor_dev
=
NULL
;
return
ret
;
}
static
void
sony_unregister_sensors
(
struct
sony_sc
*
sc
)
{
if
(
!
sc
->
sensor_dev
)
return
;
kfree
(
sc
->
sensor_dev
->
name
);
sc
->
sensor_dev
->
name
=
NULL
;
input_unregister_device
(
sc
->
sensor_dev
);
sc
->
sensor_dev
=
NULL
;
}
/*
* Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
* to "operational". Without this, the ps3 controller will not report any
...
...
@@ -1987,25 +1940,6 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on,
return
0
;
}
static
void
sony_leds_remove
(
struct
sony_sc
*
sc
)
{
struct
led_classdev
*
led
;
int
n
;
BUG_ON
(
!
(
sc
->
quirks
&
SONY_LED_SUPPORT
));
for
(
n
=
0
;
n
<
sc
->
led_count
;
n
++
)
{
led
=
sc
->
leds
[
n
];
sc
->
leds
[
n
]
=
NULL
;
if
(
!
led
)
continue
;
led_classdev_unregister
(
led
);
kfree
(
led
);
}
sc
->
led_count
=
0
;
}
static
int
sony_leds_init
(
struct
sony_sc
*
sc
)
{
struct
hid_device
*
hdev
=
sc
->
hdev
;
...
...
@@ -2078,11 +2012,10 @@ static int sony_leds_init(struct sony_sc *sc)
if
(
use_ds4_names
)
name_sz
=
strlen
(
dev_name
(
&
hdev
->
dev
))
+
strlen
(
ds4_name_str
[
n
])
+
2
;
led
=
kzalloc
(
sizeof
(
struct
led_classdev
)
+
name_sz
,
GFP_KERNEL
);
led
=
devm_kzalloc
(
&
hdev
->
dev
,
sizeof
(
struct
led_classdev
)
+
name_sz
,
GFP_KERNEL
);
if
(
!
led
)
{
hid_err
(
hdev
,
"Couldn't allocate memory for LED %d
\n
"
,
n
);
ret
=
-
ENOMEM
;
goto
error_leds
;
return
-
ENOMEM
;
}
name
=
(
void
*
)(
&
led
[
1
]);
...
...
@@ -2103,21 +2036,14 @@ static int sony_leds_init(struct sony_sc *sc)
sc
->
leds
[
n
]
=
led
;
ret
=
led_classdev_register
(
&
hdev
->
dev
,
led
);
ret
=
devm_
led_classdev_register
(
&
hdev
->
dev
,
led
);
if
(
ret
)
{
hid_err
(
hdev
,
"Failed to register LED %d
\n
"
,
n
);
sc
->
leds
[
n
]
=
NULL
;
kfree
(
led
);
goto
error_leds
;
return
ret
;
}
}
return
ret
;
error_leds:
sony_leds_remove
(
sc
);
return
ret
;
return
0
;
}
static
void
sixaxis_send_output_report
(
struct
sony_sc
*
sc
)
...
...
@@ -2276,16 +2202,20 @@ static int sony_allocate_output_report(struct sony_sc *sc)
if
((
sc
->
quirks
&
SIXAXIS_CONTROLLER
)
||
(
sc
->
quirks
&
NAVIGATION_CONTROLLER
))
sc
->
output_report_dmabuf
=
kmalloc
(
sizeof
(
union
sixaxis_output_report_01
),
devm_kmalloc
(
&
sc
->
hdev
->
dev
,
sizeof
(
union
sixaxis_output_report_01
),
GFP_KERNEL
);
else
if
(
sc
->
quirks
&
DUALSHOCK4_CONTROLLER_BT
)
sc
->
output_report_dmabuf
=
kmalloc
(
DS4_OUTPUT_REPORT_0x11_SIZE
,
sc
->
output_report_dmabuf
=
devm_kmalloc
(
&
sc
->
hdev
->
dev
,
DS4_OUTPUT_REPORT_0x11_SIZE
,
GFP_KERNEL
);
else
if
(
sc
->
quirks
&
(
DUALSHOCK4_CONTROLLER_USB
|
DUALSHOCK4_DONGLE
))
sc
->
output_report_dmabuf
=
kmalloc
(
DS4_OUTPUT_REPORT_0x05_SIZE
,
sc
->
output_report_dmabuf
=
devm_kmalloc
(
&
sc
->
hdev
->
dev
,
DS4_OUTPUT_REPORT_0x05_SIZE
,
GFP_KERNEL
);
else
if
(
sc
->
quirks
&
MOTION_CONTROLLER
)
sc
->
output_report_dmabuf
=
kmalloc
(
MOTION_REPORT_0x02_SIZE
,
sc
->
output_report_dmabuf
=
devm_kmalloc
(
&
sc
->
hdev
->
dev
,
MOTION_REPORT_0x02_SIZE
,
GFP_KERNEL
);
else
return
0
;
...
...
@@ -2392,36 +2322,21 @@ static int sony_battery_probe(struct sony_sc *sc, int append_dev_id)
sc
->
battery_desc
.
get_property
=
sony_battery_get_property
;
sc
->
battery_desc
.
type
=
POWER_SUPPLY_TYPE_BATTERY
;
sc
->
battery_desc
.
use_for_apm
=
0
;
sc
->
battery_desc
.
name
=
kasprintf
(
GFP_KERNEL
,
battery_str_fmt
,
sc
->
mac_address
,
sc
->
device_id
);
sc
->
battery_desc
.
name
=
devm_kasprintf
(
&
hdev
->
dev
,
GFP_KERNEL
,
battery_str_fmt
,
sc
->
mac_address
,
sc
->
device_id
);
if
(
!
sc
->
battery_desc
.
name
)
return
-
ENOMEM
;
sc
->
battery
=
power_supply_register
(
&
hdev
->
dev
,
&
sc
->
battery_desc
,
sc
->
battery
=
devm_
power_supply_register
(
&
hdev
->
dev
,
&
sc
->
battery_desc
,
&
psy_cfg
);
if
(
IS_ERR
(
sc
->
battery
))
{
ret
=
PTR_ERR
(
sc
->
battery
);
hid_err
(
hdev
,
"Unable to register battery device
\n
"
);
goto
err_free
;
return
ret
;
}
power_supply_powers
(
sc
->
battery
,
&
hdev
->
dev
);
return
0
;
err_free:
kfree
(
sc
->
battery_desc
.
name
);
sc
->
battery_desc
.
name
=
NULL
;
return
ret
;
}
static
void
sony_battery_remove
(
struct
sony_sc
*
sc
)
{
if
(
!
sc
->
battery_desc
.
name
)
return
;
power_supply_unregister
(
sc
->
battery
);
kfree
(
sc
->
battery_desc
.
name
);
sc
->
battery_desc
.
name
=
NULL
;
}
/*
...
...
@@ -2879,16 +2794,7 @@ static int sony_input_configured(struct hid_device *hdev,
device_remove_file
(
&
sc
->
hdev
->
dev
,
&
dev_attr_firmware_version
);
if
(
sc
->
hw_version
)
device_remove_file
(
&
sc
->
hdev
->
dev
,
&
dev_attr_hardware_version
);
if
(
sc
->
quirks
&
SONY_LED_SUPPORT
)
sony_leds_remove
(
sc
);
if
(
sc
->
quirks
&
SONY_BATTERY_SUPPORT
)
sony_battery_remove
(
sc
);
if
(
sc
->
touchpad
)
sony_unregister_touchpad
(
sc
);
if
(
sc
->
sensor_dev
)
sony_unregister_sensors
(
sc
);
sony_cancel_work_sync
(
sc
);
kfree
(
sc
->
output_report_dmabuf
);
sony_remove_dev_list
(
sc
);
sony_release_device_id
(
sc
);
hid_hw_stop
(
hdev
);
...
...
@@ -2965,18 +2871,6 @@ static void sony_remove(struct hid_device *hdev)
hid_hw_close
(
hdev
);
if
(
sc
->
quirks
&
SONY_LED_SUPPORT
)
sony_leds_remove
(
sc
);
if
(
sc
->
quirks
&
SONY_BATTERY_SUPPORT
)
sony_battery_remove
(
sc
);
if
(
sc
->
touchpad
)
sony_unregister_touchpad
(
sc
);
if
(
sc
->
sensor_dev
)
sony_unregister_sensors
(
sc
);
if
(
sc
->
quirks
&
DUALSHOCK4_CONTROLLER_BT
)
device_remove_file
(
&
sc
->
hdev
->
dev
,
&
dev_attr_bt_poll_interval
);
...
...
@@ -2988,8 +2882,6 @@ static void sony_remove(struct hid_device *hdev)
sony_cancel_work_sync
(
sc
);
kfree
(
sc
->
output_report_dmabuf
);
sony_remove_dev_list
(
sc
);
sony_release_device_id
(
sc
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录