memset(data, 0, sizeof(struct lm78_data)); 
int lm78_detect(struct i2c_adapter *adapter, int address, int kind){	int i, err;	struct i2c_client *new_client;	struct lm78_data *data;	const char *client_name = "";	int is_isa = i2c_is_isa_adapter(adapter);	if (!is_isa &&	    !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {		err = -ENODEV;		goto ERROR0;	}	/* Reserve the ISA region */	if (is_isa)		if (!request_region(address, LM78_EXTENT,				    lm78_isa_driver.name)) {			err = -EBUSY;			goto ERROR0;		}	/* Probe whether there is anything available on this address. Already	   done for SMBus clients */	if (kind < 0) {		if (is_isa) {#define REALLY_SLOW_IO			/* We need the timeouts for at least some LM78-like			   chips. But only if we read 'undefined' registers. */			i = inb_p(address + 1);			if (inb_p(address + 2) != i) {				err = -ENODEV;				goto ERROR1;			}			if (inb_p(address + 3) != i) {				err = -ENODEV;				goto ERROR1;			}			if (inb_p(address + 7) != i) {				err = -ENODEV;				goto ERROR1;			}#undef REALLY_SLOW_IO			/* Let's just hope nothing breaks here */			i = inb_p(address + 5) & 0x7f;			outb_p(~i & 0x7f, address + 5);			if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {				outb_p(i, address + 5);				err = -ENODEV;				goto ERROR1;			}		}	}	/* 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 lm78_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) {		err = -ENOMEM;		goto ERROR1;	}	memset(data, 0, sizeof(struct lm78_data));	new_client = &data->client;	if (is_isa)		init_MUTEX(&data->lock);	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver;	new_client->flags = 0;	/* Now, we do the remaining detection. */	if (kind < 0) {		if (lm78_read_value(new_client, LM78_REG_CONFIG) & 0x80) {			err = -ENODEV;			goto ERROR2;		}		if (!is_isa && (lm78_read_value(				new_client, LM78_REG_I2C_ADDR) != address)) {			err = -ENODEV;			goto ERROR2;		}	}	/* Determine the chip type. */	if (kind <= 0) {		i = lm78_read_value(new_client, LM78_REG_CHIPID);		if (i == 0x00 || i == 0x20	/* LM78 */		 || i == 0x40)			/* LM78-J */			kind = lm78;		else if ((i & 0xfe) == 0xc0)			kind = lm79;		else {			if (kind == 0)				dev_warn(&adapter->dev, "Ignoring 'force' "					"parameter for unknown chip at "					"adapter %d, address 0x%02x\n",					i2c_adapter_id(adapter), address);			err = -ENODEV;			goto ERROR2;		}	}	if (kind == lm78) {		client_name = "lm78";	} else if (kind == lm79) {		client_name = "lm79";	}	/* 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 ERROR2;	/* Initialize the LM78 chip */	lm78_init_client(new_client);	/* A few vars need to be filled upon startup */	for (i = 0; i < 3; i++) {		data->fan_min[i] = lm78_read_value(new_client,					LM78_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(&new_client->dev, &dev_attr_in0_input);	device_create_file(&new_client->dev, &dev_attr_in0_min);	device_create_file(&new_client->dev, &dev_attr_in0_max);	device_create_file(&new_client->dev, &dev_attr_in1_input);	device_create_file(&new_client->dev, &dev_attr_in1_min);	device_create_file(&new_client->dev, &dev_attr_in1_max);	device_create_file(&new_client->dev, &dev_attr_in2_input);	device_create_file(&new_client->dev, &dev_attr_in2_min);	device_create_file(&new_client->dev, &dev_attr_in2_max);	device_create_file(&new_client->dev, &dev_attr_in3_input);	device_create_file(&new_client->dev, &dev_attr_in3_min);	device_create_file(&new_client->dev, &dev_attr_in3_max);	device_create_file(&new_client->dev, &dev_attr_in4_input);	device_create_file(&new_client->dev, &dev_attr_in4_min);	device_create_file(&new_client->dev, &dev_attr_in4_max);	device_create_file(&new_client->dev, &dev_attr_in5_input);	device_create_file(&new_client->dev, &dev_attr_in5_min);	device_create_file(&new_client->dev, &dev_attr_in5_max);	device_create_file(&new_client->dev, &dev_attr_in6_input);	device_create_file(&new_client->dev, &dev_attr_in6_min);	device_create_file(&new_client->dev, &dev_attr_in6_max);	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_fan1_input);	device_create_file(&new_client->dev, &dev_attr_fan1_min);	device_create_file(&new_client->dev, &dev_attr_fan1_div);	device_create_file(&new_client->dev, &dev_attr_fan2_input);	device_create_file(&new_client->dev, &dev_attr_fan2_min);	device_create_file(&new_client->dev, &dev_attr_fan2_div);	device_create_file(&new_client->dev, &dev_attr_fan3_input);	device_create_file(&new_client->dev, &dev_attr_fan3_min);	device_create_file(&new_client->dev, &dev_attr_fan3_div);	device_create_file(&new_client->dev, &dev_attr_alarms);	device_create_file(&new_client->dev, &dev_attr_cpu0_vid);	return 0;ERROR3:	i2c_detach_client(new_client);ERROR2:	kfree(data);ERROR1:	if (is_isa)		release_region(address, LM78_EXTENT);ERROR0:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ba9c2e8d15da029ea3051c95e446b2d638ef02e2/lm78.c/buggy/drivers/hwmon/lm78.c