for (i = 1; i <= 7; i++) { data->fan_min[i - 1] = w83792d_read_value(new_client, 
for (i = 0; i < 7; i++) { data->fan_min[i] = w83792d_read_value(new_client, 
w83792d_detect(struct i2c_adapter *adapter, int address, int kind){	int i = 0, val1 = 0, val2;	struct i2c_client *new_client;	struct w83792d_data *data;	int err = 0;	const char *client_name = "";	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {		goto ERROR0;	}	/* 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 w83792d_{read,write}_value. */	if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) {		err = -ENOMEM;		goto ERROR0;	}	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	init_MUTEX(&data->lock);	new_client->adapter = adapter;	new_client->driver = &w83792d_driver;	new_client->flags = 0;	/* Now, we do the remaining detection. */	/* The w83792d may be stuck in some other bank than bank 0. This may	   make reading other information impossible. Specify a force=... or	   force_*=... parameter, and the Winbond will be reset to the right	   bank. */	if (kind < 0) {		if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) {			dev_warn(&new_client->dev, "Detection failed at step "				"3\n");			goto ERROR1;		}		val1 = w83792d_read_value(new_client, W83792D_REG_BANK);		val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);		/* Check for Winbond ID if in bank 0 */		if (!(val1 & 0x07)) {  /* is Bank0 */			if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||			     ((val1 & 0x80) && (val2 != 0x5c))) {				goto ERROR1;			}		}		/* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR		   should match */		if (w83792d_read_value(new_client,					W83792D_REG_I2C_ADDR) != address) {			dev_warn(&new_client->dev, "Detection failed "				"at step 5\n");			goto ERROR1;		}	}	/* We have either had a force parameter, or we have already detected the	   Winbond. Put it now into bank 0 and Vendor ID High Byte */	w83792d_write_value(new_client,			    W83792D_REG_BANK,			    (w83792d_read_value(new_client,				W83792D_REG_BANK) & 0x78) | 0x80);	/* Determine the chip type. */	if (kind <= 0) {		/* get vendor ID */		val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);		if (val2 != 0x5c) {  /* the vendor is NOT Winbond */			goto ERROR1;		}		val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);		if (val1 == 0x7a && address >= 0x2c) {			kind = w83792d;		} else {			if (kind == 0)					dev_warn(&new_client->dev,					"w83792d: Ignoring 'force' parameter for"					" unknown chip at adapter %d, address"					" 0x%02x\n", i2c_adapter_id(adapter),					address);			goto ERROR1;		}	}	if (kind == w83792d) {		client_name = "w83792d";	} else {		dev_err(&new_client->dev, "w83792d: Internal error: unknown"					  " kind (%d)?!?", kind);		goto ERROR1;	}	/* Fill in the remaining client fields and put into the global list */	strlcpy(new_client->name, client_name, 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 ERROR1;	if ((err = w83792d_detect_subclients(adapter, address,			kind, new_client)))		goto ERROR2;	/* Initialize the chip */	w83792d_init_client(new_client);	/* A few vars need to be filled upon startup */	for (i = 1; i <= 7; i++) {		data->fan_min[i - 1] = w83792d_read_value(new_client,					W83792D_REG_FAN_MIN[i]);	}	/* 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 ERROR3;	}	device_create_file_in(new_client, 0);	device_create_file_in(new_client, 1);	device_create_file_in(new_client, 2);	device_create_file_in(new_client, 3);	device_create_file_in(new_client, 4);	device_create_file_in(new_client, 5);	device_create_file_in(new_client, 6);	device_create_file_in(new_client, 7);	device_create_file_in(new_client, 8);	device_create_file_fan(new_client, 1);	device_create_file_fan(new_client, 2);	device_create_file_fan(new_client, 3);	device_create_file_fan(new_client, 4);	device_create_file_fan(new_client, 5);	device_create_file_fan(new_client, 6);	device_create_file_fan(new_client, 7);	device_create_file_temp1(new_client);		/* Temp1 */	device_create_file_temp_add(new_client, 2);	/* Temp2 */	device_create_file_temp_add(new_client, 3);	/* Temp3 */	device_create_file_alarms(new_client);	device_create_file_pwm(new_client, 1);	device_create_file_pwm(new_client, 2);	device_create_file_pwm(new_client, 3);	device_create_file_pwmenable(new_client, 1);	device_create_file_pwmenable(new_client, 2);	device_create_file_pwmenable(new_client, 3);	device_create_file_pwm_mode(new_client, 1);	device_create_file_pwm_mode(new_client, 2);	device_create_file_pwm_mode(new_client, 3);	device_create_file_chassis(new_client);	device_create_file_chassis_clear(new_client);	device_create_file_thermal_cruise(new_client, 1);	device_create_file_thermal_cruise(new_client, 2);	device_create_file_thermal_cruise(new_client, 3);	device_create_file_tolerance(new_client, 1);	device_create_file_tolerance(new_client, 2);	device_create_file_tolerance(new_client, 3);	device_create_file_sf2_point(new_client, 1, 1);	/* Fan1 */	device_create_file_sf2_point(new_client, 2, 1);	/* Fan1 */	device_create_file_sf2_point(new_client, 3, 1);	/* Fan1 */	device_create_file_sf2_point(new_client, 4, 1);	/* Fan1 */	device_create_file_sf2_point(new_client, 1, 2);	/* Fan2 */	device_create_file_sf2_point(new_client, 2, 2);	/* Fan2 */	device_create_file_sf2_point(new_client, 3, 2);	/* Fan2 */	device_create_file_sf2_point(new_client, 4, 2);	/* Fan2 */	device_create_file_sf2_point(new_client, 1, 3);	/* Fan3 */	device_create_file_sf2_point(new_client, 2, 3);	/* Fan3 */	device_create_file_sf2_point(new_client, 3, 3);	/* Fan3 */	device_create_file_sf2_point(new_client, 4, 3);	/* Fan3 */	device_create_file_sf2_level(new_client, 1, 1);	/* Fan1 */	device_create_file_sf2_level(new_client, 2, 1);	/* Fan1 */	device_create_file_sf2_level(new_client, 3, 1);	/* Fan1 */	device_create_file_sf2_level(new_client, 1, 2);	/* Fan2 */	device_create_file_sf2_level(new_client, 2, 2);	/* Fan2 */	device_create_file_sf2_level(new_client, 3, 2);	/* Fan2 */	device_create_file_sf2_level(new_client, 1, 3);	/* Fan3 */	device_create_file_sf2_level(new_client, 2, 3);	/* Fan3 */	device_create_file_sf2_level(new_client, 3, 3);	/* Fan3 */	return 0;ERROR3:	if (data->lm75[0] != NULL) {		i2c_detach_client(data->lm75[0]);		kfree(data->lm75[0]);	}	if (data->lm75[1] != NULL) {		i2c_detach_client(data->lm75[1]);		kfree(data->lm75[1]);	}ERROR2:	i2c_detach_client(new_client);ERROR1:	kfree(data);ERROR0:	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/9632051963cb6e6f7412990f8b962209b9334e13/w83792d.c/buggy/drivers/hwmon/w83792d.c