Skip to contentSkip to conversation

platform/chrome: cros_ec_lightbar - use name instead of ID to hide lightbar attributes

PATCH In review Clinton Sprain 2 participants 2 messages Mar 9, 2016 – May 11, 2016

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

PATCH 1/1 platform/chrome: cros_ec_lightbar - use name instead of ID to hide lightbar attributes

Lightbar attributes are hidden if the ID of the device is not 0 (the assumption being that 0 = cros_ec = might have a lightbar, 1 = cros_pd = hide); however, sometimes these devices get IDs 1 and 2 (or something else) instead of IDs 0 and 1. This prevents the lightbar attributes from appearing when they should.

Proposed change is to instead check whether the name assigned to the device is CROS_EC_DEV_NAME (true for cros_ec, false for cros_pd).

---
 drivers/platform/chrome/cros_ec_lightbar.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_lightbar.c +6 -1
index ff76405..b6356b3 100644
@@ -414,7 +414,12 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj,
 					      struct cros_ec_dev, class_dev);
 	struct platform_device *pdev = container_of(ec->dev,
 						   struct platform_device, dev);
-	if (pdev->id != 0)
+	struct cros_ec_platform *pdata = pdev->dev.platform_data;
+	int is_cros_ec;
+
+	is_cros_ec = strcmp(pdata->ec_name, CROS_EC_DEV_NAME);
+
+	if (is_cros_ec != 0)
 		return 0;
 
 	/* Only instantiate this stuff if the EC has a lightbar */
Signature · 1 line
2.5.0
#1 lore raw
Quoted 10 lines · Clinton Sprain

Lightbar attributes are hidden if the ID of the device is not 0 (the assumption being that 0 = cros_ec = might have a lightbar, 1 = cros_pd = hide); however, sometimes these devices get IDs 1 and 2 (or something else) instead of IDs 0 and 1. This prevents the lightbar attributes from appearing when they should.

Proposed change is to instead check whether the name assigned to the device is CROS_EC_DEV_NAME (true for cros_ec, false for cros_pd).

Hm. I wonder why we need to check at all, given that the lightbar version check is just going to fail later anyway.

Either way, applied with some manual fixups due to surrounding changes. Apologies for the long delay here.

-Olof