.. | .. |
---|
10 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ |
---|
11 | 11 | |
---|
12 | 12 | #include <linux/spi/spi.h> |
---|
| 13 | +#include <linux/regulator/consumer.h> |
---|
13 | 14 | #include <linux/ktime.h> |
---|
14 | 15 | |
---|
15 | 16 | #include <media/dvb_demux.h> |
---|
.. | .. |
---|
51 | 52 | struct mutex spi_mutex; /* For SPI access exclusive control */ |
---|
52 | 53 | int feed_count; |
---|
53 | 54 | int all_pid_feed_count; |
---|
| 55 | + struct regulator *vcc_supply; |
---|
54 | 56 | u8 *ts_buf; |
---|
55 | 57 | struct cxd2880_pid_filter_config filter_config; |
---|
56 | 58 | }; |
---|
.. | .. |
---|
518 | 520 | if (!dvb_spi) |
---|
519 | 521 | return -ENOMEM; |
---|
520 | 522 | |
---|
| 523 | + dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc"); |
---|
| 524 | + if (IS_ERR(dvb_spi->vcc_supply)) { |
---|
| 525 | + if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) { |
---|
| 526 | + ret = -EPROBE_DEFER; |
---|
| 527 | + goto fail_regulator; |
---|
| 528 | + } |
---|
| 529 | + dvb_spi->vcc_supply = NULL; |
---|
| 530 | + } else { |
---|
| 531 | + ret = regulator_enable(dvb_spi->vcc_supply); |
---|
| 532 | + if (ret) |
---|
| 533 | + goto fail_regulator; |
---|
| 534 | + } |
---|
| 535 | + |
---|
521 | 536 | dvb_spi->spi = spi; |
---|
522 | 537 | mutex_init(&dvb_spi->spi_mutex); |
---|
523 | 538 | dev_set_drvdata(&spi->dev, dvb_spi); |
---|
.. | .. |
---|
603 | 618 | fail_attach: |
---|
604 | 619 | dvb_unregister_adapter(&dvb_spi->adapter); |
---|
605 | 620 | fail_adapter: |
---|
| 621 | + if (dvb_spi->vcc_supply) |
---|
| 622 | + regulator_disable(dvb_spi->vcc_supply); |
---|
| 623 | +fail_regulator: |
---|
606 | 624 | kfree(dvb_spi); |
---|
607 | 625 | return ret; |
---|
608 | 626 | } |
---|
.. | .. |
---|
631 | 649 | dvb_frontend_detach(&dvb_spi->dvb_fe); |
---|
632 | 650 | dvb_unregister_adapter(&dvb_spi->adapter); |
---|
633 | 651 | |
---|
| 652 | + if (dvb_spi->vcc_supply) |
---|
| 653 | + regulator_disable(dvb_spi->vcc_supply); |
---|
| 654 | + |
---|
634 | 655 | kfree(dvb_spi); |
---|
635 | 656 | pr_info("cxd2880_spi remove ok.\n"); |
---|
636 | 657 | |
---|