Skip to content

Commit 177d591

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.5/amd-sfh' into for-linus
- amd-sfh driver code cleanups (Basavaraj Natikar)
2 parents e7de761 + 19b60ac commit 177d591

File tree

2 files changed

+20
-51
lines changed

2 files changed

+20
-51
lines changed

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

Lines changed: 14 additions & 33 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,56 +286,37 @@ 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);
295-
if (rc) {
296-
mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
297-
status = amd_sfh_wait_for_response
298-
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
299-
if (status != SENSOR_ENABLED)
300-
cl_data->sensor_sts[i] = SENSOR_DISABLED;
301-
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
302-
cl_data->sensor_idx[i],
303-
get_sensor_name(cl_data->sensor_idx[i]),
304-
cl_data->sensor_sts[i]);
297+
rc = amdtp_hid_probe(i, cl_data);
298+
if (rc)
305299
goto cleanup;
306-
}
307300
} else {
308301
cl_data->sensor_sts[i] = SENSOR_DISABLED;
309-
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
310-
cl_data->sensor_idx[i],
311-
get_sensor_name(cl_data->sensor_idx[i]),
312-
cl_data->sensor_sts[i]);
313302
}
314303
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
315304
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
316305
cl_data->sensor_sts[i]);
317306
}
307+
318308
if (!cl_data->is_any_sensor_enabled ||
319309
(mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0)) {
320-
amd_sfh_hid_client_deinit(privdata);
321-
for (i = 0; i < cl_data->num_hid_devices; i++) {
322-
devm_kfree(dev, cl_data->feature_report[i]);
323-
devm_kfree(dev, in_data->input_report[i]);
324-
devm_kfree(dev, cl_data->report_descr[i]);
325-
}
326310
dev_warn(dev, "Failed to discover, sensors not enabled is %d\n", cl_data->is_any_sensor_enabled);
327-
return -EOPNOTSUPP;
311+
rc = -EOPNOTSUPP;
312+
goto cleanup;
328313
}
329314
schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
330315
return 0;
331316

332317
cleanup:
318+
amd_sfh_hid_client_deinit(privdata);
333319
for (i = 0; i < cl_data->num_hid_devices; i++) {
334-
if (in_data->sensor_virt_addr[i]) {
335-
dma_free_coherent(&privdata->pdev->dev, 8 * sizeof(int),
336-
in_data->sensor_virt_addr[i],
337-
cl_data->sensor_dma_addr[i]);
338-
}
339320
devm_kfree(dev, cl_data->feature_report[i]);
340321
devm_kfree(dev, in_data->input_report[i]);
341322
devm_kfree(dev, cl_data->report_descr[i]);

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,16 @@ static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
168168
status = amd_sfh_wait_for_response
169169
(privdata, cl_data->sensor_idx[i], ENABLE_SENSOR);
170170

171-
status = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
171+
cl_data->sensor_sts[i] = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED;
172+
}
172173

173-
if (status == SENSOR_ENABLED) {
174+
for (i = 0; i < cl_data->num_hid_devices; i++) {
175+
cl_data->cur_hid_dev = i;
176+
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
174177
cl_data->is_any_sensor_enabled = true;
175-
cl_data->sensor_sts[i] = SENSOR_ENABLED;
176178
rc = amdtp_hid_probe(i, cl_data);
177-
if (rc) {
178-
mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
179-
status = amd_sfh_wait_for_response
180-
(privdata, cl_data->sensor_idx[i], DISABLE_SENSOR);
181-
if (status == 0)
182-
status = SENSOR_DISABLED;
183-
if (status != SENSOR_ENABLED)
184-
cl_data->sensor_sts[i] = SENSOR_DISABLED;
185-
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
186-
cl_data->sensor_idx[i],
187-
get_sensor_name(cl_data->sensor_idx[i]),
188-
cl_data->sensor_sts[i]);
179+
if (rc)
189180
goto cleanup;
190-
}
191-
} else {
192-
cl_data->sensor_sts[i] = SENSOR_DISABLED;
193181
}
194182
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
195183
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),

0 commit comments

Comments
 (0)