From: Denis Ciocca <denis.ciocca@st.com>
To: <linux-iio@vger.kernel.org>, <alexandru.Ardelean@analog.com>,
<jic23@kernel.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
Subject: [PATCH 2/5] iio:accel: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer
Date: Wed, 31 Jul 2019 14:52:47 -0700 [thread overview]
Message-ID: <20190731215250.16403-3-denis.ciocca@st.com> (raw)
In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com>
Setup buffer_setup_ops pre/post enable/disable to use
st_sensor_buffers functions for memory allocation/de-allocation.
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
---
drivers/iio/accel/st_accel_buffer.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c
index 59dcef02ec19..fc1ba52152ab 100644
--- a/drivers/iio/accel/st_accel_buffer.c
+++ b/drivers/iio/accel/st_accel_buffer.c
@@ -31,17 +31,11 @@ int st_accel_trig_set_state(struct iio_trigger *trig, bool state)
static int st_accel_buffer_postenable(struct iio_dev *indio_dev)
{
- struct st_sensor_data *adata = iio_priv(indio_dev);
int err;
- adata->buffer_data = kmalloc(indio_dev->scan_bytes,
- GFP_DMA | GFP_KERNEL);
- if (!adata->buffer_data)
- return -ENOMEM;
-
err = iio_triggered_buffer_postenable(indio_dev);
if (err < 0)
- goto st_accel_free_buffer;
+ return err;
err = st_sensors_set_axis_enable(indio_dev,
(u8)indio_dev->active_scan_mask[0]);
@@ -58,14 +52,11 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev)
st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS);
st_accel_buffer_predisable:
iio_triggered_buffer_predisable(indio_dev);
-st_accel_free_buffer:
- kfree(adata->buffer_data);
return err;
}
static int st_accel_buffer_predisable(struct iio_dev *indio_dev)
{
- struct st_sensor_data *adata = iio_priv(indio_dev);
int err, err2;
err = st_sensors_set_enable(indio_dev, false);
@@ -79,13 +70,14 @@ static int st_accel_buffer_predisable(struct iio_dev *indio_dev)
if (!err)
err = err2;
- kfree(adata->buffer_data);
return err;
}
static const struct iio_buffer_setup_ops st_accel_buffer_setup_ops = {
+ .preenable = &st_sensors_buffer_preenable,
.postenable = &st_accel_buffer_postenable,
.predisable = &st_accel_buffer_predisable,
+ .postdisable = &st_sensors_buffer_postdisable,
};
int st_accel_allocate_ring(struct iio_dev *indio_dev)
--
2.22.0
next prev parent reply other threads:[~2019-07-31 21:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 21:52 [PATCH 0/5] move buffer allocation into st_sensors_buffer Denis Ciocca
2019-07-31 21:52 ` [PATCH 1/5] iio:common: introduce st_sensors_buffer_preenable/predisable functions Denis Ciocca
2019-08-01 8:24 ` Ardelean, Alexandru
2019-08-05 15:21 ` Jonathan Cameron
2019-08-05 15:35 ` Jonathan Cameron
2019-08-05 17:18 ` Denis CIOCCA
2019-08-05 17:40 ` Denis CIOCCA
2019-07-31 21:52 ` Denis Ciocca [this message]
2019-08-01 8:24 ` [PATCH 2/5] iio:accel: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer Ardelean, Alexandru
2019-07-31 21:52 ` [PATCH 3/5] iio:gyro: " Denis Ciocca
2019-08-01 8:25 ` Ardelean, Alexandru
2019-07-31 21:52 ` [PATCH 4/5] iio:magn: " Denis Ciocca
2019-08-01 8:25 ` Ardelean, Alexandru
2019-07-31 21:52 ` [PATCH 5/5] iio:pressure: " Denis Ciocca
2019-08-01 8:25 ` Ardelean, Alexandru
2019-08-01 8:23 ` [PATCH 0/5] move buffer allocation into st_sensors_buffer Ardelean, Alexandru
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=20190731215250.16403-3-denis.ciocca@st.com \
--to=denis.ciocca@st.com \
--cc=alexandru.Ardelean@analog.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).