Skip to content

Commit 5ca505c

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Split sensor and HID initialization
Sensors are enabled independently of HID device initialization. Sensor initialization should be kept separate in this case, while HID devices should be initialized according to the sensor state. Hence split sensor initialization and HID initialization into separate blocks. Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent e295709 commit 5ca505c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
215215
struct device *dev;
216216
u32 feature_report_size;
217217
u32 input_report_size;
218-
int rc, i, status;
218+
int rc, i;
219219
u8 cl_idx;
220220

221221
req_list = &cl_data->req_list;
@@ -286,12 +286,15 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
286286
if (rc)
287287
goto cleanup;
288288
mp2_ops->start(privdata, info);
289-
status = amd_sfh_wait_for_response
290-
(privdata, cl_data->sensor_idx[i], SENSOR_ENABLED);
291-
if (status == SENSOR_ENABLED) {
289+
cl_data->sensor_sts[i] = amd_sfh_wait_for_response
290+
(privdata, cl_data->sensor_idx[i], SENSOR_ENABLED);
291+
}
292+
293+
for (i = 0; i < cl_data->num_hid_devices; i++) {
294+
cl_data->cur_hid_dev = i;
295+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
292296
cl_data->is_any_sensor_enabled = true;
293-
cl_data->sensor_sts[i] = SENSOR_ENABLED;
294-
rc = amdtp_hid_probe(cl_data->cur_hid_dev, cl_data);
297+
rc = amdtp_hid_probe(i, cl_data);
295298
if (rc)
296299
goto cleanup;
297300
} else {
@@ -301,6 +304,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
301304
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
302305
cl_data->sensor_sts[i]);
303306
}
307+
304308
if (!cl_data->is_any_sensor_enabled ||
305309
(mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0)) {
306310
dev_warn(dev, "Failed to discover, sensors not enabled is %d\n", cl_data->is_any_sensor_enabled);

0 commit comments

Comments
 (0)