Skip to contentSkip to conversation

platform/chrome: lightbar: Assign drvdata during probe

PATCH In review Rajat Jain 2 participants 3 messages Jun 25, 2019 – Jun 27, 2019

Subsystems (2)
lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

PATCH 1/1 platform/chrome: lightbar: Assign drvdata during probe

The lightbar driver never assigned the drvdata in probe method, and thus causes a panic when it is accessed at the suspend time.

---
 drivers/platform/chrome/cros_ec_lightbar.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_lightbar.c +5 -2
index d30a6650b0b5..98e514fc5830 100644
@@ -578,11 +578,14 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
 
 	ret = sysfs_create_group(&ec_dev->class_dev.kobj,
 				 &cros_ec_lightbar_attr_group);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(dev, "failed to create %s attributes. err=%d\n",
 			cros_ec_lightbar_attr_group.name, ret);
+		return ret;
+	}
 
-	return ret;
+	platform_set_drvdata(pd, ec_dev);
+	return 0;
 }
 
 static int cros_ec_lightbar_remove(struct platform_device *pd)
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
#1 lore raw

Hi Rajat,

Quoted 2 lines · Rajat Jain

The lightbar driver never assigned the drvdata in probe method, and thus causes a panic when it is accessed at the suspend time.

Good catch, that's one of the problems I currently have with mainline on Samus. The other one, that I didn't find time to look at is, that for some reason, when I suspend the system reboots. Is suspend/resume working for you in current mainline?

There is no drvdata because we don't really need extra private data for this driver, the ec_dev is directly the drvdata provided by device parent. I am wondering if you can just do

   struct cros_ec_dev *ec_dev = to_cros_ec_dev(dev);

in the suspend/resume calls like we do in the show/store calls or get the drvdata from its parent. I guess I prefer the first one.

Quoted 1 line

Would be nice have a fixes tag here.

Quoted 17 lines
---
 drivers/platform/chrome/cros_ec_lightbar.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_lightbar.c +1 -1
index d30a6650b0b5..98e514fc5830 100644
@@ -578,11 +578,14 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
 
 	ret = sysfs_create_group(&ec_dev->class_dev.kobj,
 				 &cros_ec_lightbar_attr_group);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(dev, "failed to create %s attributes. err=%d\n",

drivers/platform/chrome/cros_ec_lightbar.c static int cros_ec_lightbar_probe(struct platform_device *pd) · line 591

Quoted 10 lines
drivers/platform/chrome/cros_ec_lightbar.c +4 -1
 			cros_ec_lightbar_attr_group.name, ret);
+		return ret;
+	}
 
-	return ret;
+	platform_set_drvdata(pd, ec_dev);
+	return 0;
 }
 
 static int cros_ec_lightbar_remove(struct platform_device *pd)

Thanks,
~ Enric

author
#2 lore raw

Hi Enric,

Quoted 10 lines · Enric Balletbo i Serra

Hi Rajat,

Quoted 2 lines · Rajat Jain

The lightbar driver never assigned the drvdata in probe method, and thus causes a panic when it is accessed at the suspend time.

Good catch, that's one of the problems I currently have with mainline on Samus. The other one, that I didn't find time to look at is, that for some reason, when I suspend the system reboots. Is suspend/resume working for you in current mainline?

I haven't tried current mainline yet. (I tried, but wasn't able to build it like I used to. If you have a recipe, can you share and I can give it a try).
I was seeing the same symptoms on my Hatch (using 4.19) before this patch. I found this was the cause of the reboot, and is fixed now with this patch. May be you can try on Samus with its fix?

Quoted 9 lines

There is no drvdata because we don't really need extra private data for this driver, the ec_dev is directly the drvdata provided by device parent. I am wondering if you can just do

   struct cros_ec_dev *ec_dev = to_cros_ec_dev(dev);

in the suspend/resume calls like we do in the show/store calls or get the drvdata from its parent. I guess I prefer the first one.

The dev in suspend() callback points to "cros-ec-lightbar" device instead of "cros-ec-dev", so we'd need to reach the parent. I'll send a new patch in a moment.

Thanks,

Rajat

Quoted 35 lines
Quoted 2 lines

Would be nice have a fixes tag here.

Quoted 17 lines
---
 drivers/platform/chrome/cros_ec_lightbar.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_lightbar.c +1 -1
index d30a6650b0b5..98e514fc5830 100644
@@ -578,11 +578,14 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
 
      ret = sysfs_create_group(&ec_dev->class_dev.kobj,
                               &cros_ec_lightbar_attr_group);
-     if (ret < 0)
+     if (ret < 0) {
              dev_err(dev, "failed to create %s attributes. err=%d\n",

drivers/platform/chrome/cros_ec_lightbar.c static int cros_ec_lightbar_probe(struct platform_device *pd) · line 591

Quoted 10 lines
drivers/platform/chrome/cros_ec_lightbar.c +4 -1
                      cros_ec_lightbar_attr_group.name, ret);
+             return ret;
+     }
 
-     return ret;
+     platform_set_drvdata(pd, ec_dev);
+     return 0;
 }
 
 static int cros_ec_lightbar_remove(struct platform_device *pd)

Thanks,
~ Enric