From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org,
Gwendal Grignou <gwendal@chromium.org>,
Benson Leung <bleung@chromium.org>
Subject: [PATCH 2/2] Revert "mfd: cros_ec: Use devm_kzalloc for private data"
Date: Wed, 20 Jun 2018 14:30:33 -0700 [thread overview]
Message-ID: <20180620213033.100455-2-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20180620213033.100455-1-dmitry.torokhov@gmail.com>
This reverts commit 3aa2177e47878f7e7616da8a2050c44f22301b6e.
Linux device objects are refcounted and thus should not be allocated
with devm API as they may outlive the timeframe of another device being
bound to a driver.
---
drivers/mfd/cros_ec_dev.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 4b1dbe81fcb6..bd4d4e7ec040 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -262,7 +262,12 @@ static const struct file_operations fops = {
#endif
};
-static void __remove(struct device *dev) { }
+static void __remove(struct device *dev)
+{
+ struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
+ class_dev);
+ kfree(ec);
+}
static void cros_ec_sensors_register(struct cros_ec_dev *ec)
{
@@ -388,7 +393,7 @@ static int ec_device_probe(struct platform_device *pdev)
int retval = -ENOMEM;
struct device *dev = &pdev->dev;
struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
- struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
+ struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
if (!ec)
return retval;
@@ -410,6 +415,7 @@ static int ec_device_probe(struct platform_device *pdev)
ec->class_dev.devt = MKDEV(ec_major, pdev->id);
ec->class_dev.class = &cros_class;
ec->class_dev.parent = dev;
+ ec->class_dev.release = __remove;
retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name);
if (retval) {
--
2.18.0.rc1.244.gcf134e6275-goog
next prev parent reply other threads:[~2018-06-20 21:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 21:30 [PATCH 1/2] Revert "mfd: cros_ec: Remove unused __remove function" Dmitry Torokhov
2018-06-20 21:30 ` Dmitry Torokhov [this message]
2018-07-04 7:00 ` [PATCH 2/2] Revert "mfd: cros_ec: Use devm_kzalloc for private data" Lee Jones
2018-07-04 6:48 ` [PATCH 1/2] Revert "mfd: cros_ec: Remove unused __remove function" Lee Jones
2018-07-04 15:16 ` Dmitry Torokhov
2018-07-04 16:11 ` Lee Jones
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=20180620213033.100455-2-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=arnd@arndb.de \
--cc=bleung@chromium.org \
--cc=gwendal@chromium.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@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