mfd: cros_ec: Register cros_ec_lid_angle driver when presented
Register driver when EC indicates has precise lid angle calculation code running. Fix incorrect extra resource allocation in cros_ec_sensors_register(). Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>alistair/sunxi64-5.4-dsi
parent
5aa3709c0a
commit
1bb407f17c
|
@ -297,13 +297,15 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
|
||||||
|
|
||||||
resp = (struct ec_response_motion_sense *)msg->data;
|
resp = (struct ec_response_motion_sense *)msg->data;
|
||||||
sensor_num = resp->dump.sensor_count;
|
sensor_num = resp->dump.sensor_count;
|
||||||
/* Allocate 1 extra sensors in FIFO are needed */
|
/*
|
||||||
sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell),
|
* Allocate 2 extra sensors if lid angle sensor and/or FIFO are needed.
|
||||||
|
*/
|
||||||
|
sensor_cells = kcalloc(sensor_num + 2, sizeof(struct mfd_cell),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (sensor_cells == NULL)
|
if (sensor_cells == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
sensor_platforms = kcalloc(sensor_num + 1,
|
sensor_platforms = kcalloc(sensor_num,
|
||||||
sizeof(struct cros_ec_sensor_platform),
|
sizeof(struct cros_ec_sensor_platform),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (sensor_platforms == NULL)
|
if (sensor_platforms == NULL)
|
||||||
|
@ -363,6 +365,11 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
|
||||||
sensor_cells[id].name = "cros-ec-ring";
|
sensor_cells[id].name = "cros-ec-ring";
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
|
if (cros_ec_check_features(ec,
|
||||||
|
EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)) {
|
||||||
|
sensor_cells[id].name = "cros-ec-lid-angle";
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
ret = mfd_add_devices(ec->dev, 0, sensor_cells, id,
|
ret = mfd_add_devices(ec->dev, 0, sensor_cells, id,
|
||||||
NULL, 0, NULL);
|
NULL, 0, NULL);
|
||||||
|
|
Loading…
Reference in New Issue