| @@ -812,36 +812,37 @@ EXPORT_SYMBOL(cros_ec_get_host_event); · 811 unmodified lines |
| 812 | 812 | */ |
| 813 | 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 | 816 | struct cros_ec_command *msg; |
| 816 | 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 | 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 | 822 | if (!msg) { |
| 822 | 823 | dev_err(ec->dev, "failed to allocate memory to get EC features\n"); |
| 823 | 824 | return false; |
| 824 | 825 | } |
| 825 | 826 | |
| 826 | 827 | msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; |
| 827 | | − msg->insize = sizeof(ec->features); |
| 828 | + msg->insize = sizeof(*features); |
| 828 | 829 | |
| 829 | 830 | ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); |
| 830 | 831 | if (ret < 0) { |
| 831 | 832 | dev_warn(ec->dev, "cannot get EC features: %d/%d\n", |
| 832 | 833 | ret, msg->result); |
| 833 | | − memset(ec->features, 0, sizeof(ec->features)); |
| 834 | + memset(features, 0, sizeof(*features)); |
| 834 | 835 | } else { |
| 835 | | − memcpy(ec->features, msg->data, sizeof(ec->features)); |
| 836 | + memcpy(features, msg->data, sizeof(*features)); |
| 836 | 837 | } |
| 837 | 838 | |
| 838 | 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 | 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 | 847 | EXPORT_SYMBOL_GPL(cros_ec_check_features); |
| 847 | 848 | |