Skip to content

Commit cee416a

Browse files
gwendalcrEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_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 <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent b2057c6 commit cee416a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/platform/chrome/cros_ec_sensorhub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static int cros_ec_sensorhub_register(struct device *dev,
6565
return sensor_num;
6666
}
6767

68+
sensorhub->sensor_num = sensor_num;
6869
if (sensor_num == 0) {
6970
dev_err(dev, "Zero sensors reported.\n");
7071
return -EINVAL;
@@ -172,7 +173,8 @@ static int cros_ec_sensorhub_probe(struct platform_device *pdev)
172173
* If the device has sensors but does not claim to
173174
* be a sensor hub, we are in legacy mode.
174175
*/
175-
for (i = 0; i < 2; i++) {
176+
data->sensor_num = 2;
177+
for (i = 0; i < data->sensor_num; i++) {
176178
ret = cros_ec_sensorhub_allocate_sensor(dev,
177179
"cros-ec-accel-legacy", i);
178180
if (ret)

include/linux/platform_data/cros_ec_sensorhub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ struct cros_ec_sensor_platform {
2222
* struct cros_ec_sensorhub - Sensor Hub device data.
2323
*
2424
* @ec: Embedded Controller where the hub is located.
25+
* @sensor_num: Number of MEMS sensors present in the EC.
2526
*/
2627
struct cros_ec_sensorhub {
2728
struct cros_ec_dev *ec;
29+
int sensor_num;
2830
};
2931

3032
#endif /* __LINUX_PLATFORM_DATA_CROS_EC_SENSORHUB_H */

0 commit comments

Comments
 (0)