mfd / platform: cros_ec: Add sensor_count and make check_features public
Add a new function to return the number of MEMS sensors available in a ChromeOS Embedded Controller. It uses MOTIONSENSE_CMD_DUMP if available or a specific memory map ACPI registers to find out. Also, make check_features public as it can be useful for other drivers to know what the Embedded Controller supports. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
This commit is contained in:

committed by
Enric Balletbo i Serra

parent
c9b465683a
commit
a16b2e2819
@@ -112,38 +112,6 @@ static const struct mfd_cell cros_ec_vbc_cells[] = {
|
||||
{ .name = "cros-ec-vbc", }
|
||||
};
|
||||
|
||||
static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
|
||||
{
|
||||
struct cros_ec_command *msg;
|
||||
int ret;
|
||||
|
||||
if (ec->features[0] == -1U && ec->features[1] == -1U) {
|
||||
/* features bitmap not read yet */
|
||||
msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
|
||||
msg->insize = sizeof(ec->features);
|
||||
|
||||
ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
|
||||
if (ret < 0) {
|
||||
dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
|
||||
ret, msg->result);
|
||||
memset(ec->features, 0, sizeof(ec->features));
|
||||
} else {
|
||||
memcpy(ec->features, msg->data, sizeof(ec->features));
|
||||
}
|
||||
|
||||
dev_dbg(ec->dev, "EC features %08x %08x\n",
|
||||
ec->features[0], ec->features[1]);
|
||||
|
||||
kfree(msg);
|
||||
}
|
||||
|
||||
return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
|
||||
}
|
||||
|
||||
static void cros_ec_class_release(struct device *dev)
|
||||
{
|
||||
kfree(to_cros_ec_dev(dev));
|
||||
|
Reference in New Issue
Block a user