From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-iio@vger.kernel.org>, <linux-amlogic@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>, <linux-imx@nxp.com>
Cc: "Chen-Yu Tsai" <wens@csie.org>,
"Andriy Tryshnivskyy" <andriy.tryshnivskyy@opensynergy.com>,
"Ciprian Regus" <ciprian.regus@analog.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Cixi Geng" <cixi.geng1@unisoc.com>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Heiko Stuebner" <heiko@sntech.de>,
"Nuno Sá" <nuno.sa@analog.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Alexandru Ardelean" <aardelean@deviqon.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Haibo Chen" <haibo.chen@nxp.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jyoti Bhayana" <jbhayana@google.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Florian Boor" <florian.boor@kernelconcepts.de>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Kevin Hilman" <khilman@baylibre.com>
Subject: [PATCH v3 2/4] iio: health: max30100: do not use internal iio_dev lock
Date: Wed, 12 Oct 2022 17:16:18 +0200 [thread overview]
Message-ID: <20221012151620.1725215-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20221012151620.1725215-1-nuno.sa@analog.com>
The pattern used in this device does not quite fit in the
iio_device_claim_direct_mode() typical usage. In this case,
iio_buffer_enabled() was being used not to prevent the raw access but to
allow it. Hence, let's make use of the new
iio_device_claim_buffer_mode() API to make sure we stay in buffered mode
during the complete read.
Note that we are shadowing the error code returned by
iio_device_claim_buffer_mode() so that we keep the original one
(-EAGAIN). The reason is that some userspace stack might already be
relying on this particular code so that we are not taking chances and
leave it alone.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/health/max30100.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 2cca5e0519f8..6ac49901c9da 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -387,18 +387,15 @@ static int max30100_read_raw(struct iio_dev *indio_dev,
* Temperature reading can only be acquired while engine
* is running
*/
- mutex_lock(&indio_dev->mlock);
-
- if (!iio_buffer_enabled(indio_dev))
+ if (iio_device_claim_buffer_mode(indio_dev)) {
ret = -EAGAIN;
- else {
+ } else {
ret = max30100_get_temp(data, val);
if (!ret)
ret = IIO_VAL_INT;
+ iio_device_release_buffer_mode(indio_dev);
}
-
- mutex_unlock(&indio_dev->mlock);
break;
case IIO_CHAN_INFO_SCALE:
*val = 1; /* 0.0625 */
--
2.38.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-iio@vger.kernel.org>, <linux-amlogic@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>, <linux-imx@nxp.com>
Cc: "Chen-Yu Tsai" <wens@csie.org>,
"Andriy Tryshnivskyy" <andriy.tryshnivskyy@opensynergy.com>,
"Ciprian Regus" <ciprian.regus@analog.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Cixi Geng" <cixi.geng1@unisoc.com>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Heiko Stuebner" <heiko@sntech.de>,
"Nuno Sá" <nuno.sa@analog.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Alexandru Ardelean" <aardelean@deviqon.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Haibo Chen" <haibo.chen@nxp.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jyoti Bhayana" <jbhayana@google.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Florian Boor" <florian.boor@kernelconcepts.de>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Kevin Hilman" <khilman@baylibre.com>
Subject: [PATCH v3 2/4] iio: health: max30100: do not use internal iio_dev lock
Date: Wed, 12 Oct 2022 17:16:18 +0200 [thread overview]
Message-ID: <20221012151620.1725215-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20221012151620.1725215-1-nuno.sa@analog.com>
The pattern used in this device does not quite fit in the
iio_device_claim_direct_mode() typical usage. In this case,
iio_buffer_enabled() was being used not to prevent the raw access but to
allow it. Hence, let's make use of the new
iio_device_claim_buffer_mode() API to make sure we stay in buffered mode
during the complete read.
Note that we are shadowing the error code returned by
iio_device_claim_buffer_mode() so that we keep the original one
(-EAGAIN). The reason is that some userspace stack might already be
relying on this particular code so that we are not taking chances and
leave it alone.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/health/max30100.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 2cca5e0519f8..6ac49901c9da 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -387,18 +387,15 @@ static int max30100_read_raw(struct iio_dev *indio_dev,
* Temperature reading can only be acquired while engine
* is running
*/
- mutex_lock(&indio_dev->mlock);
-
- if (!iio_buffer_enabled(indio_dev))
+ if (iio_device_claim_buffer_mode(indio_dev)) {
ret = -EAGAIN;
- else {
+ } else {
ret = max30100_get_temp(data, val);
if (!ret)
ret = IIO_VAL_INT;
+ iio_device_release_buffer_mode(indio_dev);
}
-
- mutex_unlock(&indio_dev->mlock);
break;
case IIO_CHAN_INFO_SCALE:
*val = 1; /* 0.0625 */
--
2.38.0
WARNING: multiple messages have this Message-ID (diff)
From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-iio@vger.kernel.org>, <linux-amlogic@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>, <linux-imx@nxp.com>
Cc: "Chen-Yu Tsai" <wens@csie.org>,
"Andriy Tryshnivskyy" <andriy.tryshnivskyy@opensynergy.com>,
"Ciprian Regus" <ciprian.regus@analog.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Cixi Geng" <cixi.geng1@unisoc.com>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Heiko Stuebner" <heiko@sntech.de>,
"Nuno Sá" <nuno.sa@analog.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Alexandru Ardelean" <aardelean@deviqon.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Haibo Chen" <haibo.chen@nxp.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jyoti Bhayana" <jbhayana@google.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Florian Boor" <florian.boor@kernelconcepts.de>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Kevin Hilman" <khilman@baylibre.com>
Subject: [PATCH v3 2/4] iio: health: max30100: do not use internal iio_dev lock
Date: Wed, 12 Oct 2022 17:16:18 +0200 [thread overview]
Message-ID: <20221012151620.1725215-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20221012151620.1725215-1-nuno.sa@analog.com>
The pattern used in this device does not quite fit in the
iio_device_claim_direct_mode() typical usage. In this case,
iio_buffer_enabled() was being used not to prevent the raw access but to
allow it. Hence, let's make use of the new
iio_device_claim_buffer_mode() API to make sure we stay in buffered mode
during the complete read.
Note that we are shadowing the error code returned by
iio_device_claim_buffer_mode() so that we keep the original one
(-EAGAIN). The reason is that some userspace stack might already be
relying on this particular code so that we are not taking chances and
leave it alone.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/health/max30100.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 2cca5e0519f8..6ac49901c9da 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -387,18 +387,15 @@ static int max30100_read_raw(struct iio_dev *indio_dev,
* Temperature reading can only be acquired while engine
* is running
*/
- mutex_lock(&indio_dev->mlock);
-
- if (!iio_buffer_enabled(indio_dev))
+ if (iio_device_claim_buffer_mode(indio_dev)) {
ret = -EAGAIN;
- else {
+ } else {
ret = max30100_get_temp(data, val);
if (!ret)
ret = IIO_VAL_INT;
+ iio_device_release_buffer_mode(indio_dev);
}
-
- mutex_unlock(&indio_dev->mlock);
break;
case IIO_CHAN_INFO_SCALE:
*val = 1; /* 0.0625 */
--
2.38.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-iio@vger.kernel.org>, <linux-amlogic@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>, <linux-imx@nxp.com>
Cc: "Chen-Yu Tsai" <wens@csie.org>,
"Andriy Tryshnivskyy" <andriy.tryshnivskyy@opensynergy.com>,
"Ciprian Regus" <ciprian.regus@analog.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Cixi Geng" <cixi.geng1@unisoc.com>,
"Neil Armstrong" <narmstrong@baylibre.com>,
"Miquel Raynal" <miquel.raynal@bootlin.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Heiko Stuebner" <heiko@sntech.de>,
"Nuno Sá" <nuno.sa@analog.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Alexandru Ardelean" <aardelean@deviqon.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Haibo Chen" <haibo.chen@nxp.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Jyoti Bhayana" <jbhayana@google.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Florian Boor" <florian.boor@kernelconcepts.de>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Shawn Guo" <shawnguo@kernel.org>,
"Kevin Hilman" <khilman@baylibre.com>
Subject: [PATCH v3 2/4] iio: health: max30100: do not use internal iio_dev lock
Date: Wed, 12 Oct 2022 17:16:18 +0200 [thread overview]
Message-ID: <20221012151620.1725215-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20221012151620.1725215-1-nuno.sa@analog.com>
The pattern used in this device does not quite fit in the
iio_device_claim_direct_mode() typical usage. In this case,
iio_buffer_enabled() was being used not to prevent the raw access but to
allow it. Hence, let's make use of the new
iio_device_claim_buffer_mode() API to make sure we stay in buffered mode
during the complete read.
Note that we are shadowing the error code returned by
iio_device_claim_buffer_mode() so that we keep the original one
(-EAGAIN). The reason is that some userspace stack might already be
relying on this particular code so that we are not taking chances and
leave it alone.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/health/max30100.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 2cca5e0519f8..6ac49901c9da 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -387,18 +387,15 @@ static int max30100_read_raw(struct iio_dev *indio_dev,
* Temperature reading can only be acquired while engine
* is running
*/
- mutex_lock(&indio_dev->mlock);
-
- if (!iio_buffer_enabled(indio_dev))
+ if (iio_device_claim_buffer_mode(indio_dev)) {
ret = -EAGAIN;
- else {
+ } else {
ret = max30100_get_temp(data, val);
if (!ret)
ret = IIO_VAL_INT;
+ iio_device_release_buffer_mode(indio_dev);
}
-
- mutex_unlock(&indio_dev->mlock);
break;
case IIO_CHAN_INFO_SCALE:
*val = 1; /* 0.0625 */
--
2.38.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-10-12 15:16 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 15:16 [PATCH v3 0/4] Make 'mlock' really private Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` [PATCH v3 1/4] iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 17:41 ` Andy Shevchenko
2022-10-12 17:41 ` Andy Shevchenko
2022-10-12 17:41 ` Andy Shevchenko
2022-10-12 17:41 ` Andy Shevchenko
2022-10-12 15:16 ` Nuno Sá [this message]
2022-10-12 15:16 ` [PATCH v3 2/4] iio: health: max30100: do not use internal iio_dev lock Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 17:46 ` Andy Shevchenko
2022-10-12 17:46 ` Andy Shevchenko
2022-10-12 17:46 ` Andy Shevchenko
2022-10-12 17:46 ` Andy Shevchenko
2022-10-14 7:16 ` Nuno Sá
2022-10-14 7:16 ` Nuno Sá
2022-10-14 7:16 ` Nuno Sá
2022-10-14 7:16 ` Nuno Sá
2022-10-12 15:16 ` [PATCH v3 3/4] iio: health: max30102: " Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 18:45 ` Miquel Raynal
2022-10-12 18:45 ` Miquel Raynal
2022-10-12 18:45 ` Miquel Raynal
2022-10-12 18:45 ` Miquel Raynal
2022-10-14 7:25 ` Nuno Sá
2022-10-14 7:25 ` Nuno Sá
2022-10-14 7:25 ` Nuno Sá
2022-10-14 7:25 ` Nuno Sá
2022-10-14 15:21 ` Jonathan Cameron
2022-10-14 15:21 ` Jonathan Cameron
2022-10-14 15:21 ` Jonathan Cameron
2022-10-14 15:21 ` Jonathan Cameron
2022-10-12 15:16 ` [PATCH v3 4/4] iio: core: move 'mlock' to 'struct iio_dev_opaque' Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 15:16 ` Nuno Sá
2022-10-12 17:49 ` [PATCH v3 0/4] Make 'mlock' really private Andy Shevchenko
2022-10-12 17:49 ` Andy Shevchenko
2022-10-12 17:49 ` Andy Shevchenko
2022-10-12 17:49 ` Andy Shevchenko
2022-10-15 16:10 ` Jonathan Cameron
2022-10-15 16:10 ` Jonathan Cameron
2022-10-15 16:10 ` Jonathan Cameron
2022-10-15 16:10 ` 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=20221012151620.1725215-3-nuno.sa@analog.com \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=aardelean@deviqon.com \
--cc=andriy.tryshnivskyy@opensynergy.com \
--cc=andy.shevchenko@gmail.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=ciprian.regus@analog.com \
--cc=cixi.geng1@unisoc.com \
--cc=festevam@gmail.com \
--cc=florian.boor@kernelconcepts.de \
--cc=haibo.chen@nxp.com \
--cc=hdegoede@redhat.com \
--cc=heiko@sntech.de \
--cc=jbhayana@google.com \
--cc=jbrunet@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=khilman@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-rockchip@lists.infradead.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=miquel.raynal@bootlin.com \
--cc=narmstrong@baylibre.com \
--cc=orsonzhai@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vz@mleia.com \
--cc=wens@csie.org \
--cc=zhang.lyra@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.