aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-07-11 04:01:00 -0400
committerJonathan Cameron <jic23@kernel.org>2012-07-12 12:57:16 -0400
commit9660ac704ec92ef535bf7c991cb7129b186007a5 (patch)
tree2ec745a051debf23ab5f24d818b8cf86978d4a67 /drivers/iio
parent3879089ba3421bc8136025837b1a532729643371 (diff)
iio: ad5064: Move bus write callbacks to #if protected sections
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>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/dac/ad5064.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index aa739c497f2b..de2c3687b3ee 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -122,25 +122,6 @@ enum ad5064_type {
122 ID_AD5668_2, 122 ID_AD5668_2,
123}; 123};
124 124
125static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
126 unsigned int addr, unsigned int val)
127{
128 struct i2c_client *i2c = to_i2c_client(st->dev);
129
130 st->data.i2c[0] = (cmd << 4) | addr;
131 put_unaligned_be16(val, &st->data.i2c[1]);
132 return i2c_master_send(i2c, st->data.i2c, 3);
133}
134
135static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
136 unsigned int addr, unsigned int val)
137{
138 struct spi_device *spi = to_spi_device(st->dev);
139
140 st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
141 return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
142}
143
144static int ad5064_write(struct ad5064_state *st, unsigned int cmd, 125static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
145 unsigned int addr, unsigned int val, unsigned int shift) 126 unsigned int addr, unsigned int val, unsigned int shift)
146{ 127{
@@ -533,6 +514,15 @@ static int __devexit ad5064_remove(struct device *dev)
533 514
534#if IS_ENABLED(CONFIG_SPI_MASTER) 515#if IS_ENABLED(CONFIG_SPI_MASTER)
535 516
517static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
518 unsigned int addr, unsigned int val)
519{
520 struct spi_device *spi = to_spi_device(st->dev);
521
522 st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
523 return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
524}
525
536static int __devinit ad5064_spi_probe(struct spi_device *spi) 526static int __devinit ad5064_spi_probe(struct spi_device *spi)
537{ 527{
538 const struct spi_device_id *id = spi_get_device_id(spi); 528 const struct spi_device_id *id = spi_get_device_id(spi);
@@ -596,6 +586,16 @@ static inline void ad5064_spi_unregister_driver(void) { }
596 586
597#if IS_ENABLED(CONFIG_I2C) 587#if IS_ENABLED(CONFIG_I2C)
598 588
589static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
590 unsigned int addr, unsigned int val)
591{
592 struct i2c_client *i2c = to_i2c_client(st->dev);
593
594 st->data.i2c[0] = (cmd << 4) | addr;
595 put_unaligned_be16(val, &st->data.i2c[1]);
596 return i2c_master_send(i2c, st->data.i2c, 3);
597}
598
599static int __devinit ad5064_i2c_probe(struct i2c_client *i2c, 599static int __devinit ad5064_i2c_probe(struct i2c_client *i2c,
600 const struct i2c_device_id *id) 600 const struct i2c_device_id *id)
601{ 601{