memset(data, 0, sizeof(struct gl518_data)); 
static int gl518_detect(struct i2c_adapter *adapter, int address, int kind){	int i;	struct i2c_client *new_client;	struct gl518_data *data;	int err = 0;	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 gl518_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	memset(data, 0, sizeof(struct gl518_data));	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &gl518_driver;	new_client->flags = 0;	/* Now, we do the remaining detection. */	if (kind < 0) {		if ((gl518_read_value(new_client, GL518_REG_CHIP_ID) != 0x80)		 || (gl518_read_value(new_client, GL518_REG_CONF) & 0x80))			goto exit_free;	}	/* Determine the chip type. */	if (kind <= 0) {		i = gl518_read_value(new_client, GL518_REG_REVISION);		if (i == 0x00) {			kind = gl518sm_r00;		} else if (i == 0x80) {			kind = gl518sm_r80;		} else {			if (kind <= 0)				dev_info(&adapter->dev,				    "Ignoring 'force' parameter for unknown "				    "chip at adapter %d, address 0x%02x\n",				    i2c_adapter_id(adapter), address);			goto exit_free;		}	}	/* Fill in the remaining client fields */	strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);	data->type = kind;	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 GL518SM chip */	data->alarm_mask = 0xff;	data->voltage_in[0]=data->voltage_in[1]=data->voltage_in[2]=0;	gl518_init_client((struct i2c_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_in0_input);	device_create_file(&new_client->dev, &dev_attr_in1_input);	device_create_file(&new_client->dev, &dev_attr_in2_input);	device_create_file(&new_client->dev, &dev_attr_in3_input);	device_create_file(&new_client->dev, &dev_attr_in0_min);	device_create_file(&new_client->dev, &dev_attr_in1_min);	device_create_file(&new_client->dev, &dev_attr_in2_min);	device_create_file(&new_client->dev, &dev_attr_in3_min);	device_create_file(&new_client->dev, &dev_attr_in0_max);	device_create_file(&new_client->dev, &dev_attr_in1_max);	device_create_file(&new_client->dev, &dev_attr_in2_max);	device_create_file(&new_client->dev, &dev_attr_in3_max);	device_create_file(&new_client->dev, &dev_attr_fan1_auto);	device_create_file(&new_client->dev, &dev_attr_fan1_input);	device_create_file(&new_client->dev, &dev_attr_fan2_input);	device_create_file(&new_client->dev, &dev_attr_fan1_min);	device_create_file(&new_client->dev, &dev_attr_fan2_min);	device_create_file(&new_client->dev, &dev_attr_fan1_div);	device_create_file(&new_client->dev, &dev_attr_fan2_div);	device_create_file(&new_client->dev, &dev_attr_temp1_input);	device_create_file(&new_client->dev, &dev_attr_temp1_max);	device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);	device_create_file(&new_client->dev, &dev_attr_alarms);	device_create_file(&new_client->dev, &dev_attr_beep_enable);	device_create_file(&new_client->dev, &dev_attr_beep_mask);	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/gl518sm.c/clean/drivers/hwmon/gl518sm.c