memset(data, 0, sizeof(struct ds1621_data)); 
int ds1621_detect(struct i2c_adapter *adapter, int address,                  int kind){	int conf, temp;	struct i2c_client *new_client;	struct ds1621_data *data;	int err = 0;	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA 				     | I2C_FUNC_SMBUS_WORD_DATA 				     | I2C_FUNC_SMBUS_WRITE_BYTE))		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 ds1621_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	memset(data, 0, sizeof(struct ds1621_data));		new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &ds1621_driver;	new_client->flags = 0;	/* Now, we do the remaining detection. It is lousy. */	if (kind < 0) {		/* The NVB bit should be low if no EEPROM write has been 		   requested during the latest 10ms, which is highly 		   improbable in our case. */		conf = ds1621_read_value(new_client, DS1621_REG_CONF);		if (conf & DS1621_REG_CONFIG_NVB)			goto exit_free;		/* The 7 lowest bits of a temperature should always be 0. */		temp = ds1621_read_value(new_client, DS1621_REG_TEMP);		if (temp & 0x007f)			goto exit_free;		temp = ds1621_read_value(new_client, DS1621_REG_TEMP_MIN);		if (temp & 0x007f)			goto exit_free;		temp = ds1621_read_value(new_client, DS1621_REG_TEMP_MAX);		if (temp & 0x007f)			goto exit_free;	}	/* Determine the chip type - only one kind supported! */	if (kind <= 0)		kind = ds1621;	/* Fill in remaining client fields and put it into the global list */	strlcpy(new_client->name, "ds1621", 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 DS1621 chip */	ds1621_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_alarms);	device_create_file(&new_client->dev, &dev_attr_temp1_input);	device_create_file(&new_client->dev, &dev_attr_temp1_min);	device_create_file(&new_client->dev, &dev_attr_temp1_max);		return 0;/* OK, this is not exactly good programming practice, usually. But it is   very code-efficient in this case. */      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/ds1621.c/clean/drivers/hwmon/ds1621.c