/* 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 eeprom_{read,write}_value. */ if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { err = -ENOMEM; goto exit; } 
/* Only check even addresses */ if (address & 1) return 0;  if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) return -ENOMEM; 
static int max6875_detect(struct i2c_adapter *adapter, int address, int kind){	struct i2c_client *new_client;	struct max6875_data *data;	int err = 0;	/* Prevent 24RF08 corruption (in case of user error) */	if (kind < 0)		i2c_smbus_xfer(adapter, address, 0, 0, 0,			       I2C_SMBUS_QUICK, NULL);	/* There are three ways we can read the EEPROM data:	   (1) I2C block reads (faster, but unsupported by most adapters)	   (2) Consecutive byte reads (100% overhead)	   (3) Regular byte data reads (200% overhead)	   The third method is not implemented by this driver because all	   known adapters support at least the second. */	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA |				     I2C_FUNC_SMBUS_BYTE |				     I2C_FUNC_SMBUS_WRITE_BYTE_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 eeprom_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	memset(data, 0, sizeof(struct max6875_data));	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &max6875_driver;	new_client->flags = 0;	/* Setup the user section */	data->blocks[max6875_eeprom_user].type    = max6875_eeprom_user;	data->blocks[max6875_eeprom_user].slices  = USER_EEPROM_SLICES;	data->blocks[max6875_eeprom_user].size    = USER_EEPROM_SIZE;	data->blocks[max6875_eeprom_user].base    = USER_EEPROM_BASE;	data->blocks[max6875_eeprom_user].data    = data->data;	data->blocks[max6875_eeprom_user].updated = data->last_updated;	/* Setup the config section */	data->blocks[max6875_eeprom_config].type    = max6875_eeprom_config;	data->blocks[max6875_eeprom_config].slices  = CONFIG_EEPROM_SLICES;	data->blocks[max6875_eeprom_config].size    = CONFIG_EEPROM_SIZE;	data->blocks[max6875_eeprom_config].base    = CONFIG_EEPROM_BASE;	data->blocks[max6875_eeprom_config].data    = &data->data[USER_EEPROM_SIZE];	data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES];	/* Setup the register section */	data->blocks[max6875_register_config].type    = max6875_register_config;	data->blocks[max6875_register_config].slices  = CONFIG_EEPROM_SLICES;	data->blocks[max6875_register_config].size    = CONFIG_EEPROM_SIZE;	data->blocks[max6875_register_config].base    = 0;	data->blocks[max6875_register_config].data    = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE];	data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES];	/* Init the data */	memset(data->data, 0xff, sizeof(data->data));	/* Fill in the remaining client fields */	strlcpy(new_client->name, "max6875", I2C_NAME_SIZE);	init_MUTEX(&data->update_lock);	/* Verify that the chip is really what we think it is */	if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) ||	    (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0))		goto exit_kfree;	/* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */	if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) ||	    (data->blocks[max6875_eeprom_config].data[0x42] != 0) ||	    (data->blocks[max6875_register_config].data[0x41] != 0) ||	    (data->blocks[max6875_register_config].data[0x42] != 0) ||	    (data->blocks[max6875_eeprom_config].data[0x40] !=	     data->blocks[max6875_register_config].data[0x40]))		goto exit_kfree;	/* Tell the I2C layer a new client has arrived */	if ((err = i2c_attach_client(new_client)))		goto exit_kfree;	/* create the sysfs eeprom files with the correct permissions */	if (allow_write == 0) {		user_eeprom_attr.attr.mode &= ~S_IWUGO;		user_eeprom_attr.write = NULL;		config_eeprom_attr.attr.mode &= ~S_IWUGO;		config_eeprom_attr.write = NULL;		config_register_attr.attr.mode &= ~S_IWUGO;		config_register_attr.write = NULL;	}	sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr);	sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr);	sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr);	return 0;exit_kfree:	kfree(data);exit:	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/bc769ff8f5f6e3d249bfde082653e5bf1c2b5698/max6875.c/buggy/drivers/i2c/chips/max6875.c