[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200327223443.6006-2-gwendal@chromium.org>
Date: Fri, 27 Mar 2020 15:34:32 -0700
From: Gwendal Grignou <gwendal@...omium.org>
To: bleung@...omium.org, enric.balletbo@...labora.com,
Jonathan.Cameron@...wei.com
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Gwendal Grignou <gwendal@...omium.org>
Subject: [PATCH v7 01/12] platform: chrome: sensorhub: Add the number of sensors in sensorhub
To better manage resources, store the number of sensors reported by
the EC.
Signed-off-by: Gwendal Grignou <gwendal@...omium.org>
---
New in v7
drivers/platform/chrome/cros_ec_sensorhub.c | 4 +++-
include/linux/platform_data/cros_ec_sensorhub.h | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_sensorhub.c b/drivers/platform/chrome/cros_ec_sensorhub.c
index 79fefd3bb0fa6..134ee5e460472 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub.c
@@ -65,6 +65,7 @@ static int cros_ec_sensorhub_register(struct device *dev,
return sensor_num;
}
+ sensorhub->sensor_num = sensor_num;
if (sensor_num == 0) {
dev_err(dev, "Zero sensors reported.\n");
return -EINVAL;
@@ -172,7 +173,8 @@ static int cros_ec_sensorhub_probe(struct platform_device *pdev)
* If the device has sensors but does not claim to
* be a sensor hub, we are in legacy mode.
*/
- for (i = 0; i < 2; i++) {
+ data->sensor_num = 2;
+ for (i = 0; i < data->sensor_num; i++) {
ret = cros_ec_sensorhub_allocate_sensor(dev,
"cros-ec-accel-legacy", i);
if (ret)
diff --git a/include/linux/platform_data/cros_ec_sensorhub.h b/include/linux/platform_data/cros_ec_sensorhub.h
index bef7ffc7fce10..7e46a47fd642b 100644
--- a/include/linux/platform_data/cros_ec_sensorhub.h
+++ b/include/linux/platform_data/cros_ec_sensorhub.h
@@ -22,9 +22,11 @@ struct cros_ec_sensor_platform {
* struct cros_ec_sensorhub - Sensor Hub device data.
*
* @ec: Embedded Controller where the hub is located.
+ * @sensor_num: Number of MEMS sensors present in the EC.
*/
struct cros_ec_sensorhub {
struct cros_ec_dev *ec;
+ int sensor_num;
};
#endif /* __LINUX_PLATFORM_DATA_CROS_EC_SENSORHUB_H */
--
2.26.0.rc2.310.g2932bb562d-goog
Powered by blists - more mailing lists