7
7
// Author: Bruce zhao <[email protected] >
8
8
//
9
9
10
+ #include <linux/cleanup.h>
10
11
#include <linux/crc8.h>
11
12
#include <linux/i2c.h>
12
13
#include "aw88395_lib.h"
@@ -361,11 +362,11 @@ static int aw_dev_parse_raw_dsp_fw(unsigned char *data, unsigned int data_len,
361
362
static int aw_dev_prof_parse_multi_bin (struct aw_device * aw_dev , unsigned char * data ,
362
363
unsigned int data_len , struct aw_prof_desc * prof_desc )
363
364
{
364
- struct aw_bin * aw_bin ;
365
365
int ret ;
366
366
int i ;
367
367
368
- aw_bin = devm_kzalloc (aw_dev -> dev , data_len + sizeof (struct aw_bin ), GFP_KERNEL );
368
+ struct aw_bin * aw_bin __free (kfree ) = kzalloc (data_len + sizeof (struct aw_bin ),
369
+ GFP_KERNEL );
369
370
if (!aw_bin )
370
371
return - ENOMEM ;
371
372
@@ -375,7 +376,7 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char *
375
376
ret = aw_parsing_bin_file (aw_dev , aw_bin );
376
377
if (ret < 0 ) {
377
378
dev_err (aw_dev -> dev , "parse bin failed" );
378
- goto parse_bin_failed ;
379
+ return ret ;
379
380
}
380
381
381
382
for (i = 0 ; i < aw_bin -> all_bin_parse_num ; i ++ ) {
@@ -387,10 +388,8 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char *
387
388
data + aw_bin -> header_info [i ].valid_data_addr ;
388
389
break ;
389
390
case DATA_TYPE_DSP_REG :
390
- if (aw_bin -> header_info [i ].valid_data_len & 0x01 ) {
391
- ret = - EINVAL ;
392
- goto parse_bin_failed ;
393
- }
391
+ if (aw_bin -> header_info [i ].valid_data_len & 0x01 )
392
+ return - EINVAL ;
394
393
395
394
swab16_array ((u16 * )(data + aw_bin -> header_info [i ].valid_data_addr ),
396
395
aw_bin -> header_info [i ].valid_data_len >> 1 );
@@ -402,10 +401,8 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char *
402
401
break ;
403
402
case DATA_TYPE_DSP_FW :
404
403
case DATA_TYPE_SOC_APP :
405
- if (aw_bin -> header_info [i ].valid_data_len & 0x01 ) {
406
- ret = - EINVAL ;
407
- goto parse_bin_failed ;
408
- }
404
+ if (aw_bin -> header_info [i ].valid_data_len & 0x01 )
405
+ return - EINVAL ;
409
406
410
407
swab16_array ((u16 * )(data + aw_bin -> header_info [i ].valid_data_addr ),
411
408
aw_bin -> header_info [i ].valid_data_len >> 1 );
@@ -422,20 +419,17 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char *
422
419
}
423
420
}
424
421
prof_desc -> prof_st = AW88395_PROFILE_OK ;
425
- ret = 0 ;
426
422
427
- parse_bin_failed :
428
- devm_kfree (aw_dev -> dev , aw_bin );
429
- return ret ;
423
+ return 0 ;
430
424
}
431
425
432
426
static int aw_dev_parse_reg_bin_with_hdr (struct aw_device * aw_dev ,
433
427
uint8_t * data , uint32_t data_len , struct aw_prof_desc * prof_desc )
434
428
{
435
- struct aw_bin * aw_bin ;
436
429
int ret ;
437
430
438
- aw_bin = devm_kzalloc (aw_dev -> dev , data_len + sizeof (* aw_bin ), GFP_KERNEL );
431
+ struct aw_bin * aw_bin __free (kfree ) = kzalloc (data_len + sizeof (* aw_bin ),
432
+ GFP_KERNEL );
439
433
if (!aw_bin )
440
434
return - ENOMEM ;
441
435
@@ -445,14 +439,13 @@ static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev,
445
439
ret = aw_parsing_bin_file (aw_dev , aw_bin );
446
440
if (ret < 0 ) {
447
441
dev_err (aw_dev -> dev , "parse bin failed" );
448
- goto parse_bin_failed ;
442
+ return ret ;
449
443
}
450
444
451
445
if ((aw_bin -> all_bin_parse_num != 1 ) ||
452
446
(aw_bin -> header_info [0 ].bin_data_type != DATA_TYPE_REGISTER )) {
453
447
dev_err (aw_dev -> dev , "bin num or type error" );
454
- ret = - EINVAL ;
455
- goto parse_bin_failed ;
448
+ return - EINVAL ;
456
449
}
457
450
458
451
prof_desc -> sec_desc [AW88395_DATA_TYPE_REG ].data =
@@ -461,15 +454,7 @@ static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev,
461
454
aw_bin -> header_info [0 ].valid_data_len ;
462
455
prof_desc -> prof_st = AW88395_PROFILE_OK ;
463
456
464
- devm_kfree (aw_dev -> dev , aw_bin );
465
- aw_bin = NULL ;
466
-
467
457
return 0 ;
468
-
469
- parse_bin_failed :
470
- devm_kfree (aw_dev -> dev , aw_bin );
471
- aw_bin = NULL ;
472
- return ret ;
473
458
}
474
459
475
460
static int aw_dev_parse_data_by_sec_type (struct aw_device * aw_dev , struct aw_cfg_hdr * cfg_hdr ,
@@ -678,21 +663,21 @@ static int aw_dev_cfg_get_multiple_valid_prof(struct aw_device *aw_dev,
678
663
static int aw_dev_load_cfg_by_hdr (struct aw_device * aw_dev ,
679
664
struct aw_cfg_hdr * prof_hdr )
680
665
{
681
- struct aw_all_prof_info * all_prof_info ;
682
666
int ret ;
683
667
684
- all_prof_info = devm_kzalloc (aw_dev -> dev , sizeof (struct aw_all_prof_info ), GFP_KERNEL );
668
+ struct aw_all_prof_info * all_prof_info __free (kfree ) = kzalloc (sizeof (* all_prof_info ),
669
+ GFP_KERNEL );
685
670
if (!all_prof_info )
686
671
return - ENOMEM ;
687
672
688
673
ret = aw_dev_parse_dev_type (aw_dev , prof_hdr , all_prof_info );
689
674
if (ret < 0 ) {
690
- goto exit ;
675
+ return ret ;
691
676
} else if (ret == AW88395_DEV_TYPE_NONE ) {
692
677
dev_dbg (aw_dev -> dev , "get dev type num is 0, parse default dev" );
693
678
ret = aw_dev_parse_dev_default_type (aw_dev , prof_hdr , all_prof_info );
694
679
if (ret < 0 )
695
- goto exit ;
680
+ return ret ;
696
681
}
697
682
698
683
switch (aw_dev -> prof_data_type ) {
@@ -710,8 +695,6 @@ static int aw_dev_load_cfg_by_hdr(struct aw_device *aw_dev,
710
695
if (!ret )
711
696
aw_dev -> prof_info .prof_name_list = profile_name ;
712
697
713
- exit :
714
- devm_kfree (aw_dev -> dev , all_prof_info );
715
698
return ret ;
716
699
}
717
700
0 commit comments