/* Read a value from a register in an TCM825X sensor device. The value is returned in 'val'. Returns zero if successful, or non-zero otherwise.  */
static int tcm825x_read_reg(struct i2c_client *client, int reg)
/* Read a value from a register in an TCM825X sensor device. The value is returned in 'val'. Returns zero if successful, or non-zero otherwise.  */
static int tcm825x_read_reg(struct i2c_client *client, int reg)
{
	int err;
	struct i2c_msg msg[2];
	u8 reg_buf, data_buf = 0;
	if (!client->adapter)
		return -ENODEV;
	msg[0].addr = client->addr;
	msg[0].flags = 0;
	msg[0].len = 1;
	msg[0].buf = &reg_buf;
	msg[1].addr = client->addr;
	msg[1].flags = I2C_M_RD;
	msg[1].len = 1;
	msg[1].buf = &data_buf;
	reg_buf = reg;
	err = i2c_transfer(client->adapter, msg, 2);
	if (err < 0)
		return err;
	return data_buf;
}