Skip to contentSkip to conversation

Revert "mfd: cros_ec: Remove unused __remove function"

PATCH In review Dmitry Torokhov 2 participants 6 messages Jun 20, 2018 – Jul 4, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Revert "mfd: cros_ec: Remove unused __remove function"

This reverts commit 556c242045f0c1613aac2e64dc5b2ff0e4bc89e1.

The patch that this change is purported to fix is broken and should be reverted; thus we reverting this one as well.
---

Lee,

I see the broken code is already in Linus' tree, so please merge send it on at your earliest convenience.

Thanks,
Dmitry

 drivers/mfd/cros_ec_dev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mfd/cros_ec_dev.c +2 -0
index 306e1fd109bd..4b1dbe81fcb6 100644
@@ -262,6 +262,8 @@ static const struct file_operations fops = {
 #endif
 };
 
+static void __remove(struct device *dev) { }
+
 static void cros_ec_sensors_register(struct cros_ec_dev *ec)
 {
 	/*
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
#1 lore raw

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(-)
drivers/mfd/cros_ec_dev.c +8 -2
index 4b1dbe81fcb6..bd4d4e7ec040 100644
@@ -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) {
Signature · 1 line
2.18.0.rc1.244.gcf134e6275-goog
#2 lore raw

Re: [PATCH 2/2] Revert "mfd: cros_ec: Use devm_kzalloc for private data"

Quoted 8 lines · Dmitry Torokhov

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(-)

For my own reference:

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw
In reply to Dmitry Torokhov
Quoted 4 lines · Dmitry Torokhov

This reverts commit 556c242045f0c1613aac2e64dc5b2ff0e4bc89e1.

The patch that this change is purported to fix is broken and should be reverted; thus we reverting this one as well.

You need to provide more information.

How does the original patch break the build/code execution? What is this patch doing to rectify the issue?
Any other information you think is relevant.

Quoted 27 lines

---

Lee,

I see the broken code is already in Linus' tree, so please merge send it on at your earliest convenience.

Thanks,
Dmitry

 drivers/mfd/cros_ec_dev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mfd/cros_ec_dev.c +2 -0
index 306e1fd109bd..4b1dbe81fcb6 100644
@@ -262,6 +262,8 @@ static const struct file_operations fops = {
 #endif
 };
 
+static void __remove(struct device *dev) { }
+
 static void cros_ec_sensors_register(struct cros_ec_dev *ec)
 {
 	/*
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

Hi Lee,

Quoted 4 lines · Lee Jones
Quoted 2 lines · Dmitry Torokhov

This reverts commit 556c242045f0c1613aac2e64dc5b2ff0e4bc89e1.

Quoted 8 lines
Quoted 2 lines

The patch that this change is purported to fix is broken and should be reverted; thus we reverting this one as well.

You need to provide more information.

How does the original patch break the build/code execution? What is this patch doing to rectify the issue?
Any other information you think is relevant.

We are reverting this patch because it is not needed: it tries to fix another patch that is completely broken and needs to be reverted. The justification for reverting the original broken patch is in the revert of that patch, but just for reference:

We should not use devm_kzalloc() to allocate refcounted objects.

Thanks.

Signature · 1 line
Dmitry
#5 lore raw
Quoted 14 lines · Dmitry Torokhov
Quoted 4 lines · Lee Jones
Quoted 2 lines · Dmitry Torokhov

This reverts commit 556c242045f0c1613aac2e64dc5b2ff0e4bc89e1.

Quoted 8 lines
Quoted 2 lines

The patch that this change is purported to fix is broken and should be reverted; thus we reverting this one as well.

You need to provide more information.

How does the original patch break the build/code execution? What is this patch doing to rectify the issue?
Any other information you think is relevant.

Quoted 6 lines

We are reverting this patch because it is not needed: it tries to fix another patch that is completely broken and needs to be reverted. The justification for reverting the original broken patch is in the revert of that patch, but just for reference:

We should not use devm_kzalloc() to allocate refcounted objects.

The other patch looked good. Please ensure the story is told in each of the patches individually though. That way they can be are viewed by an outsider the history can be read and understood independently.

Thanks in advance.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog