 /* Make sure we aren't probing the ISA bus!! This is just a safety check at this moment; i2c_detect really won't call us. */ #ifdef DEBUG if (i2c_is_isa_adapter(adapter)) { dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n"); return 0; } #endif 
static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind){	int i;	struct i2c_client *new_client;	struct adm1021_data *data;	int err = 0;	const char *type_name = "";	/* Make sure we aren't probing the ISA bus!! This is just a safety check	   at this moment; i2c_detect really won't call us. */#ifdef DEBUG	if (i2c_is_isa_adapter(adapter)) {		dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n");		return 0;	}#endif	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 adm1021_{read,write}_value. */	if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) {		err = -ENOMEM;		goto error0;	}	memset(data, 0, sizeof(struct adm1021_data));	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &adm1021_driver;	new_client->flags = 0;	/* Now, we do the remaining detection. */	if (kind < 0) {		if ((adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0x03) != 0x00		 || (adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x3F) != 0x00		 || (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00) {			err = -ENODEV;			goto error1;		}	}	/* Determine the chip type. */	if (kind <= 0) {		i = adm1021_read_value(new_client, ADM1021_REG_MAN_ID);		if (i == 0x41)			if ((adm1021_read_value(new_client, ADM1021_REG_DEV_ID) & 0x0F0) == 0x030)				kind = adm1023;			else				kind = adm1021;		else if (i == 0x49)			kind = thmc10;		else if (i == 0x23)			kind = gl523sm;		else if ((i == 0x4d) &&			 (adm1021_read_value(new_client, ADM1021_REG_DEV_ID) == 0x01))			kind = max1617a;		else if (i == 0x54)			kind = mc1066;		/* LM84 Mfr ID in a different place, and it has more unused bits */		else if (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) == 0x00		      && (kind == 0 /* skip extra detection */		       || ((adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x7F) == 0x00			&& (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0xAB) == 0x00)))			kind = lm84;		else			kind = max1617;	}	if (kind == max1617) {		type_name = "max1617";	} else if (kind == max1617a) {		type_name = "max1617a";	} else if (kind == adm1021) {		type_name = "adm1021";	} else if (kind == adm1023) {		type_name = "adm1023";	} else if (kind == thmc10) {		type_name = "thmc10";	} else if (kind == lm84) {		type_name = "lm84";	} else if (kind == gl523sm) {		type_name = "gl523sm";	} else if (kind == mc1066) {		type_name = "mc1066";	}	/* Fill in the remaining client fields and put it into the global list */	strlcpy(new_client->name, type_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;	/* Initialize the ADM1021 chip */	if (kind != lm84)		adm1021_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 error2;	}	device_create_file(&new_client->dev, &dev_attr_temp1_max);	device_create_file(&new_client->dev, &dev_attr_temp1_min);	device_create_file(&new_client->dev, &dev_attr_temp1_input);	device_create_file(&new_client->dev, &dev_attr_temp2_max);	device_create_file(&new_client->dev, &dev_attr_temp2_min);	device_create_file(&new_client->dev, &dev_attr_temp2_input);	device_create_file(&new_client->dev, &dev_attr_alarms);	return 0;error2:	i2c_detach_client(new_client);error1:	kfree(data);error0:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/02ff982c6911de1484e13a1d765d7bd31a0f8fee/adm1021.c/buggy/drivers/hwmon/adm1021.c