/* Note that we don't use the hw_write function pointer of snd_soc_codec. That's because it's too clunky: the hw_write_t prototype does not match i2c_smbus_write_byte_data(), and it's just another layer of overhead.  */
static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
/* Note that we don't use the hw_write function pointer of snd_soc_codec. That's because it's too clunky: the hw_write_t prototype does not match i2c_smbus_write_byte_data(), and it's just another layer of overhead.  */
static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
{
	u8 *cache = codec->reg_cache;
	if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG))
		return -EIO;
	if (cache[reg - CS4270_FIRSTREG] != value) {
		struct i2c_client *client = codec->control_data;
		if (i2c_smbus_write_byte_data(client, reg, value)) {
			dev_err(codec->dev, "i2c write failed\n");
			return -EIO;
		}
		cache[reg - CS4270_FIRSTREG] = value;
	}
	return 0;
}