@@ -316,6 +316,9 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep
316
316
static int hidp_output_raw_report (struct hid_device * hid , unsigned char * data , size_t count ,
317
317
unsigned char report_type )
318
318
{
319
+ struct hidp_session * session = hid -> driver_data ;
320
+ int ret ;
321
+
319
322
switch (report_type ) {
320
323
case HID_FEATURE_REPORT :
321
324
report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE ;
@@ -327,10 +330,47 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
327
330
return - EINVAL ;
328
331
}
329
332
333
+ if (mutex_lock_interruptible (& session -> report_mutex ))
334
+ return - ERESTARTSYS ;
335
+
336
+ /* Set up our wait, and send the report request to the device. */
337
+ set_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags );
330
338
if (hidp_send_ctrl_message (hid -> driver_data , report_type ,
331
- data , count ))
332
- return - ENOMEM ;
333
- return count ;
339
+ data , count )) {
340
+ ret = - ENOMEM ;
341
+ goto err ;
342
+ }
343
+
344
+ /* Wait for the ACK from the device. */
345
+ while (test_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags )) {
346
+ int res ;
347
+
348
+ res = wait_event_interruptible_timeout (session -> report_queue ,
349
+ !test_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags ),
350
+ 10 * HZ );
351
+ if (res == 0 ) {
352
+ /* timeout */
353
+ ret = - EIO ;
354
+ goto err ;
355
+ }
356
+ if (res < 0 ) {
357
+ /* signal */
358
+ ret = - ERESTARTSYS ;
359
+ goto err ;
360
+ }
361
+ }
362
+
363
+ if (!session -> output_report_success ) {
364
+ ret = - EIO ;
365
+ goto err ;
366
+ }
367
+
368
+ ret = count ;
369
+
370
+ err :
371
+ clear_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags );
372
+ mutex_unlock (& session -> report_mutex );
373
+ return ret ;
334
374
}
335
375
336
376
static void hidp_idle_timeout (unsigned long arg )
@@ -357,10 +397,12 @@ static void hidp_process_handshake(struct hidp_session *session,
357
397
unsigned char param )
358
398
{
359
399
BT_DBG ("session %p param 0x%02x" , session , param );
400
+ session -> output_report_success = 0 ; /* default condition */
360
401
361
402
switch (param ) {
362
403
case HIDP_HSHK_SUCCESSFUL :
363
404
/* FIXME: Call into SET_ GET_ handlers here */
405
+ session -> output_report_success = 1 ;
364
406
break ;
365
407
366
408
case HIDP_HSHK_NOT_READY :
@@ -385,6 +427,12 @@ static void hidp_process_handshake(struct hidp_session *session,
385
427
HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER , NULL , 0 );
386
428
break ;
387
429
}
430
+
431
+ /* Wake up the waiting thread. */
432
+ if (test_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags )) {
433
+ clear_bit (HIDP_WAITING_FOR_SEND_ACK , & session -> flags );
434
+ wake_up_interruptible (& session -> report_queue );
435
+ }
388
436
}
389
437
390
438
static void hidp_process_hid_control (struct hidp_session * session ,
0 commit comments