@@ -215,7 +215,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
215
215
struct device * dev ;
216
216
u32 feature_report_size ;
217
217
u32 input_report_size ;
218
- int rc , i , status ;
218
+ int rc , i ;
219
219
u8 cl_idx ;
220
220
221
221
req_list = & cl_data -> req_list ;
@@ -286,56 +286,37 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
286
286
if (rc )
287
287
goto cleanup ;
288
288
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 ) {
292
296
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 )
305
299
goto cleanup ;
306
- }
307
300
} else {
308
301
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 ]);
313
302
}
314
303
dev_dbg (dev , "sid 0x%x (%s) status 0x%x\n" ,
315
304
cl_data -> sensor_idx [i ], get_sensor_name (cl_data -> sensor_idx [i ]),
316
305
cl_data -> sensor_sts [i ]);
317
306
}
307
+
318
308
if (!cl_data -> is_any_sensor_enabled ||
319
309
(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
- }
326
310
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 ;
328
313
}
329
314
schedule_delayed_work (& cl_data -> work_buffer , msecs_to_jiffies (AMD_SFH_IDLE_LOOP ));
330
315
return 0 ;
331
316
332
317
cleanup :
318
+ amd_sfh_hid_client_deinit (privdata );
333
319
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
- }
339
320
devm_kfree (dev , cl_data -> feature_report [i ]);
340
321
devm_kfree (dev , in_data -> input_report [i ]);
341
322
devm_kfree (dev , cl_data -> report_descr [i ]);
0 commit comments