From: Angel Iglesias <ang.iglesiasg@gmail.com>
To: linux-iio@vger.kernel.org
Cc: Angel Iglesias <ang.iglesiasg@gmail.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andreas Klinger <ak@it-klinger.de>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/7] iio: pressure: bmp280: Add preinit callback
Date: Sun, 29 Jan 2023 02:33:04 +0100 [thread overview]
Message-ID: <f44c0fce3fa620db03ade26c8b131d62d46df1c3.1674954271.git.ang.iglesiasg@gmail.com> (raw)
In-Reply-To: <cover.1674954271.git.ang.iglesiasg@gmail.com>
Adds preinit callback to execute operations on probe before applying
initial configuration.
Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com>
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 2c8773db4b73..6467034b1d3e 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1076,6 +1076,12 @@ static const int bmp380_odr_table[][2] = {
[BMP380_ODR_0_0015HZ] = {0, 1526},
};
+static int bmp380_preinit(struct bmp280_data *data)
+{
+ /* BMP3xx requires soft-reset as part of initialization */
+ return bmp380_cmd(data, BMP380_CMD_SOFT_RESET);
+}
+
static int bmp380_chip_config(struct bmp280_data *data)
{
bool change = false, aux;
@@ -1206,6 +1212,7 @@ const struct bmp280_chip_info bmp380_chip_info = {
.read_temp = bmp380_read_temp,
.read_press = bmp380_read_press,
.read_calib = bmp380_read_calib,
+ .preinit = bmp380_preinit,
};
EXPORT_SYMBOL_NS(bmp380_chip_info, IIO_BMP280);
@@ -1605,11 +1612,11 @@ int bmp280_common_probe(struct device *dev,
return -EINVAL;
}
- /* BMP3xx requires soft-reset as part of initialization */
- if (chip_id == BMP380_CHIP_ID) {
- ret = bmp380_cmd(data, BMP380_CMD_SOFT_RESET);
- if (ret < 0)
- return ret;
+ if (data->chip_info->preinit) {
+ ret = data->chip_info->preinit(data);
+ if (ret)
+ return dev_err_probe(data->dev, ret,
+ "error running preinit tasks\n");
}
ret = data->chip_info->chip_config(data);
diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h
index 387723fd0772..be17104ef0a2 100644
--- a/drivers/iio/pressure/bmp280.h
+++ b/drivers/iio/pressure/bmp280.h
@@ -345,6 +345,7 @@ struct bmp280_chip_info {
int (*read_press)(struct bmp280_data *, int *, int *);
int (*read_humid)(struct bmp280_data *, int *, int *);
int (*read_calib)(struct bmp280_data *);
+ int (*preinit)(struct bmp280_data *);
};
/* Chip infos for each variant */
--
2.39.1
next prev parent reply other threads:[~2023-01-29 1:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 1:33 [PATCH v3 0/7] Add support for pressure sensor Bosch BMP580 Angel Iglesias
2023-01-29 1:33 ` [PATCH v3 1/7] iio: pressure: bmp280: Use chip_info pointers for each chip as driver data Angel Iglesias
2023-01-29 1:33 ` Angel Iglesias [this message]
2023-01-29 1:33 ` [PATCH v3 3/7] iio: pressure: bmp280: Make read calibration callback optional Angel Iglesias
2023-01-29 1:33 ` [PATCH v3 4/7] iio: pressure: Kconfig: Delete misleading I2C reference on bmp280 title Angel Iglesias
2023-01-29 1:33 ` [PATCH v3 5/7] iio: pressure: bmp280: Add support for new sensor BMP580 Angel Iglesias
2023-02-05 14:53 ` Jonathan Cameron
2023-02-05 23:39 ` Angel Iglesias
2023-01-29 1:33 ` [PATCH v3 6/7] dt-bindings: iio: pressure: bmp085: Add BMP580 compatible string Angel Iglesias
2023-01-29 1:33 ` [PATCH v3 7/7] iio: pressure: bmp280: Add nvmem operations for BMP580 Angel Iglesias
2023-01-30 12:29 ` Andy Shevchenko
2023-01-31 22:36 ` Angel Iglesias
2023-01-30 12:30 ` [PATCH v3 0/7] Add support for pressure sensor Bosch BMP580 Andy Shevchenko
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=f44c0fce3fa620db03ade26c8b131d62d46df1c3.1674954271.git.ang.iglesiasg@gmail.com \
--to=ang.iglesiasg@gmail.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@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
all inboxes | Powered by JetHome®