From: Gwendal Grignou <gwendal@chromium.org>
To: bleung@chromium.org, enric.balletbo@collabora.com, groeck@chromium.org
Cc: linux-kernel@vger.kernel.org,
Gwendal Grignou <gwendal@google.com>,
stable@vger.kernel.org
Subject: [PATCH v2 2/2] platform/chrome: Update cros_ec sysfs attributes on sensors discovery
Date: Mon, 5 Apr 2021 13:28:57 -0700 [thread overview]
Message-ID: <20210405202857.1265308-3-gwendal@google.com> (raw)
In-Reply-To: <20210405202857.1265308-1-gwendal@google.com>
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_groups() when accelerometers are enumerated if the
cros_ec sysfs attributes groups have 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>
---
Changes in v2:
Rebase after .dev_groups is used.
drivers/platform/chrome/cros_ec_sensorhub.c | 6 +++++-
drivers/platform/chrome/cros_ec_sysfs.c | 10 ++++++++++
include/linux/platform_data/cros_ec_proto.h | 2 ++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c
index 9c4af76a9956e..c69fec935fb50 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->groups && sysfs_update_groups(&ec->class_dev.kobj, ec->groups))
+ dev_warn(dev, "Unable to update cros-ec-sysfs");
+ }
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 114b9dbe981e7..b363f70270a38 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -340,11 +340,21 @@ static const struct attribute_group *cros_ec_attr_groups[] = {
NULL,
};
+static int cros_ec_sysfs_probe(struct platform_device *pd)
+{
+ struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
+
+ ec_dev->groups = cros_ec_attr_groups;
+
+ return 0;
+}
+
static struct platform_driver cros_ec_sysfs_driver = {
.driver = {
.name = DRV_NAME,
.dev_groups = cros_ec_attr_groups,
},
+ .probe = cros_ec_sysfs_probe,
};
module_platform_driver(cros_ec_sysfs_driver);
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 02599687770c5..de940112f53ae 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.
+ * @groups: sysfs attributes groups 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;
+ const struct attribute_group **groups;
struct cros_ec_device *ec_dev;
struct device *dev;
struct cros_ec_debugfs *debug_info;
--
2.31.0.208.g409f899ff0-goog
next prev parent reply other threads:[~2021-04-05 20:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 20:28 [PATCH v2 0/2] platform/chrome: Update cros_ec sysfs attribute after sensors are found Gwendal Grignou
2021-04-05 20:28 ` [PATCH v2 1/2] platform/chrome: Use dev_groups to set device sysfs attributes Gwendal Grignou
2021-04-05 20:28 ` Gwendal Grignou [this message]
2021-05-27 21:01 ` [PATCH v2 0/2] platform/chrome: Update cros_ec sysfs attribute after sensors are found Gwendal Grignou
2021-05-31 5:36 ` Dmitry Torokhov
2021-08-04 21:09 ` Gwendal Grignou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210405202857.1265308-3-gwendal@google.com \
--to=gwendal@chromium.org \
--cc=bleung@chromium.org \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=gwendal@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®