From: Jonathan Cameron <jic23@kernel.org>
To: Denis CIOCCA <denis.ciocca@st.com>
Cc: linux-iio@vger.kernel.org, lars@metafoo.de, j.anaszewski@samsung.com
Subject: Re: [PATCH 2/3] iio:common: Added get_buffer_element function pointer
Date: Sat, 18 May 2013 21:33:23 +0100 [thread overview]
Message-ID: <5197E593.60405@kernel.org> (raw)
In-Reply-To: <1368607493-4843-3-git-send-email-denis.ciocca@st.com>
>From a quick read, it seems to me that all that is required to make
a single function cover both cases is to tell it how many bytes
are to be read?
If so a callback seems like overkill. Of course if there are other
cases on the way for other devices this might make sense, but here
it seems there ought to be easier ways of doing this such as
adata->bytes_per_element = 2 or 3 and having the function take the
number of bytes of data when called? Or just infer it from
the iio_chan_spec structure....
Jonathan
On 05/15/2013 09:44 AM, Denis CIOCCA wrote:
> Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
> ---
> drivers/iio/accel/st_accel_core.c | 1 +
> drivers/iio/common/st_sensors/st_sensors_buffer.c | 2 +-
> drivers/iio/gyro/st_gyro_core.c | 1 +
> drivers/iio/magnetometer/st_magn_core.c | 1 +
> include/linux/iio/common/st_sensors.h | 2 ++
> 5 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 40236d5..2b8a7bd 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -454,6 +454,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
> if (err < 0)
> goto st_accel_common_probe_error;
>
> + adata->get_buffer_element = &st_sensors_get_buffer_element;
> adata->multiread_bit = adata->sensor->multi_read_bit;
> indio_dev->channels = adata->sensor->ch;
> indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS;
> diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> index 09b236d..430039d 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
> @@ -94,7 +94,7 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
> struct iio_dev *indio_dev = pf->indio_dev;
> struct st_sensor_data *sdata = iio_priv(indio_dev);
>
> - len = st_sensors_get_buffer_element(indio_dev, sdata->buffer_data);
> + len = sdata->get_buffer_element(indio_dev, sdata->buffer_data);
> if (len < 0)
> goto st_sensors_get_buffer_element_error;
>
> diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
> index 9bae46b..56e9253 100644
> --- a/drivers/iio/gyro/st_gyro_core.c
> +++ b/drivers/iio/gyro/st_gyro_core.c
> @@ -313,6 +313,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
> if (err < 0)
> goto st_gyro_common_probe_error;
>
> + gdata->get_buffer_element = &st_sensors_get_buffer_element;
> gdata->multiread_bit = gdata->sensor->multi_read_bit;
> indio_dev->channels = gdata->sensor->ch;
> indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS;
> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
> index 715d616..3208ba8 100644
> --- a/drivers/iio/magnetometer/st_magn_core.c
> +++ b/drivers/iio/magnetometer/st_magn_core.c
> @@ -356,6 +356,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
> if (err < 0)
> goto st_magn_common_probe_error;
>
> + mdata->get_buffer_element = &st_sensors_get_buffer_element;
> mdata->multiread_bit = mdata->sensor->multi_read_bit;
> indio_dev->channels = mdata->sensor->ch;
> indio_dev->num_channels = ST_SENSORS_NUMBER_ALL_CHANNELS;
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index 5ffd763..fd81707 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -203,6 +203,7 @@ struct st_sensors {
> * @buffer_data: Data used by buffer part.
> * @odr: Output data rate of the sensor [Hz].
> * @get_irq_data_ready: Function to get the IRQ used for data ready signal.
> + * @get_buffer_element: Function to get data from sensor and push on buffer.
> * @tf: Transfer function structure used by I/O operations.
> * @tb: Transfer buffers and mutex used by I/O operations.
> */
> @@ -220,6 +221,7 @@ struct st_sensor_data {
> unsigned int odr;
>
> unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev);
> + int (*get_buffer_element) (struct iio_dev *indio_dev, u8 *buf);
>
> const struct st_sensor_transfer_function *tf;
> struct st_sensor_transfer_buffer tb;
>
next prev parent reply other threads:[~2013-05-18 20:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 8:44 STMicroelectronics pressure sensors driver Denis CIOCCA
2013-05-15 8:44 ` [PATCH 1/3] iio:common: ST_SENSORS_LSM_CHANNELS macro changed Denis CIOCCA
2013-05-18 20:23 ` Jonathan Cameron
2013-05-15 8:44 ` [PATCH 2/3] iio:common: Added get_buffer_element function pointer Denis CIOCCA
2013-05-18 20:33 ` Jonathan Cameron [this message]
2013-05-15 8:44 ` [PATCH 3/3] iio:pressure: Add STMicroelectronics pressures driver Denis CIOCCA
2013-05-17 15:00 ` Jacek Anaszewski
2013-05-17 16:09 ` Denis CIOCCA
2013-05-18 21:06 ` Jonathan Cameron
2013-05-20 7:51 ` Denis CIOCCA
2013-05-20 9:47 ` Jacek Anaszewski
2013-05-22 21:27 ` Jonathan Cameron
2013-05-22 21:29 ` Jonathan Cameron
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=5197E593.60405@kernel.org \
--to=jic23@kernel.org \
--cc=denis.ciocca@st.com \
--cc=j.anaszewski@samsung.com \
--cc=lars@metafoo.de \
--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).