From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
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>,
Shreeya Patel <shreeya.patel@collabora.com>,
Zhigang Shi <Zhigang.Shi@liteon.com>,
Paul Gazzillo <paul@pgazz.com>,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/5] iio: trigger: Add simple trigger_validation helper
Date: Sun, 7 May 2023 15:34:57 +0100 [thread overview]
Message-ID: <20230507153457.3b6bbfed@jic23-huawei> (raw)
In-Reply-To: <dab917aa8f2442ad10aa2a266395edd3cd7ce1d7.1683105758.git.mazziesaccount@gmail.com>
On Wed, 3 May 2023 12:48:57 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> Some triggers can only be attached to the IIO device that corresponds to
> the same physical device. Implement generic helper which can be used as
> a validate_trigger callback for such devices.
>
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>
Noticed a trivial capitalisation issue inline.
Jonathan
> ---
> Revision history
> v2: => v3:
> - Fix title (space after iio:)
> v2: New patch
> ---
> drivers/iio/industrialio-trigger.c | 22 +++++++++++++++++++++-
> include/linux/iio/trigger.h | 1 +
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
> index 784dc1e00310..c616297aa754 100644
> --- a/drivers/iio/industrialio-trigger.c
> +++ b/drivers/iio/industrialio-trigger.c
> @@ -322,7 +322,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
> * this is the case if the IIO device and the trigger device share the
> * same parent device.
> */
> - if (pf->indio_dev->dev.parent == trig->dev.parent)
> + if (iio_validate_own_trigger(pf->indio_dev, trig))
> trig->attached_own_device = true;
>
> return ret;
> @@ -728,6 +728,26 @@ bool iio_trigger_using_own(struct iio_dev *indio_dev)
> }
> EXPORT_SYMBOL(iio_trigger_using_own);
>
> +/**
> + * iio_validate_own_trigger - Check if a trigger and IIO device belong to
> + * the same device
> + * @idev: the IIO device to check
> + * @trig: The IIO trigger to check
The / the consistency needs fixing. I'm not sure on the local / file convention, but
it hopefully isn't a random mixture!
> + *
> + * This function can be used as the validate_trigger callback for triggers that
> + * can only be attached to their own device.
> + *
> + * Return: 0 if both the trigger and the IIO device belong to the same
> + * device, -EINVAL otherwise.
> + */
> +int iio_validate_own_trigger(struct iio_dev *idev, struct iio_trigger *trig)
> +{
> + if (idev->dev.parent != trig->dev.parent)
> + return -EINVAL;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(iio_validate_own_trigger);
> +
> /**
> * iio_trigger_validate_own_device - Check if a trigger and IIO device belong to
> * the same device
> diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
> index 51f52c5c6092..bce3b1788199 100644
> --- a/include/linux/iio/trigger.h
> +++ b/include/linux/iio/trigger.h
> @@ -171,6 +171,7 @@ void iio_trigger_free(struct iio_trigger *trig);
> */
> bool iio_trigger_using_own(struct iio_dev *indio_dev);
>
> +int iio_validate_own_trigger(struct iio_dev *idev, struct iio_trigger *trig);
> int iio_trigger_validate_own_device(struct iio_trigger *trig,
> struct iio_dev *indio_dev);
>
next prev parent reply other threads:[~2023-05-07 14:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 9:44 [PATCH v4 0/5] Support ROHM BU27008 RGB sensor Matti Vaittinen
2023-05-03 9:48 ` [PATCH v4 1/5] dt-bindings: iio: light: ROHM BU27008 Matti Vaittinen
2023-05-03 9:48 ` [PATCH v4 2/5] iio: trigger: Add simple trigger_validation helper Matti Vaittinen
2023-05-07 14:34 ` Jonathan Cameron [this message]
2023-05-03 9:49 ` [PATCH v4 3/5] iio: kx022a: Use new iio_validate_own_trigger() Matti Vaittinen
2023-05-03 9:50 ` [PATCH v4 4/5] iio: light: ROHM BU27008 color sensor Matti Vaittinen
2023-05-04 14:33 ` Andy Shevchenko
2023-05-05 4:56 ` Vaittinen, Matti
2023-05-08 12:23 ` Andy Shevchenko
2023-05-08 12:40 ` Matti Vaittinen
2023-05-07 14:54 ` Jonathan Cameron
2023-05-08 6:32 ` Matti Vaittinen
2023-05-13 17:52 ` Jonathan Cameron
2023-05-15 12:31 ` Matti Vaittinen
2023-05-03 9:50 ` [PATCH v4 5/5] MAINTAINERS: Add ROHM BU27008 Matti Vaittinen
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=20230507153457.3b6bbfed@jic23-huawei \
--to=jic23@kernel.org \
--cc=Zhigang.Shi@liteon.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.osipenko@collabora.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=paul@pgazz.com \
--cc=robh+dt@kernel.org \
--cc=shreeya.patel@collabora.com \
/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).