954 state->chip_id = id;
955 mxl_info("%s detected @ %d-%04x", name,
956 i2c_adapter_id(state->i2c_props.adap),
957 state->i2c_props.addr);
958 return 0;
959fail:
960 mxl_warn("unable to identify device @ %d-%04x",
961 i2c_adapter_id(state->i2c_props.adap),
962 state->i2c_props.addr);
963
964 state->chip_id = MxL_UNKNOWN_ID;
965 return ret;
966}
967
968struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,
969 struct i2c_adapter *i2c, u8 addr,
970 struct mxl5007t_config *cfg)
971{
972 struct mxl5007t_state *state = NULL;
973 int instance, ret;
974
975 mutex_lock(&mxl5007t_list_mutex);
976 instance = hybrid_tuner_request_state(struct mxl5007t_state, state,
977 hybrid_tuner_instance_list,
978 i2c, addr, "mxl5007");
979 switch (instance) {
980 case 0:
981 goto fail;
982 case 1:
983
984 state->config = cfg;
985
986 mutex_init(&state->lock);
987
988 if (fe->ops.i2c_gate_ctrl)
989 fe->ops.i2c_gate_ctrl(fe, 1);
990
991 ret = mxl5007t_get_chip_id(state);
992
993 if (fe->ops.i2c_gate_ctrl)
994 fe->ops.i2c_gate_ctrl(fe, 0);