Skip to content

Commit

Permalink
platform/chrome: cros_ec_sensorhub: Add the number of sensors in sens…
Browse files Browse the repository at this point in the history
…orhub

To better manage resources, store the number of sensors reported by
the EC.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
  • Loading branch information
Gwendal Grignou authored and Enric Balletbo i Serra committed Mar 28, 2020
1 parent b2057c6 commit cee416a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/platform/chrome/cros_ec_sensorhub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions include/linux/platform_data/cros_ec_sensorhub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit cee416a

Please sign in to comment.