| @@ -812,36 +812,37 @@ EXPORT_SYMBOL(cros_ec_get_host_event); · 811 unmodified lines |
| 812 | */ | 812 | */ |
| 813 | bool cros_ec_check_features(struct cros_ec_dev *ec, int feature) | 813 | bool cros_ec_check_features(struct cros_ec_dev *ec, int feature) |
| 814 | { | 814 | { |
| | 815 | struct ec_response_get_features *features = &ec->features; |
| 815 | struct cros_ec_command *msg; | 816 | struct cros_ec_command *msg; |
| 816 | int ret; | 817 | int ret; |
| 817 | | 818 | |
| 818 | if (ec->features[0] == -1U && ec->features[1] == -1U) { | 819 | if (features->flags[0] == -1U && features->flags[1] == -1U) { |
| 819 | /* features bitmap not read yet */ | 820 | /* features bitmap not read yet */ |
| 820 | msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); | 821 | msg = kzalloc(sizeof(*msg) + sizeof(*features), GFP_KERNEL); |
| 821 | if (!msg) { | 822 | if (!msg) { |
| 822 | dev_err(ec->dev, "failed to allocate memory to get EC features\n"); | 823 | dev_err(ec->dev, "failed to allocate memory to get EC features\n"); |
| 823 | return false; | 824 | return false; |
| 824 | } | 825 | } |
| 825 | | 826 | |
| 826 | msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; | 827 | msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; |
| 827 | msg->insize = sizeof(ec->features); | 828 | msg->insize = sizeof(*features); |
| 828 | | 829 | |
| 829 | ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); | 830 | ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); |
| 830 | if (ret < 0) { | 831 | if (ret < 0) { |
| 831 | dev_warn(ec->dev, "cannot get EC features: %d/%d\n", | 832 | dev_warn(ec->dev, "cannot get EC features: %d/%d\n", |
| 832 | ret, msg->result); | 833 | ret, msg->result); |
| 833 | memset(ec->features, 0, sizeof(ec->features)); | 834 | memset(features, 0, sizeof(*features)); |
| 834 | } else { | 835 | } else { |
| 835 | memcpy(ec->features, msg->data, sizeof(ec->features)); | 836 | memcpy(features, msg->data, sizeof(*features)); |
| 836 | } | 837 | } |
| 837 | | 838 | |
| 838 | dev_dbg(ec->dev, "EC features %08x %08x\n", | 839 | dev_dbg(ec->dev, "EC features %08x %08x\n", |
| 839 | ec->features[0], ec->features[1]); | 840 | features->flags[0], features->flags[1]); |
| 840 | | 841 | |
| 841 | kfree(msg); | 842 | kfree(msg); |
| 842 | } | 843 | } |
| 843 | | 844 | |
| 844 | return !!(ec->features[feature / 32] & EC_FEATURE_MASK_0(feature)); | 845 | return !!(features->flags[feature / 32] & EC_FEATURE_MASK_0(feature)); |
| 845 | } | 846 | } |
| 846 | EXPORT_SYMBOL_GPL(cros_ec_check_features); | 847 | EXPORT_SYMBOL_GPL(cros_ec_check_features); |
| 847 | | 848 | |