data->id = ds1337_id++; 
static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind){	struct i2c_client *new_client;	struct ds1337_data *data;	int err = 0;	const char *name = "";	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |				     I2C_FUNC_I2C))		goto exit;	if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) {		err = -ENOMEM;		goto exit;	}	memset(data, 0, sizeof(struct ds1337_data));	INIT_LIST_HEAD(&data->list);	/* The common I2C client data is placed right before the	 * DS1337-specific data. 	 */	new_client = &data->client;	i2c_set_clientdata(new_client, data);	new_client->addr = address;	new_client->adapter = adapter;	new_client->driver = &ds1337_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.	 *	 * For detection, we read registers that are most likely to cause	 * detection failure, i.e. those that have more bits with fixed	 * or reserved values.	 */	/* Default to an DS1337 if forced */	if (kind == 0)		kind = ds1337;	if (kind < 0) {		/* detection and identification */		u8 data;		/* Check that status register bits 6-2 are zero */		if ((ds1337_read(new_client, DS1337_REG_STATUS, &data) < 0) ||		    (data & 0x7c))			goto exit_free;		/* Check for a valid day register value */		if ((ds1337_read(new_client, DS1337_REG_DAY, &data) < 0) ||		    (data == 0) || (data & 0xf8))			goto exit_free;		/* Check for a valid date register value */		if ((ds1337_read(new_client, DS1337_REG_DATE, &data) < 0) ||		    (data == 0) || (data & 0xc0) || ((data & 0x0f) > 9) ||		    (data >= 0x32))			goto exit_free;		/* Check for a valid month register value */		if ((ds1337_read(new_client, DS1337_REG_MONTH, &data) < 0) ||		    (data == 0) || (data & 0x60) || ((data & 0x0f) > 9) ||		    ((data >= 0x13) && (data <= 0x19)))			goto exit_free;		/* Check that control register bits 6-5 are zero */		if ((ds1337_read(new_client, DS1337_REG_CONTROL, &data) < 0) ||		    (data & 0x60))			goto exit_free;		kind = ds1337;	}	if (kind == ds1337)		name = "ds1337";	/* We can fill in the remaining client fields */	strlcpy(new_client->name, name, I2C_NAME_SIZE);	/* Tell the I2C layer a new client has arrived */	if ((err = i2c_attach_client(new_client)))		goto exit_free;	/* Initialize the DS1337 chip */	ds1337_init_client(new_client);	/* Add client to local list */	data->id = ds1337_id++;	list_add(&data->list, &ds1337_clients);	return 0;exit_free:	kfree(data);exit:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/86919833dbeac668762ae7056ead2d35d070f622/ds1337.c/buggy/drivers/i2c/chips/ds1337.c