man_id = i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID); chip_id = i2c_smbus_read_byte_data(new_client, LM90_REG_R_CHIP_ID); reg_config1 = i2c_smbus_read_byte_data(new_client, LM90_REG_R_CONFIG1); reg_convrate = i2c_smbus_read_byte_data(new_client, LM90_REG_R_CONVRATE); 
if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID, &man_id) < 0 || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID, &chip_id) < 0 || lm90_read_reg(new_client, LM90_REG_R_CONFIG1, &reg_config1) < 0 || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, &reg_convrate) < 0) goto exit_free; 
static int lm90_detect(struct i2c_adapter *adapter, int address, int kind){	struct i2c_client *new_client;	struct lm90_data *data;	int err = 0;	const char *name = "";	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))		goto exit;	if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	/* The common I2C client data is placed right before the	   LM90-specific data. */	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &lm90_driver;	new_client->flags = 0;	/*	 * Now we do the remaining detection. A negative kind means that	 * the driver was loaded with no force parameter (default), so we	 * must both detect and identify the chip. A zero kind means that	 * the driver was loaded with the force parameter, the detection	 * step shall be skipped. A positive kind means that the driver	 * was loaded with the force parameter and a given kind of chip is	 * requested, so both the detection and the identification steps	 * are skipped.	 */	/* Default to an LM90 if forced */	if (kind == 0)		kind = lm90;	if (kind < 0) { /* detection and identification */		u8 man_id, chip_id, reg_config1, reg_convrate;		man_id = i2c_smbus_read_byte_data(new_client,			 LM90_REG_R_MAN_ID);		chip_id = i2c_smbus_read_byte_data(new_client,			  LM90_REG_R_CHIP_ID);		reg_config1 = i2c_smbus_read_byte_data(new_client,			      LM90_REG_R_CONFIG1);		reg_convrate = i2c_smbus_read_byte_data(new_client,			       LM90_REG_R_CONVRATE);				if (man_id == 0x01) { /* National Semiconductor */			u8 reg_config2;			reg_config2 = i2c_smbus_read_byte_data(new_client,				      LM90_REG_R_CONFIG2);			if ((reg_config1 & 0x2A) == 0x00			 && (reg_config2 & 0xF8) == 0x00			 && reg_convrate <= 0x09) {				if (address == 0x4C				 && (chip_id & 0xF0) == 0x20) { /* LM90 */					kind = lm90;				} else				if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */					kind = lm99;				} else				if (address == 0x4C				 && (chip_id & 0xF0) == 0x10) { /* LM86 */					kind = lm86;				}			}		} else		if (man_id == 0x41) { /* Analog Devices */			if (address == 0x4C			 && (chip_id & 0xF0) == 0x40 /* ADM1032 */			 && (reg_config1 & 0x3F) == 0x00			 && reg_convrate <= 0x0A) {				kind = adm1032;			} else			if (address == 0x4c			 && chip_id == 0x51 /* ADT7461 */			 && (reg_config1 & 0x1F) == 0x00 /* check compat mode */			 && reg_convrate <= 0x0A) {				kind = adt7461;			}		} else		if (man_id == 0x4D) { /* Maxim */			/*			 * The Maxim variants do NOT have a chip_id register.			 * Reading from that address will return the last read			 * value, which in our case is those of the man_id			 * register. Likewise, the config1 register seems to			 * lack a low nibble, so the value will be those of the			 * previous read, so in our case those of the man_id			 * register.			 */			if (chip_id == man_id			 && (reg_config1 & 0x1F) == (man_id & 0x0F)			 && reg_convrate <= 0x09) {			 	kind = max6657;			}		}		if (kind <= 0) { /* identification failed */			dev_info(&adapter->dev,			    "Unsupported chip (man_id=0x%02X, "			    "chip_id=0x%02X).\n", man_id, chip_id);			goto exit_free;		}	}	if (kind == lm90) {		name = "lm90";	} else if (kind == adm1032) {		name = "adm1032";	} else if (kind == lm99) {		name = "lm99";	} else if (kind == lm86) {		name = "lm86";	} else if (kind == max6657) {		name = "max6657";	} else if (kind == adt7461) {		name = "adt7461";	}	/* We can fill in the remaining client fields */	strlcpy(new_client->name, name, I2C_NAME_SIZE);	data->valid = 0;	data->kind = kind;	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 LM90 chip */	lm90_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 exit_detach;	}	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp1_input.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp2_input.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp1_min.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp2_min.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp1_max.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp2_max.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp1_crit.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp2_crit.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp1_crit_hyst.dev_attr);	device_create_file(&new_client->dev,			   &sensor_dev_attr_temp2_crit_hyst.dev_attr);	device_create_file(&new_client->dev, &dev_attr_alarms);	return 0;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/8256fe0f40f1cd72f80f2c46fe0ab1638f03a98d/lm90.c/clean/drivers/hwmon/lm90.c