iio: ad5064: Move bus write callbacks to #if protected sections
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 11 Jul 2012 08:01:00 +0000 (09:01 +0100)
committerJonathan Cameron <jic23@kernel.org>
Thu, 12 Jul 2012 16:57:16 +0000 (17:57 +0100)
Move the SPI and I2C specific write callbacks to the respective
"#if IS_ENABLED(CONFIG_SPI_MASTER)" and "#if IS_ENABLED(CONFIG_I2C)"
protected sections of the code.

This fixes the following warning which occurs if CONFIG_I2C is not set:
drivers/iio/dac/ad5064.c: In function ‘ad5064_i2c_write’:
drivers/iio/dac/ad5064.c:132: error: implicit declaration of function ‘i2c_master_send’

And the follwing warning which occurs when CONFIG_SPI_MASTER is not set:
drivers/iio/dac/ad5064.c:137: warning: ‘ad5064_spi_write’ defined but not used

Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/dac/ad5064.c

index aa739c4..de2c368 100644 (file)
@@ -122,25 +122,6 @@ enum ad5064_type {
        ID_AD5668_2,
 };
 
-static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
-       unsigned int addr, unsigned int val)
-{
-       struct i2c_client *i2c = to_i2c_client(st->dev);
-
-       st->data.i2c[0] = (cmd << 4) | addr;
-       put_unaligned_be16(val, &st->data.i2c[1]);
-       return i2c_master_send(i2c, st->data.i2c, 3);
-}
-
-static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
-       unsigned int addr, unsigned int val)
-{
-       struct spi_device *spi = to_spi_device(st->dev);
-
-       st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
-       return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
-}
-
 static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
        unsigned int addr, unsigned int val, unsigned int shift)
 {
@@ -533,6 +514,15 @@ static int __devexit ad5064_remove(struct device *dev)
 
 #if IS_ENABLED(CONFIG_SPI_MASTER)
 
+static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
+       unsigned int addr, unsigned int val)
+{
+       struct spi_device *spi = to_spi_device(st->dev);
+
+       st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
+       return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
+}
+
 static int __devinit ad5064_spi_probe(struct spi_device *spi)
 {
        const struct spi_device_id *id = spi_get_device_id(spi);
@@ -596,6 +586,16 @@ static inline void ad5064_spi_unregister_driver(void) { }
 
 #if IS_ENABLED(CONFIG_I2C)
 
+static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
+       unsigned int addr, unsigned int val)
+{
+       struct i2c_client *i2c = to_i2c_client(st->dev);
+
+       st->data.i2c[0] = (cmd << 4) | addr;
+       put_unaligned_be16(val, &st->data.i2c[1]);
+       return i2c_master_send(i2c, st->data.i2c, 3);
+}
+
 static int __devinit ad5064_i2c_probe(struct i2c_client *i2c,
        const struct i2c_device_id *id)
 {