From: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public•gmane.org>
To: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public•gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
Randy Dunlap <rdunlap-/UHa2rfvQTnk1uMJSBkQmQ@public•gmane.org>,
linux-next-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public•gmane.org>
Subject: [PATCH] iio: ad5064: Move bus write callbacks to #if protected sections
Date: Wed, 11 Jul 2012 10:01:30 +0200 [thread overview]
Message-ID: <1341993690-19125-1-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <4FFD1458.6000404-/UHa2rfvQTnk1uMJSBkQmQ@public.gmane.org>
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-/UHa2rfvQTnk1uMJSBkQmQ@public•gmane.org>
Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public•gmane.org>
---
drivers/iio/dac/ad5064.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index aa739c4..de2c368 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -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)
{
--
1.7.10.4
next prev parent reply other threads:[~2012-07-11 8:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 7:43 linux-next: Tree for July 10 Stephen Rothwell
2012-07-11 5:44 ` linux-next: Tree for July 10 (gpio/gpio-tps65910.c) Randy Dunlap
2012-07-11 8:44 ` Linus Walleij
2012-07-11 5:51 ` linux-next: Tree for July 10 (iio) Randy Dunlap
[not found] ` <4FFD1458.6000404-/UHa2rfvQTnk1uMJSBkQmQ@public.gmane.org>
2012-07-11 8:01 ` Lars-Peter Clausen [this message]
2012-07-12 19:22 ` [PATCH] iio: ad5064: Move bus write callbacks to #if protected sections Jonathan Cameron
2012-07-11 20:01 ` linux-next: Tree for July 10 (mfd/arizona-irq.c) Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1341993690-19125-1-git-send-email-lars@metafoo.de \
--to=lars-qo5elluwu/uelga04laivw@public$(echo .)gmane.org \
--cc=jic23-KWPb1pKIrIJaa/9Udqfwiw@public$(echo .)gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
--cc=linux-next-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
--cc=rdunlap-/UHa2rfvQTnk1uMJSBkQmQ@public$(echo .)gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox