memset(data, 0, sizeof(struct lm77_data)); 
static int lm77_detect(struct i2c_adapter *adapter, int address, int kind){	struct i2c_client *new_client;	struct lm77_data *data;	int err = 0;	const char *name = "";	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |				     I2C_FUNC_SMBUS_WORD_DATA))		goto exit;	/* OK. For now, we presume we have a valid client. We now create the	   client structure, even though we cannot fill it completely yet.	   But it allows us to access lm77_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	memset(data, 0, sizeof(struct lm77_data));	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &lm77_driver;	new_client->flags = 0;	/* Here comes the remaining detection.  Since the LM77 has no	   register dedicated to identification, we have to rely on the	   following tricks:	   1. the high 4 bits represent the sign and thus they should	      always be the same	   2. the high 3 bits are unused in the configuration register	   3. addresses 0x06 and 0x07 return the last read value	   4. registers cycling over 8-address boundaries	   Word-sized registers are high-byte first. */	if (kind < 0) {		int i, cur, conf, hyst, crit, min, max;		/* addresses cycling */		cur = i2c_smbus_read_word_data(new_client, 0);		conf = i2c_smbus_read_byte_data(new_client, 1);		hyst = i2c_smbus_read_word_data(new_client, 2);		crit = i2c_smbus_read_word_data(new_client, 3);		min = i2c_smbus_read_word_data(new_client, 4);		max = i2c_smbus_read_word_data(new_client, 5);		for (i = 8; i <= 0xff; i += 8)			if (i2c_smbus_read_byte_data(new_client, i + 1) != conf			    || i2c_smbus_read_word_data(new_client, i + 2) != hyst			    || i2c_smbus_read_word_data(new_client, i + 3) != crit			    || i2c_smbus_read_word_data(new_client, i + 4) != min			    || i2c_smbus_read_word_data(new_client, i + 5) != max)				goto exit_free;		/* sign bits */		if (((cur & 0x00f0) != 0xf0 && (cur & 0x00f0) != 0x0)		    || ((hyst & 0x00f0) != 0xf0 && (hyst & 0x00f0) != 0x0)		    || ((crit & 0x00f0) != 0xf0 && (crit & 0x00f0) != 0x0)		    || ((min & 0x00f0) != 0xf0 && (min & 0x00f0) != 0x0)		    || ((max & 0x00f0) != 0xf0 && (max & 0x00f0) != 0x0))			goto exit_free;		/* unused bits */		if (conf & 0xe0)			goto exit_free;		/* 0x06 and 0x07 return the last read value */		cur = i2c_smbus_read_word_data(new_client, 0);		if (i2c_smbus_read_word_data(new_client, 6) != cur		    || i2c_smbus_read_word_data(new_client, 7) != cur)			goto exit_free;		hyst = i2c_smbus_read_word_data(new_client, 2);		if (i2c_smbus_read_word_data(new_client, 6) != hyst		    || i2c_smbus_read_word_data(new_client, 7) != hyst)			goto exit_free;		min = i2c_smbus_read_word_data(new_client, 4);		if (i2c_smbus_read_word_data(new_client, 6) != min		    || i2c_smbus_read_word_data(new_client, 7) != min)			goto exit_free;	}	/* Determine the chip type - only one kind supported! */	if (kind <= 0)		kind = lm77;	if (kind == lm77) {		name = "lm77";	}	/* Fill in the remaining client fields and put it into the global list */	strlcpy(new_client->name, name, I2C_NAME_SIZE);	data->valid = 0;	init_MUTEX(&data->update_lock);	/* Tell the I2C layer a new client has arrived */	if ((err = i2c_attach_client(new_client)))		goto exit_free;	/* Initialize the LM77 chip */	lm77_init_client(new_client);	/* Register sysfs hooks */	data->class_dev = hwmon_device_register(&new_client->dev);	if (IS_ERR(data->class_dev)) {		err = PTR_ERR(data->class_dev);		goto exit_detach;	}	device_create_file(&new_client->dev, &dev_attr_temp1_input);	device_create_file(&new_client->dev, &dev_attr_temp1_crit);	device_create_file(&new_client->dev, &dev_attr_temp1_min);	device_create_file(&new_client->dev, &dev_attr_temp1_max);	device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);	device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst);	device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);	device_create_file(&new_client->dev, &dev_attr_alarms);	return 0;exit_detach:	i2c_detach_client(new_client);exit_free:	kfree(data);exit:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ba9c2e8d15da029ea3051c95e446b2d638ef02e2/lm77.c/clean/drivers/hwmon/lm77.c