diff options
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/tuners/mxl5007t.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c index f3b193ac6614..4a1ea5425850 100644 --- a/drivers/media/common/tuners/mxl5007t.c +++ b/drivers/media/common/tuners/mxl5007t.c | |||
@@ -660,11 +660,11 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status) | |||
660 | s32 rf_input_level; | 660 | s32 rf_input_level; |
661 | int ret; | 661 | int ret; |
662 | 662 | ||
663 | mutex_lock(&state->lock); | ||
664 | |||
665 | if (fe->ops.i2c_gate_ctrl) | 663 | if (fe->ops.i2c_gate_ctrl) |
666 | fe->ops.i2c_gate_ctrl(fe, 1); | 664 | fe->ops.i2c_gate_ctrl(fe, 1); |
667 | 665 | ||
666 | mutex_lock(&state->lock); | ||
667 | |||
668 | ret = mxl5007t_synth_lock_status(state, &rf_locked, &ref_locked); | 668 | ret = mxl5007t_synth_lock_status(state, &rf_locked, &ref_locked); |
669 | if (mxl_fail(ret)) | 669 | if (mxl_fail(ret)) |
670 | goto fail; | 670 | goto fail; |
@@ -676,10 +676,11 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status) | |||
676 | goto fail; | 676 | goto fail; |
677 | mxl_debug("rf input power: %d", rf_input_level); | 677 | mxl_debug("rf input power: %d", rf_input_level); |
678 | fail: | 678 | fail: |
679 | mutex_unlock(&state->lock); | ||
680 | |||
679 | if (fe->ops.i2c_gate_ctrl) | 681 | if (fe->ops.i2c_gate_ctrl) |
680 | fe->ops.i2c_gate_ctrl(fe, 0); | 682 | fe->ops.i2c_gate_ctrl(fe, 0); |
681 | 683 | ||
682 | mutex_unlock(&state->lock); | ||
683 | return ret; | 684 | return ret; |
684 | } | 685 | } |
685 | 686 | ||
@@ -730,11 +731,11 @@ static int mxl5007t_set_params(struct dvb_frontend *fe, | |||
730 | return -EINVAL; | 731 | return -EINVAL; |
731 | } | 732 | } |
732 | 733 | ||
733 | mutex_lock(&state->lock); | ||
734 | |||
735 | if (fe->ops.i2c_gate_ctrl) | 734 | if (fe->ops.i2c_gate_ctrl) |
736 | fe->ops.i2c_gate_ctrl(fe, 1); | 735 | fe->ops.i2c_gate_ctrl(fe, 1); |
737 | 736 | ||
737 | mutex_lock(&state->lock); | ||
738 | |||
738 | ret = mxl5007t_tuner_init(state, mode); | 739 | ret = mxl5007t_tuner_init(state, mode); |
739 | if (mxl_fail(ret)) | 740 | if (mxl_fail(ret)) |
740 | goto fail; | 741 | goto fail; |
@@ -747,10 +748,11 @@ static int mxl5007t_set_params(struct dvb_frontend *fe, | |||
747 | state->bandwidth = (fe->ops.info.type == FE_OFDM) ? | 748 | state->bandwidth = (fe->ops.info.type == FE_OFDM) ? |
748 | params->u.ofdm.bandwidth : 0; | 749 | params->u.ofdm.bandwidth : 0; |
749 | fail: | 750 | fail: |
751 | mutex_unlock(&state->lock); | ||
752 | |||
750 | if (fe->ops.i2c_gate_ctrl) | 753 | if (fe->ops.i2c_gate_ctrl) |
751 | fe->ops.i2c_gate_ctrl(fe, 0); | 754 | fe->ops.i2c_gate_ctrl(fe, 0); |
752 | 755 | ||
753 | mutex_unlock(&state->lock); | ||
754 | return ret; | 756 | return ret; |
755 | } | 757 | } |
756 | 758 | ||
@@ -802,11 +804,11 @@ static int mxl5007t_set_analog_params(struct dvb_frontend *fe, | |||
802 | } | 804 | } |
803 | mxl_debug("setting mxl5007 to system %s", mode_name); | 805 | mxl_debug("setting mxl5007 to system %s", mode_name); |
804 | 806 | ||
805 | mutex_lock(&state->lock); | ||
806 | |||
807 | if (fe->ops.i2c_gate_ctrl) | 807 | if (fe->ops.i2c_gate_ctrl) |
808 | fe->ops.i2c_gate_ctrl(fe, 1); | 808 | fe->ops.i2c_gate_ctrl(fe, 1); |
809 | 809 | ||
810 | mutex_lock(&state->lock); | ||
811 | |||
810 | ret = mxl5007t_tuner_init(state, cable ? cbl_mode : ota_mode); | 812 | ret = mxl5007t_tuner_init(state, cable ? cbl_mode : ota_mode); |
811 | if (mxl_fail(ret)) | 813 | if (mxl_fail(ret)) |
812 | goto fail; | 814 | goto fail; |
@@ -818,10 +820,11 @@ static int mxl5007t_set_analog_params(struct dvb_frontend *fe, | |||
818 | state->frequency = freq; | 820 | state->frequency = freq; |
819 | state->bandwidth = 0; | 821 | state->bandwidth = 0; |
820 | fail: | 822 | fail: |
823 | mutex_unlock(&state->lock); | ||
824 | |||
821 | if (fe->ops.i2c_gate_ctrl) | 825 | if (fe->ops.i2c_gate_ctrl) |
822 | fe->ops.i2c_gate_ctrl(fe, 0); | 826 | fe->ops.i2c_gate_ctrl(fe, 0); |
823 | 827 | ||
824 | mutex_unlock(&state->lock); | ||
825 | return ret; | 828 | return ret; |
826 | } | 829 | } |
827 | 830 | ||
@@ -833,11 +836,11 @@ static int mxl5007t_init(struct dvb_frontend *fe) | |||
833 | int ret; | 836 | int ret; |
834 | u8 d; | 837 | u8 d; |
835 | 838 | ||
836 | mutex_lock(&state->lock); | ||
837 | |||
838 | if (fe->ops.i2c_gate_ctrl) | 839 | if (fe->ops.i2c_gate_ctrl) |
839 | fe->ops.i2c_gate_ctrl(fe, 1); | 840 | fe->ops.i2c_gate_ctrl(fe, 1); |
840 | 841 | ||
842 | mutex_lock(&state->lock); | ||
843 | |||
841 | ret = mxl5007t_read_reg(state, 0x05, &d); | 844 | ret = mxl5007t_read_reg(state, 0x05, &d); |
842 | if (mxl_fail(ret)) | 845 | if (mxl_fail(ret)) |
843 | goto fail; | 846 | goto fail; |
@@ -845,11 +848,11 @@ static int mxl5007t_init(struct dvb_frontend *fe) | |||
845 | ret = mxl5007t_write_reg(state, 0x05, d | 0x01); | 848 | ret = mxl5007t_write_reg(state, 0x05, d | 0x01); |
846 | mxl_fail(ret); | 849 | mxl_fail(ret); |
847 | fail: | 850 | fail: |
851 | mutex_unlock(&state->lock); | ||
852 | |||
848 | if (fe->ops.i2c_gate_ctrl) | 853 | if (fe->ops.i2c_gate_ctrl) |
849 | fe->ops.i2c_gate_ctrl(fe, 0); | 854 | fe->ops.i2c_gate_ctrl(fe, 0); |
850 | 855 | ||
851 | mutex_unlock(&state->lock); | ||
852 | |||
853 | return ret; | 856 | return ret; |
854 | } | 857 | } |
855 | 858 | ||
@@ -859,11 +862,11 @@ static int mxl5007t_sleep(struct dvb_frontend *fe) | |||
859 | int ret; | 862 | int ret; |
860 | u8 d; | 863 | u8 d; |
861 | 864 | ||
862 | mutex_lock(&state->lock); | ||
863 | |||
864 | if (fe->ops.i2c_gate_ctrl) | 865 | if (fe->ops.i2c_gate_ctrl) |
865 | fe->ops.i2c_gate_ctrl(fe, 1); | 866 | fe->ops.i2c_gate_ctrl(fe, 1); |
866 | 867 | ||
868 | mutex_lock(&state->lock); | ||
869 | |||
867 | ret = mxl5007t_read_reg(state, 0x05, &d); | 870 | ret = mxl5007t_read_reg(state, 0x05, &d); |
868 | if (mxl_fail(ret)) | 871 | if (mxl_fail(ret)) |
869 | goto fail; | 872 | goto fail; |
@@ -871,11 +874,11 @@ static int mxl5007t_sleep(struct dvb_frontend *fe) | |||
871 | ret = mxl5007t_write_reg(state, 0x05, d & ~0x01); | 874 | ret = mxl5007t_write_reg(state, 0x05, d & ~0x01); |
872 | mxl_fail(ret); | 875 | mxl_fail(ret); |
873 | fail: | 876 | fail: |
877 | mutex_unlock(&state->lock); | ||
878 | |||
874 | if (fe->ops.i2c_gate_ctrl) | 879 | if (fe->ops.i2c_gate_ctrl) |
875 | fe->ops.i2c_gate_ctrl(fe, 0); | 880 | fe->ops.i2c_gate_ctrl(fe, 0); |
876 | 881 | ||
877 | mutex_unlock(&state->lock); | ||
878 | |||
879 | return ret; | 882 | return ret; |
880 | } | 883 | } |
881 | 884 | ||
@@ -995,18 +998,18 @@ struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe, | |||
995 | 998 | ||
996 | mutex_init(&state->lock); | 999 | mutex_init(&state->lock); |
997 | 1000 | ||
998 | mutex_lock(&state->lock); | ||
999 | |||
1000 | if (fe->ops.i2c_gate_ctrl) | 1001 | if (fe->ops.i2c_gate_ctrl) |
1001 | fe->ops.i2c_gate_ctrl(fe, 1); | 1002 | fe->ops.i2c_gate_ctrl(fe, 1); |
1002 | 1003 | ||
1004 | mutex_lock(&state->lock); | ||
1005 | |||
1003 | ret = mxl5007t_get_chip_id(state); | 1006 | ret = mxl5007t_get_chip_id(state); |
1004 | 1007 | ||
1008 | mutex_unlock(&state->lock); | ||
1009 | |||
1005 | if (fe->ops.i2c_gate_ctrl) | 1010 | if (fe->ops.i2c_gate_ctrl) |
1006 | fe->ops.i2c_gate_ctrl(fe, 0); | 1011 | fe->ops.i2c_gate_ctrl(fe, 0); |
1007 | 1012 | ||
1008 | mutex_unlock(&state->lock); | ||
1009 | |||
1010 | /* check return value of mxl5007t_get_chip_id */ | 1013 | /* check return value of mxl5007t_get_chip_id */ |
1011 | if (mxl_fail(ret)) | 1014 | if (mxl_fail(ret)) |
1012 | goto fail; | 1015 | goto fail; |