From: Lars-Peter Clausen <lars@metafoo.de>
To: Denis CIOCCA <denis.ciocca@st.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/9] iio:common: Add STMicroelectronics common library
Date: Wed, 16 Jan 2013 15:18:27 +0100 [thread overview]
Message-ID: <50F6B6B3.4030000@metafoo.de> (raw)
In-Reply-To: <1358238660-14929-2-git-send-email-denis.ciocca@st.com>
Just noticed something else while going through the individual drivers.
> diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> new file mode 100644
> index 0000000..1c69c63
> --- /dev/null
> +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> @@ -0,0 +1,83 @@
[...]
> +
> +static struct iio_trigger_ops st_sensors_trigger_ops = {
> + .owner = THIS_MODULE,
> +};
> +
> +int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
> + int (*set_trigger_state)(struct iio_trigger *trig, bool state),
> + int (*try_reenable)(struct iio_trigger *trig))
> +{
> + int err;
> + struct st_sensor_data *sdata = iio_priv(indio_dev);
> +
> + sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name);
> + if (sdata->trig == NULL) {
> + err = -ENOMEM;
> + dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n");
> + goto iio_trigger_alloc_error;
> + }
> +
> + err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev),
> + iio_trigger_generic_data_rdy_poll,
> + NULL,
> + IRQF_TRIGGER_RISING,
> + sdata->trig->name,
> + sdata->trig);
> + if (err)
> + goto request_irq_error;
> +
> + st_sensors_trigger_ops.set_trigger_state = set_trigger_state;
> + st_sensors_trigger_ops.try_reenable = try_reenable;
This is bad idea. It will break as soon as you have e.g. a gyro and and
accel driver instantiated at the same time. If you need custom trigger ops
callbacks define a custom trigger ops set per driver.
> + sdata->trig->private_data = indio_dev;
> + sdata->trig->ops = &st_sensors_trigger_ops;
> + sdata->trig->dev.parent = sdata->dev;
> +
> + err = iio_trigger_register(sdata->trig);
> + if (err < 0) {
> + dev_err(&indio_dev->dev, "failed to register iio trigger.\n");
> + goto iio_trigger_register_error;
> + }
> + indio_dev->trig = sdata->trig;
> +
> + return 0;
>
next prev parent reply other threads:[~2013-01-16 14:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 8:30 iio: STMicroelectronics iio drivers Denis CIOCCA
2013-01-15 8:30 ` [PATCH 1/9] iio:common: Add STMicroelectronics common library Denis CIOCCA
2013-01-16 14:07 ` Lars-Peter Clausen
2013-01-16 16:30 ` Denis CIOCCA
2013-01-16 17:13 ` Lars-Peter Clausen
2013-01-16 14:18 ` Lars-Peter Clausen [this message]
2013-01-15 8:30 ` [PATCH 2/9] iio:accel: Add STMicroelectronics accelerometers driver Denis CIOCCA
2013-01-16 14:28 ` Lars-Peter Clausen
2013-01-16 16:56 ` Denis CIOCCA
2013-01-16 17:16 ` Lars-Peter Clausen
2013-01-15 8:30 ` [PATCH 3/9] iio:gyro: Add STMicroelectronics gyroscopes driver Denis CIOCCA
2013-01-15 8:31 ` [PATCH 4/9] iio:magnetometer: Add STMicroelectronics magnetometers driver Denis CIOCCA
2013-01-15 22:33 ` iio: STMicroelectronics iio drivers Jonathan Cameron
2013-01-15 23:01 ` Jonathan Cameron
2013-01-15 23:06 ` Jonathan Cameron
2013-01-16 8:48 ` Jonathan Cameron
2013-01-16 11:48 ` Denis CIOCCA
2013-01-16 12:25 ` Jonathan Cameron
2013-01-16 13:36 ` Lars-Peter Clausen
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=50F6B6B3.4030000@metafoo.de \
--to=lars@metafoo.de \
--cc=denis.ciocca@st.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).