@@ -282,20 +282,22 @@ static int snd_i2c_bit_sendbytes(struct snd_i2c_device *device,
return -EIO; /* not yet implemented */
snd_i2c_bit_start(bus);
err = snd_i2c_bit_sendbyte(bus, device->addr << 1);
- if (err < 0) {
- snd_i2c_bit_hw_stop(bus);
- return err;
- }
+ if (err < 0)
+ goto stop_bus;
+
while (count-- > 0) {
err = snd_i2c_bit_sendbyte(bus, *bytes++);
- if (err < 0) {
- snd_i2c_bit_hw_stop(bus);
- return err;
- }
+ if (err < 0)
+ goto stop_bus;
+
res++;
}
snd_i2c_bit_stop(bus);
return res;
+
+stop_bus:
+ snd_i2c_bit_hw_stop(bus);
+ return err;
}
static int snd_i2c_bit_readbytes(struct snd_i2c_device *device,
@@ -308,21 +310,23 @@ static int snd_i2c_bit_readbytes(struct snd_i2c_device *device,
return -EIO; /* not yet implemented */
snd_i2c_bit_start(bus);
err = snd_i2c_bit_sendbyte(bus, (device->addr << 1) | 1);
- if (err < 0) {
- snd_i2c_bit_hw_stop(bus);
- return err;
- }
+ if (err < 0)
+ goto stop_bus;
+
while (count-- > 0) {
err = snd_i2c_bit_readbyte(bus, count == 0);
- if (err < 0) {
- snd_i2c_bit_hw_stop(bus);
- return err;
- }
+ if (err < 0)
+ goto stop_bus;
+
*bytes++ = (unsigned char)err;
res++;
}
snd_i2c_bit_stop(bus);
return res;
+
+stop_bus:
+ snd_i2c_bit_hw_stop(bus);
+ return err;
}
static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus, unsigned short addr)