diff options
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-fe.c')
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-fe.c | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c index dfe72aaec380..7f7fab7cd5af 100644 --- a/drivers/media/dvb/frontends/tda18271-fe.c +++ b/drivers/media/dvb/frontends/tda18271-fe.c | |||
@@ -31,8 +31,8 @@ static int tda18271_cal_on_startup; | |||
31 | module_param_named(cal, tda18271_cal_on_startup, int, 0644); | 31 | module_param_named(cal, tda18271_cal_on_startup, int, 0644); |
32 | MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); | 32 | MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); |
33 | 33 | ||
34 | static LIST_HEAD(tda18271_list); | ||
35 | static DEFINE_MUTEX(tda18271_list_mutex); | 34 | static DEFINE_MUTEX(tda18271_list_mutex); |
35 | static LIST_HEAD(hybrid_tuner_instance_list); | ||
36 | 36 | ||
37 | /*---------------------------------------------------------------------*/ | 37 | /*---------------------------------------------------------------------*/ |
38 | 38 | ||
@@ -986,16 +986,9 @@ static int tda18271_release(struct dvb_frontend *fe) | |||
986 | 986 | ||
987 | mutex_lock(&tda18271_list_mutex); | 987 | mutex_lock(&tda18271_list_mutex); |
988 | 988 | ||
989 | priv->count--; | 989 | if (priv) |
990 | hybrid_tuner_release_state(priv); | ||
990 | 991 | ||
991 | if (!priv->count) { | ||
992 | tda_dbg("destroying instance @ %d-%04x\n", | ||
993 | i2c_adapter_id(priv->i2c_adap), | ||
994 | priv->i2c_addr); | ||
995 | list_del(&priv->tda18271_list); | ||
996 | |||
997 | kfree(priv); | ||
998 | } | ||
999 | mutex_unlock(&tda18271_list_mutex); | 992 | mutex_unlock(&tda18271_list_mutex); |
1000 | 993 | ||
1001 | fe->tuner_priv = NULL; | 994 | fe->tuner_priv = NULL; |
@@ -1109,7 +1102,8 @@ static int tda18271_get_id(struct dvb_frontend *fe) | |||
1109 | } | 1102 | } |
1110 | 1103 | ||
1111 | tda_info("%s detected @ %d-%04x%s\n", name, | 1104 | tda_info("%s detected @ %d-%04x%s\n", name, |
1112 | i2c_adapter_id(priv->i2c_adap), priv->i2c_addr, | 1105 | i2c_adapter_id(priv->i2c_props.adap), |
1106 | priv->i2c_props.addr, | ||
1113 | (0 == ret) ? "" : ", device not supported."); | 1107 | (0 == ret) ? "" : ", device not supported."); |
1114 | 1108 | ||
1115 | return ret; | 1109 | return ret; |
@@ -1136,46 +1130,25 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1136 | struct tda18271_config *cfg) | 1130 | struct tda18271_config *cfg) |
1137 | { | 1131 | { |
1138 | struct tda18271_priv *priv = NULL; | 1132 | struct tda18271_priv *priv = NULL; |
1139 | int state_found = 0; | 1133 | int instance; |
1140 | 1134 | ||
1141 | mutex_lock(&tda18271_list_mutex); | 1135 | mutex_lock(&tda18271_list_mutex); |
1142 | 1136 | ||
1143 | list_for_each_entry(priv, &tda18271_list, tda18271_list) { | 1137 | instance = hybrid_tuner_request_state(struct tda18271_priv, priv, |
1144 | if ((i2c_adapter_id(priv->i2c_adap) == i2c_adapter_id(i2c)) && | 1138 | hybrid_tuner_instance_list, |
1145 | (priv->i2c_addr == addr)) { | 1139 | i2c, addr, "tda18271"); |
1146 | tda_dbg("attaching existing tuner @ %d-%04x\n", | 1140 | switch (instance) { |
1147 | i2c_adapter_id(priv->i2c_adap), | 1141 | case 0: |
1148 | priv->i2c_addr); | 1142 | goto fail; |
1149 | priv->count++; | 1143 | break; |
1150 | fe->tuner_priv = priv; | 1144 | case 1: |
1151 | state_found = 1; | 1145 | /* new tuner instance */ |
1152 | /* allow dvb driver to override i2c gate setting */ | ||
1153 | if ((cfg) && (cfg->gate != TDA18271_GATE_ANALOG)) | ||
1154 | priv->gate = cfg->gate; | ||
1155 | break; | ||
1156 | } | ||
1157 | } | ||
1158 | if (state_found == 0) { | ||
1159 | tda_dbg("creating new tuner instance @ %d-%04x\n", | ||
1160 | i2c_adapter_id(i2c), addr); | ||
1161 | |||
1162 | priv = kzalloc(sizeof(struct tda18271_priv), GFP_KERNEL); | ||
1163 | if (priv == NULL) { | ||
1164 | mutex_unlock(&tda18271_list_mutex); | ||
1165 | return NULL; | ||
1166 | } | ||
1167 | |||
1168 | priv->i2c_addr = addr; | ||
1169 | priv->i2c_adap = i2c; | ||
1170 | priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; | 1146 | priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; |
1171 | priv->cal_initialized = false; | 1147 | priv->cal_initialized = false; |
1172 | mutex_init(&priv->lock); | 1148 | mutex_init(&priv->lock); |
1173 | priv->count++; | ||
1174 | 1149 | ||
1175 | fe->tuner_priv = priv; | 1150 | fe->tuner_priv = priv; |
1176 | 1151 | ||
1177 | list_add_tail(&priv->tda18271_list, &tda18271_list); | ||
1178 | |||
1179 | if (tda18271_get_id(fe) < 0) | 1152 | if (tda18271_get_id(fe) < 0) |
1180 | goto fail; | 1153 | goto fail; |
1181 | 1154 | ||
@@ -1189,6 +1162,15 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1189 | tda18271_rf_cal_init(fe); | 1162 | tda18271_rf_cal_init(fe); |
1190 | 1163 | ||
1191 | mutex_unlock(&priv->lock); | 1164 | mutex_unlock(&priv->lock); |
1165 | break; | ||
1166 | default: | ||
1167 | /* existing tuner instance */ | ||
1168 | fe->tuner_priv = priv; | ||
1169 | |||
1170 | /* allow dvb driver to override i2c gate setting */ | ||
1171 | if ((cfg) && (cfg->gate != TDA18271_GATE_ANALOG)) | ||
1172 | priv->gate = cfg->gate; | ||
1173 | break; | ||
1192 | } | 1174 | } |
1193 | 1175 | ||
1194 | /* override default std map with values in config struct */ | 1176 | /* override default std map with values in config struct */ |