Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2170647ybl; Thu, 30 Jan 2020 12:37:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzt5YsrbW2GdDrynEVzQUbNPG78yhuFmdWHGh+ST0wPVoA5GbEozQQNIYrMQAtj6FGR6+Jg X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr4846928otr.82.1580416620306; Thu, 30 Jan 2020 12:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580416620; cv=none; d=google.com; s=arc-20160816; b=jjO/uca0B5l8pt92aNzDl67xZCPyzrspMQIDnZRBiwqevk11xCqCjoLmzMu6E0IZYX 2ftvCw9COtnrHnaTrLtet0mlz7k+va1SZlmzvRhmjpegi1h74V7mGWDBjY3JMuXVs3VR xBG/b/jkU1T0qS4z+MKwup8rUsUe2UHcypddgDFGQAwjFSmTTtkfVMiGJVTnsmnqN+Sf OpQoBUIPkFiPgqXZO+MyeyDINyF3pK9YqevYV17wkeHRUA9JS2218vw6eReFArKcyVd5 iFiiHuqKhbKkRYS8lMUwO7rzhBd2qZVBXce319oXdQ5c2tFJsf/Uy5mWJ6W2OlB8qadR caig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ls2tMeKv9f/jgxrcgT00rlFPgO3Iqf2bPNU9NTKhuuA=; b=RIEJpIGAmPLCn+AVIaCoox+jEiR8b4yDAHyzUGN50aG4jtcJGusbavyViisQ900Ryp I6WIZytauOvVNdv/wdJhOokzpaIdo0jM6LXqhO0BKWabZtS2ZsG5+Hfg+O4BJfIm5AzO L8MDn+sQWwSobh7g08TeDrnutJJUQIkvonEgW8ypeeVqo2pYwu9AJyQD7IOl31kFnocm NduDVGtVYkG3qbJBKr3Hvr7iQrTLowYT77Xzo6tvUe1u7t/t5xc1dfa1OfEMbZBVfpeG viZIcS3gOj9tRp45dHv87fBC+5tZD8zrUP6nGhsUDHDGtwpIhVEpWkJS7UcT0Jf08KpZ +LMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=g7awB2ne; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e192si3017653oib.82.2020.01.30.12.36.48; Thu, 30 Jan 2020 12:37:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=g7awB2ne; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbgA3Ueb (ORCPT + 99 others); Thu, 30 Jan 2020 15:34:31 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38610 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727515AbgA3Ueb (ORCPT ); Thu, 30 Jan 2020 15:34:31 -0500 Received: by mail-pg1-f193.google.com with SMTP id a33so2247238pgm.5 for ; Thu, 30 Jan 2020 12:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ls2tMeKv9f/jgxrcgT00rlFPgO3Iqf2bPNU9NTKhuuA=; b=g7awB2ne4o5cENNYO4XNZlKcdtN8PAc/gTPbg8CFzfTmV7vVXy0DaMpOT1WCpvirXj ILtB4VGoCSqxDbVxIIg6dkSkjOOAzvGm2Muc0iM7VUAcvoFOWtR6d8uoQGpV8IHdkguE GUejGP2g1hEG3giv+H3VxhLiwH9QDlLB1OYpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ls2tMeKv9f/jgxrcgT00rlFPgO3Iqf2bPNU9NTKhuuA=; b=FzmqFKNpd0pm1I8dptS7dZOq7c72YOm6VLhHalV/gtoJfPQ7lfLYIBeZBNCRrGrvWK dvqrZZGUgH8zLCMwMc4+kq5hkLrTpxG6U3xlZoZ7/8NIwW5W2rvZHi5Z3Jv/srhG4S8H U0JWnmVdSfoDMhWrW92F5gyPEmt9A9JxhVwx5qI6sf8vwNrEMSQLHpZxJs4Wo6QPwfOq FSVa3+D/2N2oSpcmY/P1+rjmACA8WcI0Ttya759hOLU1nzMuBg787coRv6xDCntG/KTf 2nq8zkMFqtDCN+NxOVuCuiXioNpvvXwsfFPOv9waxPzmgJzTqkf+fPgrrLSQ/JJSjH+F Caxg== X-Gm-Message-State: APjAAAUeHzGhgahmM3O2KVNr3HBPsEgYtB/0yev5k7v49ejQ9u3F9Jsh wHWWNFcx/yjJR6FCpkq+EtjXZdeXAG/hHw== X-Received: by 2002:a63:ed4a:: with SMTP id m10mr5736301pgk.99.1580416469829; Thu, 30 Jan 2020 12:34:29 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id q12sm7469321pfh.158.2020.01.30.12.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 12:34:29 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org (open list:HID CORE LAYER) Subject: [PATCH 09/17] hid: google-hammer: Use cros_ec_send_cmd_msg() Date: Thu, 30 Jan 2020 12:30:52 -0800 Message-Id: <20200130203106.201894-10-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200130203106.201894-1-pmalani@chromium.org> References: <20200130203106.201894-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace cros_ec_cmd_xfer_status() with cros_ec_send_cmd_msg() which does the message buffer setup and cleanup. Signed-off-by: Prashant Malani --- drivers/hid/hid-google-hammer.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c index 2aa4ed157aec87..428762a6a4993f 100644 --- a/drivers/hid/hid-google-hammer.c +++ b/drivers/hid/hid-google-hammer.c @@ -53,38 +53,25 @@ static bool cbas_parse_base_state(const void *data) static int cbas_ec_query_base(struct cros_ec_device *ec_dev, bool get_state, bool *state) { - struct ec_params_mkbp_info *params; - struct cros_ec_command *msg; + struct ec_params_mkbp_info params = {0}; int ret; - msg = kzalloc(sizeof(*msg) + max(sizeof(u32), sizeof(*params)), - GFP_KERNEL); - if (!msg) - return -ENOMEM; - - msg->command = EC_CMD_MKBP_INFO; - msg->version = 1; - msg->outsize = sizeof(*params); - msg->insize = sizeof(u32); - params = (struct ec_params_mkbp_info *)msg->data; - params->info_type = get_state ? + params.info_type = get_state ? EC_MKBP_INFO_CURRENT : EC_MKBP_INFO_SUPPORTED; - params->event_type = EC_MKBP_EVENT_SWITCH; + params.event_type = EC_MKBP_EVENT_SWITCH; - ret = cros_ec_cmd_xfer_status(ec_dev, msg); + ret = cros_ec_send_cmd_msg(ec_dev, 1, EC_CMD_MKBP_INFO, + ¶ms, sizeof(params), state, sizeof(u32)); if (ret >= 0) { if (ret != sizeof(u32)) { dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n", ret, sizeof(u32)); ret = -EPROTO; } else { - *state = cbas_parse_base_state(msg->data); ret = 0; } } - kfree(msg); - return ret; } -- 2.25.0.341.g760bfbb309-goog