Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1180927ybl; Fri, 24 Jan 2020 17:23:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyePt7fKyeVOZ8YxfmrN0qyIWhtosQLPkiidQlIKQdJbJFWj3a4HEItPbPIn3pqv3+pbeKU X-Received: by 2002:a05:6830:1050:: with SMTP id b16mr635585otp.140.1579915404889; Fri, 24 Jan 2020 17:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579915404; cv=none; d=google.com; s=arc-20160816; b=0yn9opCV/Ekw/hUsMScLWzgFPyOVMnt8MC/Ct7YzM/4s2hgDIZFciZnzH8Q9C4kUZv BeL1NlusseLAkEDsnyCrIRYlBsHnUnNMZ5TlCZ1RwO3OEgWzvTlNj0U2t810QRW3Sysw /lulfOxagATol22SMPGiVPflCw6S5Jq1rgkU6XhaTYRaG1d9NlKZ4Mo+8C07L6aTJh9t RmfJBmT53r2/2G2+8ZEYFsMwS3Tj7CR5ih8q6kiD1lJYaQriGYZymAtpWJ3Q5C6yPnzL BMcFIObQpj1fUBNq8jSC6GhSjm3mY6Gxpb9GtcZvx3ScHM27opjxTfI37CSFbJ7TxgoP 3Cow== 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=JwNAT38uZz21Fou+nxtSqV2POWJ4Lnccl1Lds062gEU=; b=bifDI3btT/7UlE3iJtnq3zhiM76wLk+m2nGWk/ATaq+XMK1pzUCi5e+sVi4hLR2vRi Zv7KR0bkgIKqoWVm4WKzI+YZSJhCHGNOV7coc/JKa7Fh+tsW38BcqjoYvhjvPpV9sVCw iml204+BhTyVnGb13dUEejjF6QQ4cA3OvGLk95SWWMl6VAn85iU9w9Y7yoBYsOn+Vpll sIiCPSNcRcmt6jcn0a6sKbTiPYlKOgpEAmkZqDNSt74x3egmThqgh5cCkEgafk7EKDb+ FlLZLmUKo5cGC7v6Fxub+C+aL9lYqD4lQqfG8rmOuaHTkwD8wRaRv9FI0n+Kije1xURx bFig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eN8g4PFU; 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 g6si3683150otk.171.2020.01.24.17.23.12; Fri, 24 Jan 2020 17:23:24 -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=eN8g4PFU; 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 S1729742AbgAYBWF (ORCPT + 99 others); Fri, 24 Jan 2020 20:22:05 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34277 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbgAYBWF (ORCPT ); Fri, 24 Jan 2020 20:22:05 -0500 Received: by mail-pf1-f193.google.com with SMTP id i6so1958112pfc.1 for ; Fri, 24 Jan 2020 17:22:04 -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=JwNAT38uZz21Fou+nxtSqV2POWJ4Lnccl1Lds062gEU=; b=eN8g4PFUQA/zfbSLhLk0EizRBjwVlPnAj486l7RDRW27upiEendjq7GCQDT+V/fTAg 21r76jPO1mroldm/9YfgdbOeYXS3ODUtYa2XKmQ9leu14e5NH1lpv4nTnXQY9aS2KoPx Mm+vgQa5lFxjOXYpsRqAZsGAD5nqNo+gcB+Y4= 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=JwNAT38uZz21Fou+nxtSqV2POWJ4Lnccl1Lds062gEU=; b=IQVnQJUH0oGPvcUlBMaonJnBqzn7H3Q4ftS7E0k6x22MqP/ZYawqZA+fKQiyx36fMg 6GjErSlZeDBcgXRmISsUMiE8MAH22nIPvCS3WC1jorhR2s8V4Zpeuy0zypFUBYnjDtKz dXe864hX/pI0RPueCvn2n5wN14+LyBEs7vyqNONsUjNarv9bkNX5sR/ykFXt9EFD7QxT YZv792+FvUxkB/PGXPJPnc1pV74SeYMIgIWtvGo+cHvqxdMYAt/d8Rb3ZLxEC6sKGwWE VhFBXwsItRh9+qMGvLcZgxjFnuHd0C92YT9RW+It4dedl874nyjx71w1moX5bFPg0Abp dSUQ== X-Gm-Message-State: APjAAAWMknLGcYzIw7BYfVcFOIyOY6tXaxRKPA6w8qA5yJZOSvg5tCzk 666jRLOmYhyC5vwKqbG+PGQYTw== X-Received: by 2002:a62:486:: with SMTP id 128mr5982032pfe.236.1579915324262; Fri, 24 Jan 2020 17:22:04 -0800 (PST) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:172e:4646:c089:ce59]) by smtp.gmail.com with ESMTPSA id n4sm7443337pgg.88.2020.01.24.17.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 17:22:03 -0800 (PST) From: Prashant Malani To: enric.balletbo@collabora.com, bleung@chromium.org Cc: linux-kernel@vger.kernel.org, Prashant Malani Subject: [PATCH 3/4] platform/chrome: Use send_cmd_msg in debugfs Date: Fri, 24 Jan 2020 17:21:07 -0800 Message-Id: <20200125012105.59903-4-pmalani@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200125012105.59903-1-pmalani@chromium.org> References: <20200125012105.59903-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 Update Chrome EC's debugfs driver to use the cros_ec_send_cmd_msg() wrapper instead of cros_ec_cmd_xfer_status() within the pdinfo_read() function. This helps to remove some of the structure and buffer definitions and some of the message buffer set up code. Signed-off-by: Prashant Malani --- drivers/platform/chrome/cros_ec_debugfs.c | 39 +++++++---------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c index 6ae484989d1f5..34c1c36be1c51 100644 --- a/drivers/platform/chrome/cros_ec_debugfs.c +++ b/drivers/platform/chrome/cros_ec_debugfs.c @@ -199,44 +199,29 @@ static ssize_t cros_ec_pdinfo_read(struct file *file, char read_buf[EC_USB_PD_MAX_PORTS * 40], *p = read_buf; struct cros_ec_debugfs *debug_info = file->private_data; struct cros_ec_device *ec_dev = debug_info->ec->ec_dev; - struct { - struct cros_ec_command msg; - union { - struct ec_response_usb_pd_control_v1 resp; - struct ec_params_usb_pd_control params; - }; - } __packed ec_buf; - struct cros_ec_command *msg; - struct ec_response_usb_pd_control_v1 *resp; - struct ec_params_usb_pd_control *params; + struct ec_response_usb_pd_control_v1 resp = {0}; + struct ec_params_usb_pd_control params = {0}; int i; - msg = &ec_buf.msg; - params = (struct ec_params_usb_pd_control *)msg->data; - resp = (struct ec_response_usb_pd_control_v1 *)msg->data; - - msg->command = EC_CMD_USB_PD_CONTROL; - msg->version = 1; - msg->insize = sizeof(*resp); - msg->outsize = sizeof(*params); - /* * Read status from all PD ports until failure, typically caused * by attempting to read status on a port that doesn't exist. */ for (i = 0; i < EC_USB_PD_MAX_PORTS; ++i) { - params->port = i; - params->role = 0; - params->mux = 0; - params->swap = 0; - - if (cros_ec_cmd_xfer_status(ec_dev, msg) < 0) + params.port = i; + params.role = 0; + params.mux = 0; + params.swap = 0; + + if (cros_ec_send_cmd_msg(ec_dev, 1, EC_CMD_USB_PD_CONTROL, + ¶ms, sizeof(params), &resp, + sizeof(resp)) < 0) break; p += scnprintf(p, sizeof(read_buf) + read_buf - p, "p%d: %s en:%.2x role:%.2x pol:%.2x\n", i, - resp->state, resp->enabled, resp->role, - resp->polarity); + resp.state, resp.enabled, resp.role, + resp.polarity); } return simple_read_from_buffer(user_buf, count, ppos, -- 2.25.0.341.g760bfbb309-goog