@@ -423,14 +423,38 @@ static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
423
423
return (* ppos = len );
424
424
}
425
425
426
+ static int hns3_dbg_check_cmd (struct hnae3_handle * handle , char * cmd_buf )
427
+ {
428
+ int ret = 0 ;
429
+
430
+ if (strncmp (cmd_buf , "help" , 4 ) == 0 )
431
+ hns3_dbg_help (handle );
432
+ else if (strncmp (cmd_buf , "queue info" , 10 ) == 0 )
433
+ ret = hns3_dbg_queue_info (handle , cmd_buf );
434
+ else if (strncmp (cmd_buf , "queue map" , 9 ) == 0 )
435
+ ret = hns3_dbg_queue_map (handle );
436
+ else if (strncmp (cmd_buf , "bd info" , 7 ) == 0 )
437
+ ret = hns3_dbg_bd_info (handle , cmd_buf );
438
+ else if (strncmp (cmd_buf , "dev capability" , 14 ) == 0 )
439
+ hns3_dbg_dev_caps (handle );
440
+ else if (strncmp (cmd_buf , "dev spec" , 8 ) == 0 )
441
+ hns3_dbg_dev_specs (handle );
442
+ else if (handle -> ae_algo -> ops -> dbg_run_cmd )
443
+ ret = handle -> ae_algo -> ops -> dbg_run_cmd (handle , cmd_buf );
444
+ else
445
+ ret = - EOPNOTSUPP ;
446
+
447
+ return ret ;
448
+ }
449
+
426
450
static ssize_t hns3_dbg_cmd_write (struct file * filp , const char __user * buffer ,
427
451
size_t count , loff_t * ppos )
428
452
{
429
453
struct hnae3_handle * handle = filp -> private_data ;
430
454
struct hns3_nic_priv * priv = handle -> priv ;
431
455
char * cmd_buf , * cmd_buf_tmp ;
432
456
int uncopied_bytes ;
433
- int ret = 0 ;
457
+ int ret ;
434
458
435
459
if (* ppos != 0 )
436
460
return 0 ;
@@ -461,23 +485,7 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer,
461
485
count = cmd_buf_tmp - cmd_buf + 1 ;
462
486
}
463
487
464
- if (strncmp (cmd_buf , "help" , 4 ) == 0 )
465
- hns3_dbg_help (handle );
466
- else if (strncmp (cmd_buf , "queue info" , 10 ) == 0 )
467
- ret = hns3_dbg_queue_info (handle , cmd_buf );
468
- else if (strncmp (cmd_buf , "queue map" , 9 ) == 0 )
469
- ret = hns3_dbg_queue_map (handle );
470
- else if (strncmp (cmd_buf , "bd info" , 7 ) == 0 )
471
- ret = hns3_dbg_bd_info (handle , cmd_buf );
472
- else if (strncmp (cmd_buf , "dev capability" , 14 ) == 0 )
473
- hns3_dbg_dev_caps (handle );
474
- else if (strncmp (cmd_buf , "dev spec" , 8 ) == 0 )
475
- hns3_dbg_dev_specs (handle );
476
- else if (handle -> ae_algo -> ops -> dbg_run_cmd )
477
- ret = handle -> ae_algo -> ops -> dbg_run_cmd (handle , cmd_buf );
478
- else
479
- ret = - EOPNOTSUPP ;
480
-
488
+ ret = hns3_dbg_check_cmd (handle , cmd_buf );
481
489
if (ret )
482
490
hns3_dbg_help (handle );
483
491
0 commit comments