diff options
| -rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 3abbff3fe888..de17a36beb6f 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
| @@ -1345,23 +1345,6 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
| 1345 | return ret; | 1345 | return ret; |
| 1346 | } | 1346 | } |
| 1347 | 1347 | ||
| 1348 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1349 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1350 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
| 1351 | if (ret != 0) | ||
| 1352 | goto err_gpio; | ||
| 1353 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
| 1354 | } | ||
| 1355 | |||
| 1356 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
| 1357 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
| 1358 | |||
| 1359 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), | ||
| 1360 | aic3x->supplies); | ||
| 1361 | if (ret != 0) { | ||
| 1362 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
| 1363 | goto err_get; | ||
| 1364 | } | ||
| 1365 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { | 1348 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { |
| 1366 | aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; | 1349 | aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; |
| 1367 | aic3x->disable_nb[i].aic3x = aic3x; | 1350 | aic3x->disable_nb[i].aic3x = aic3x; |
| @@ -1418,12 +1401,6 @@ err_notif: | |||
| 1418 | while (i--) | 1401 | while (i--) |
| 1419 | regulator_unregister_notifier(aic3x->supplies[i].consumer, | 1402 | regulator_unregister_notifier(aic3x->supplies[i].consumer, |
| 1420 | &aic3x->disable_nb[i].nb); | 1403 | &aic3x->disable_nb[i].nb); |
| 1421 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
| 1422 | err_get: | ||
| 1423 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1424 | !aic3x_is_shared_reset(aic3x)) | ||
| 1425 | gpio_free(aic3x->gpio_reset); | ||
| 1426 | err_gpio: | ||
| 1427 | return ret; | 1404 | return ret; |
| 1428 | } | 1405 | } |
| 1429 | 1406 | ||
| @@ -1434,15 +1411,9 @@ static int aic3x_remove(struct snd_soc_codec *codec) | |||
| 1434 | 1411 | ||
| 1435 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1412 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 1436 | list_del(&aic3x->list); | 1413 | list_del(&aic3x->list); |
| 1437 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1438 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1439 | gpio_set_value(aic3x->gpio_reset, 0); | ||
| 1440 | gpio_free(aic3x->gpio_reset); | ||
| 1441 | } | ||
| 1442 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | 1414 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) |
| 1443 | regulator_unregister_notifier(aic3x->supplies[i].consumer, | 1415 | regulator_unregister_notifier(aic3x->supplies[i].consumer, |
| 1444 | &aic3x->disable_nb[i].nb); | 1416 | &aic3x->disable_nb[i].nb); |
| 1445 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
| 1446 | 1417 | ||
| 1447 | return 0; | 1418 | return 0; |
| 1448 | } | 1419 | } |
| @@ -1484,7 +1455,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1484 | struct aic3x_priv *aic3x; | 1455 | struct aic3x_priv *aic3x; |
| 1485 | struct aic3x_setup_data *ai3x_setup; | 1456 | struct aic3x_setup_data *ai3x_setup; |
| 1486 | struct device_node *np = i2c->dev.of_node; | 1457 | struct device_node *np = i2c->dev.of_node; |
| 1487 | int ret; | 1458 | int ret, i; |
| 1488 | u32 value; | 1459 | u32 value; |
| 1489 | 1460 | ||
| 1490 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); | 1461 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); |
| @@ -1545,14 +1516,46 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1545 | 1516 | ||
| 1546 | aic3x->model = id->driver_data; | 1517 | aic3x->model = id->driver_data; |
| 1547 | 1518 | ||
| 1519 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1520 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1521 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
| 1522 | if (ret != 0) | ||
| 1523 | goto err; | ||
| 1524 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
| 1528 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
| 1529 | |||
| 1530 | ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies), | ||
| 1531 | aic3x->supplies); | ||
| 1532 | if (ret != 0) { | ||
| 1533 | dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); | ||
| 1534 | goto err_gpio; | ||
| 1535 | } | ||
| 1536 | |||
| 1548 | ret = snd_soc_register_codec(&i2c->dev, | 1537 | ret = snd_soc_register_codec(&i2c->dev, |
| 1549 | &soc_codec_dev_aic3x, &aic3x_dai, 1); | 1538 | &soc_codec_dev_aic3x, &aic3x_dai, 1); |
| 1550 | return ret; | 1539 | return ret; |
| 1540 | |||
| 1541 | err_gpio: | ||
| 1542 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1543 | !aic3x_is_shared_reset(aic3x)) | ||
| 1544 | gpio_free(aic3x->gpio_reset); | ||
| 1545 | err: | ||
| 1546 | return ret; | ||
| 1551 | } | 1547 | } |
| 1552 | 1548 | ||
| 1553 | static int aic3x_i2c_remove(struct i2c_client *client) | 1549 | static int aic3x_i2c_remove(struct i2c_client *client) |
| 1554 | { | 1550 | { |
| 1551 | struct aic3x_priv *aic3x = i2c_get_clientdata(client); | ||
| 1552 | |||
| 1555 | snd_soc_unregister_codec(&client->dev); | 1553 | snd_soc_unregister_codec(&client->dev); |
| 1554 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1555 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1556 | gpio_set_value(aic3x->gpio_reset, 0); | ||
| 1557 | gpio_free(aic3x->gpio_reset); | ||
| 1558 | } | ||
| 1556 | return 0; | 1559 | return 0; |
| 1557 | } | 1560 | } |
| 1558 | 1561 | ||
