linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Ranostay <matt.ranostay@intel.com>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org, Matt Ranostay <matt.ranostay@intel.com>
Subject: [PATCH 2/3] iio: pressure: bmp280: add per chip initialize function pointer
Date: Mon, 11 Apr 2016 22:21:33 -0700	[thread overview]
Message-ID: <1460438494-16135-3-git-send-email-matt.ranostay@intel.com> (raw)
In-Reply-To: <1460438494-16135-1-git-send-email-matt.ranostay@intel.com>

Some variants have functions that need to be enabled outside of an core
chip initialization.

Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
 drivers/iio/pressure/bmp280.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c
index 2e7cff38f5ff..e80cbf3b21fc 100644
--- a/drivers/iio/pressure/bmp280.c
+++ b/drivers/iio/pressure/bmp280.c
@@ -88,6 +88,9 @@ enum { bmp280, bme280 };
 struct bmp280_chip_info {
 	int id;
 	int num_channels;
+
+	/* per chip initialization function */
+	int (*init)(struct bmp280_data *);
 };
 
 static struct bmp280_chip_info bmp280_chip_info_table[] = {
@@ -336,10 +339,18 @@ static const struct iio_info bmp280_info = {
 	.read_raw = &bmp280_read_raw,
 };
 
-static int bmp280_chip_init(struct bmp280_data *data)
+static int bmp280_common_init(struct bmp280_data *data)
 {
 	int ret;
 
+	if (data->chip->init) {
+		ret = data->chip->init(data);
+		if (ret < 0) {
+			dev_err(&data->client->dev, "failed to run chip init");
+			return ret;
+		}
+	}
+
 	ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_MEAS,
 				 BMP280_OSRS_TEMP_MASK |
 				 BMP280_OSRS_PRESS_MASK |
@@ -429,7 +440,7 @@ static int bmp280_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	ret = bmp280_chip_init(data);
+	ret = bmp280_common_init(data);
 	if (ret < 0)
 		return ret;
 
-- 
1.9.1

  parent reply	other threads:[~2016-04-12  5:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12  5:21 [PATCH 0/3] iio: pressure: bmp280: add BME280 part support Matt Ranostay
2016-04-12  5:21 ` [PATCH 1/3] iio: pressure: bmp280: add initial support for multiple chips Matt Ranostay
2016-04-12  5:23   ` Peter Meerwald-Stadler
2016-04-12  5:27     ` Matt Ranostay
2016-04-17 11:51       ` Jonathan Cameron
2016-04-12  5:21 ` Matt Ranostay [this message]
2016-04-12  5:17   ` [PATCH 2/3] iio: pressure: bmp280: add per chip initialize function pointer Peter Meerwald-Stadler
2016-04-12  5:21 ` [PATCH 3/3] iio: pressure: bmp280: add humidity support Matt Ranostay
2016-04-12  5:21   ` Peter Meerwald-Stadler
2016-04-12  5:42     ` Matt Ranostay

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=1460438494-16135-3-git-send-email-matt.ranostay@intel.com \
    --to=matt.ranostay@intel.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).