@@ -3435,15 +3435,17 @@ static int wcd938x_bind(struct device *dev)
3435
3435
wcd938x -> rxdev = wcd938x_sdw_device_get (wcd938x -> rxnode );
3436
3436
if (!wcd938x -> rxdev ) {
3437
3437
dev_err (dev , "could not find slave with matching of node\n" );
3438
- return - EINVAL ;
3438
+ ret = - EINVAL ;
3439
+ goto err_unbind ;
3439
3440
}
3440
3441
wcd938x -> sdw_priv [AIF1_PB ] = dev_get_drvdata (wcd938x -> rxdev );
3441
3442
wcd938x -> sdw_priv [AIF1_PB ]-> wcd938x = wcd938x ;
3442
3443
3443
3444
wcd938x -> txdev = wcd938x_sdw_device_get (wcd938x -> txnode );
3444
3445
if (!wcd938x -> txdev ) {
3445
3446
dev_err (dev , "could not find txslave with matching of node\n" );
3446
- return - EINVAL ;
3447
+ ret = - EINVAL ;
3448
+ goto err_put_rxdev ;
3447
3449
}
3448
3450
wcd938x -> sdw_priv [AIF1_CAP ] = dev_get_drvdata (wcd938x -> txdev );
3449
3451
wcd938x -> sdw_priv [AIF1_CAP ]-> wcd938x = wcd938x ;
@@ -3454,31 +3456,35 @@ static int wcd938x_bind(struct device *dev)
3454
3456
if (!device_link_add (wcd938x -> rxdev , wcd938x -> txdev , DL_FLAG_STATELESS |
3455
3457
DL_FLAG_PM_RUNTIME )) {
3456
3458
dev_err (dev , "could not devlink tx and rx\n" );
3457
- return - EINVAL ;
3459
+ ret = - EINVAL ;
3460
+ goto err_put_txdev ;
3458
3461
}
3459
3462
3460
3463
if (!device_link_add (dev , wcd938x -> txdev , DL_FLAG_STATELESS |
3461
3464
DL_FLAG_PM_RUNTIME )) {
3462
3465
dev_err (dev , "could not devlink wcd and tx\n" );
3463
- return - EINVAL ;
3466
+ ret = - EINVAL ;
3467
+ goto err_remove_rxtx_link ;
3464
3468
}
3465
3469
3466
3470
if (!device_link_add (dev , wcd938x -> rxdev , DL_FLAG_STATELESS |
3467
3471
DL_FLAG_PM_RUNTIME )) {
3468
3472
dev_err (dev , "could not devlink wcd and rx\n" );
3469
- return - EINVAL ;
3473
+ ret = - EINVAL ;
3474
+ goto err_remove_tx_link ;
3470
3475
}
3471
3476
3472
3477
wcd938x -> regmap = dev_get_regmap (& wcd938x -> tx_sdw_dev -> dev , NULL );
3473
3478
if (!wcd938x -> regmap ) {
3474
3479
dev_err (dev , "could not get TX device regmap\n" );
3475
- return - EINVAL ;
3480
+ ret = - EINVAL ;
3481
+ goto err_remove_rx_link ;
3476
3482
}
3477
3483
3478
3484
ret = wcd938x_irq_init (wcd938x , dev );
3479
3485
if (ret ) {
3480
3486
dev_err (dev , "%s: IRQ init failed: %d\n" , __func__ , ret );
3481
- return ret ;
3487
+ goto err_remove_rx_link ;
3482
3488
}
3483
3489
3484
3490
wcd938x -> sdw_priv [AIF1_PB ]-> slave_irq = wcd938x -> virq ;
@@ -3487,17 +3493,33 @@ static int wcd938x_bind(struct device *dev)
3487
3493
ret = wcd938x_set_micbias_data (wcd938x );
3488
3494
if (ret < 0 ) {
3489
3495
dev_err (dev , "%s: bad micbias pdata\n" , __func__ );
3490
- return ret ;
3496
+ goto err_remove_rx_link ;
3491
3497
}
3492
3498
3493
3499
ret = snd_soc_register_component (dev , & soc_codec_dev_wcd938x ,
3494
3500
wcd938x_dais , ARRAY_SIZE (wcd938x_dais ));
3495
- if (ret )
3501
+ if (ret ) {
3496
3502
dev_err (dev , "%s: Codec registration failed\n" ,
3497
3503
__func__ );
3504
+ goto err_remove_rx_link ;
3505
+ }
3498
3506
3499
- return ret ;
3507
+ return 0 ;
3500
3508
3509
+ err_remove_rx_link :
3510
+ device_link_remove (dev , wcd938x -> rxdev );
3511
+ err_remove_tx_link :
3512
+ device_link_remove (dev , wcd938x -> txdev );
3513
+ err_remove_rxtx_link :
3514
+ device_link_remove (wcd938x -> rxdev , wcd938x -> txdev );
3515
+ err_put_txdev :
3516
+ put_device (wcd938x -> txdev );
3517
+ err_put_rxdev :
3518
+ put_device (wcd938x -> rxdev );
3519
+ err_unbind :
3520
+ component_unbind_all (dev , wcd938x );
3521
+
3522
+ return ret ;
3501
3523
}
3502
3524
3503
3525
static void wcd938x_unbind (struct device * dev )
@@ -3508,6 +3530,8 @@ static void wcd938x_unbind(struct device *dev)
3508
3530
device_link_remove (dev , wcd938x -> txdev );
3509
3531
device_link_remove (dev , wcd938x -> rxdev );
3510
3532
device_link_remove (wcd938x -> rxdev , wcd938x -> txdev );
3533
+ put_device (wcd938x -> txdev );
3534
+ put_device (wcd938x -> rxdev );
3511
3535
component_unbind_all (dev , wcd938x );
3512
3536
}
3513
3537
0 commit comments