if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */ 
if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */ 
struct dvb_frontend* l64781_attach(const struct l64781_config* config,				   struct i2c_adapter* i2c){	struct l64781_state* state = NULL;	int reg0x3e = -1;	u8 b0 [] = { 0x1a };	u8 b1 [] = { 0x00 };	struct i2c_msg msg [] = { { .addr = config->demod_address, .flags = 0, .buf = b0, .len = 1 },			   { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };	/* allocate memory for the internal state */	state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL);	if (state == NULL) goto error;	/* setup the state */	state->config = config;	state->i2c = i2c;	memcpy(&state->ops, &l64781_ops, sizeof(struct dvb_frontend_ops));	state->first = 1;	/**	 *  the L64781 won't show up before we send the reset_and_configure()	 *  broadcast. If nothing responds there is no L64781 on the bus...	 */	if (reset_and_configure(state) < 0) {		dprintk("No response to reset and configure broadcast...\n");		goto error;	}	/* The chip always responds to reads */	if (i2c_transfer(state->i2c, msg, 2) != 2) {	        dprintk("No response to read on I2C bus\n");		goto error;	}	/* Save current register contents for bailout */	reg0x3e = l64781_readreg(state, 0x3e);	/* Reading the POWER_DOWN register always returns 0 */	if (reg0x3e != 0) {	        dprintk("Device doesn't look like L64781\n");		goto error;	}	/* Turn the chip off */	l64781_writereg (state, 0x3e, 0x5a);	/* Responds to all reads with 0 */	if (l64781_readreg(state, 0x1a) != 0) {	        dprintk("Read 1 returned unexpcted value\n");		goto error;	}	/* Turn the chip on */	l64781_writereg (state, 0x3e, 0xa5);	/* Responds with register default value */	if (l64781_readreg(state, 0x1a) != 0xa1) {	        dprintk("Read 2 returned unexpcted value\n");		goto error;	}	/* create dvb_frontend */	state->frontend.ops = &state->ops;	state->frontend.demodulator_priv = state;	return &state->frontend;error:	if (reg0x3e >= 0) l64781_writereg (state, 0x3e, reg0x3e);  /* restore reg 0x3e */	kfree(state);	return NULL;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/2ea7533060e361810c21b2f5ee02151c4dfb85d8/l64781.c/clean/drivers/media/dvb/frontends/l64781.c