[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180620213033.100455-2-dmitry.torokhov@gmail.com>
Date: Wed, 20 Jun 2018 14:30:33 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Lee Jones <lee.jones@...aro.org>
Cc: Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
Gwendal Grignou <gwendal@...omium.org>,
Benson Leung <bleung@...omium.org>
Subject: [PATCH 2/2] Revert "mfd: cros_ec: Use devm_kzalloc for private data"
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
Powered by blists - more mailing lists