mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
@ 2021-04-03  6:20 Gwendal Grignou
  2021-04-03  7:33 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gwendal Grignou @ 2021-04-03  6:20 UTC (permalink / raw)
  To: bleung, enric.balletbo, groeck; +Cc: linux-kernel, Gwendal Grignou, stable

When cros_ec_sysfs probe is called before cros_ec_sensorhub probe
routine, the |kb_wake_angle| attribute will not be displayed, even if
there are two accelerometers in the chromebook.

Call sysfs_update_group() when accelerometers are enumerated if the
cros_ec sysfs attributes group has already been created.

Fixes: d60ac88a62df ("mfd / platform / iio: cros_ec: Register sensor through sensorhub")
Cc: stable@vger.kernel.org
Signed-off-by: Gwendal Grignou <gwendal@google.com>
---
 drivers/platform/chrome/cros_ec_sensorhub.c | 5 ++++-
 drivers/platform/chrome/cros_ec_sysfs.c     | 2 ++
 include/linux/platform_data/cros_ec_proto.h | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c
index 9c4af76a9956e..78085ad362ca8 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub.c
@@ -106,8 +106,11 @@ static int cros_ec_sensorhub_register(struct device *dev,
 		sensor_type[sensorhub->resp->info.type]++;
 	}
 
-	if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2)
+	if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) {
 		ec->has_kb_wake_angle = true;
+		if (ec->group)
+			sysfs_update_group(&ec->class_dev.kobj, ec->group);
+	}
 
 	if (cros_ec_check_features(ec,
 				   EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) {
diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index f07eabcf9494c..3838d5f51aadc 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -344,6 +344,8 @@ static int cros_ec_sysfs_probe(struct platform_device *pd)
 	ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group);
 	if (ret < 0)
 		dev_err(dev, "failed to create attributes. err=%d\n", ret);
+	else
+		ec_dev->group = &cros_ec_attr_group;
 
 	return ret;
 }
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 02599687770c5..4cd06f68bc536 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -191,6 +191,7 @@ struct cros_ec_platform {
 /**
  * struct cros_ec_dev - ChromeOS EC device entry point.
  * @class_dev: Device structure used in sysfs.
+ * @group: sysfs attributes group for this EC.
  * @ec_dev: cros_ec_device structure to talk to the physical device.
  * @dev: Pointer to the platform device.
  * @debug_info: cros_ec_debugfs structure for debugging information.
@@ -200,6 +201,7 @@ struct cros_ec_platform {
  */
 struct cros_ec_dev {
 	struct device class_dev;
+	struct attribute_group *group;
 	struct cros_ec_device *ec_dev;
 	struct device *dev;
 	struct cros_ec_debugfs *debug_info;
-- 
2.31.0.208.g409f899ff0-goog


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-03  8:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03  6:20 [PATCH] platform/chrome: Update cros_ec sysfs attributes on sensors discovery Gwendal Grignou
2021-04-03  7:33 ` kernel test robot
2021-04-03  7:47 ` kernel test robot
2021-04-03  7:52 ` Greg KH
2021-04-03  8:04 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®