From: Cosmin Tanislav <demonsingur@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Cosmin Tanislav" <cosmin.tanislav@analog.com>
Subject: [PATCH 1/3] iio: temperature: ltc2983: allocate iio channels once
Date: Fri, 14 Oct 2022 15:37:22 +0300 [thread overview]
Message-ID: <20221014123724.1401011-2-demonsingur@gmail.com> (raw)
In-Reply-To: <20221014123724.1401011-1-demonsingur@gmail.com>
From: Cosmin Tanislav <cosmin.tanislav@analog.com>
Currently, every time the device wakes up from sleep, the
iio_chan array is reallocated, leaking the previous one
until the device is removed (basically never).
Move the allocation to the probe function to avoid this.
Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
---
drivers/iio/temperature/ltc2983.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index b652d2b39bcf..a60ccf183687 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -1385,13 +1385,6 @@ static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)
return ret;
}
- st->iio_chan = devm_kzalloc(&st->spi->dev,
- st->iio_channels * sizeof(*st->iio_chan),
- GFP_KERNEL);
-
- if (!st->iio_chan)
- return -ENOMEM;
-
ret = regmap_update_bits(st->regmap, LTC2983_GLOBAL_CONFIG_REG,
LTC2983_NOTCH_FREQ_MASK,
LTC2983_NOTCH_FREQ(st->filter_notch_freq));
@@ -1514,6 +1507,12 @@ static int ltc2983_probe(struct spi_device *spi)
gpiod_set_value_cansleep(gpio, 0);
}
+ st->iio_chan = devm_kzalloc(&spi->dev,
+ st->iio_channels * sizeof(*st->iio_chan),
+ GFP_KERNEL);
+ if (!st->iio_chan)
+ return -ENOMEM;
+
ret = ltc2983_setup(st, true);
if (ret)
return ret;
--
2.37.3
next prev parent reply other threads:[~2022-10-14 12:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 12:37 [PATCH 0/3] Support more parts in LTC2983 Cosmin Tanislav
2022-10-14 12:37 ` Cosmin Tanislav [this message]
2022-10-14 14:11 ` [PATCH 1/3] iio: temperature: ltc2983: allocate iio channels once Jonathan Cameron
2022-10-14 15:18 ` Jonathan Cameron
2022-10-15 16:35 ` Jonathan Cameron
2022-10-14 12:37 ` [PATCH 2/3] dt-bindings: iio: temperature: ltc2983: support more parts Cosmin Tanislav
2022-10-14 15:37 ` Jonathan Cameron
2022-10-17 7:01 ` Cosmin Tanislav
2022-10-17 10:22 ` Jonathan Cameron
2022-10-17 1:59 ` Krzysztof Kozlowski
2022-10-17 6:53 ` Cosmin Tanislav
2022-10-17 10:26 ` Jonathan Cameron
2022-10-17 10:37 ` Jonathan Cameron
2022-10-17 23:26 ` Krzysztof Kozlowski
2022-10-17 9:38 ` Nuno Sá
2022-10-17 10:04 ` Nuno Sá
2022-10-17 23:32 ` Krzysztof Kozlowski
2022-10-18 6:01 ` Nuno Sá
2022-10-14 12:37 ` [PATCH 3/3] " Cosmin Tanislav
2022-10-14 15:44 ` Jonathan Cameron
2022-10-17 6:59 ` Cosmin Tanislav
2022-10-17 10: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=20221014123724.1401011-2-demonsingur@gmail.com \
--to=demonsingur@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=cosmin.tanislav@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh+dt@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).