return ret;
 }
 
-static int cros_typec_ec_command(struct cros_typec_data *typec,
-                                unsigned int version,
-                                unsigned int command,
-                                void *outdata,
-                                unsigned int outsize,
-                                void *indata,
-                                unsigned int insize)
-{
-       struct cros_ec_command *msg;
-       int ret;
-
-       msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL);
-       if (!msg)
-               return -ENOMEM;
-
-       msg->version = version;
-       msg->command = command;
-       msg->outsize = outsize;
-       msg->insize = insize;
-
-       if (outsize)
-               memcpy(msg->data, outdata, outsize);
-
-       ret = cros_ec_cmd_xfer_status(typec->ec, msg);
-       if (ret >= 0 && insize)
-               memcpy(indata, msg->data, insize);
-
-       kfree(msg);
-       return ret;
-}
-
 static int cros_typec_usb_safe_state(struct cros_typec_port *port)
 {
        port->state.mode = TYPEC_STATE_SAFE;
        /* Sending Acknowledgment to EC */
        mux_ack.port = port_num;
 
-       if (cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
-                                 sizeof(mux_ack), NULL, 0) < 0)
+       if (cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
+                           sizeof(mux_ack), NULL, 0) < 0)
                dev_warn(typec->dev,
                         "Failed to send Mux ACK to EC for port: %d\n",
                         port_num);
                .port = port_num,
        };
 
-       return cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_INFO, &req,
-                                    sizeof(req), resp, sizeof(*resp));
+       return cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO, &req,
+                              sizeof(req), resp, sizeof(*resp));
 }
 
 /*
        int ret = 0;
 
        memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
-       ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-                                   disc, EC_PROTO2_MAX_RESPONSE_SIZE);
+       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
+                             disc, EC_PROTO2_MAX_RESPONSE_SIZE);
        if (ret < 0) {
                dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num);
                goto sop_prime_disc_exit;
        typec_partner_set_pd_revision(port->partner, pd_revision);
 
        memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE);
-       ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
-                                   sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
+       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req),
+                             sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE);
        if (ret < 0) {
                dev_err(typec->dev, "Failed to get SOP discovery data for port: %d\n", port_num);
                goto disc_exit;
                .clear_events_mask = events_mask,
        };
 
-       return cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_CONTROL, &req,
-                                    sizeof(req), NULL, 0);
+       return cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req,
+                              sizeof(req), NULL, 0);
 }
 
 static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num)
        };
        int ret;
 
-       ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
-                                   &resp, sizeof(resp));
+       ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req),
+                             &resp, sizeof(resp));
        if (ret < 0) {
                dev_warn(typec->dev, "EC_CMD_TYPEC_STATUS failed for port: %d\n", port_num);
                return;
        req.mux = USB_PD_CTRL_MUX_NO_CHANGE;
        req.swap = USB_PD_CTRL_SWAP_NONE;
 
-       ret = cros_typec_ec_command(typec, typec->pd_ctrl_ver,
-                                   EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
-                                   &resp, sizeof(resp));
+       ret = cros_ec_command(typec->ec, typec->pd_ctrl_ver,
+                             EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
+                             &resp, sizeof(resp));
        if (ret < 0)
                return ret;
 
 
        /* We're interested in the PD control command version. */
        req_v1.cmd = EC_CMD_USB_PD_CONTROL;
-       ret = cros_typec_ec_command(typec, 1, EC_CMD_GET_CMD_VERSIONS,
-                                   &req_v1, sizeof(req_v1), &resp,
+       ret = cros_ec_command(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS,
+                             &req_v1, sizeof(req_v1), &resp,
                                    sizeof(resp));
        if (ret < 0)
                return ret;
        typec->typec_cmd_supported = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD);
        typec->needs_mux_ack = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
 
-       ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
-                                   &resp, sizeof(resp));
+       ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
+                             &resp, sizeof(resp));
        if (ret < 0)
                return ret;