Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp366367ybe; Mon, 2 Sep 2019 02:57:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqznJx/2WhGjXRF/p1VyDPXzOGmhVG3+HXwvQl0WajgOID5V0whAkGmecYftDl/LMYKe0ytX X-Received: by 2002:a17:902:bc4c:: with SMTP id t12mr28327246plz.90.1567418249655; Mon, 02 Sep 2019 02:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567418249; cv=none; d=google.com; s=arc-20160816; b=uU0/uGjUKSFoFUuQxCrKiNqxcvmHNFQq3QyYu56ovixm12002iJlRQUohGYti6Oejv Nmfyzi73PdVTyCsJ0HlLG3zXVQqL381c2Kvib5dDkTsHkDQYy8Frm/j9/lMGqkxoxdLQ CL0iiUXMvCUriPGocC+mS2cZPqtX6kRI80VdKh66gflZLX0xSRaEcu2GgSkA441nta7y dg8y6fAjfDI+VjZcQZu5EjKEAjnTk/qapgJjIcX6b1/J5LwFKe0A2MTe7R5HksyLVLFL StypiQwRNwFQ+Yr2SP4PCwQ35ArK6fhHJtt6WLzTlZnnCNjodj2obKrOHI6ijT55HpdI Dyxg== 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; bh=TjIWMo+QvH+/NMHAUUXz2IoYDtwVGV4T0fSPCUeI72k=; b=ZPNr7RK7Y4AI98AKjD+oEVjQQLh6Fg7V/YGi4cbWu7dzcjVgAYChmfCOjU84csFWIj wZRjpllQVUPS4BEUQ9gGGGssp8TxIKNHPHXvDwk5awHK5oltmZepNj8fUko3pI1cX/Tq CDYVGkeoJdGBeB8eh7wbRdVEv3yryECL4I/UAQu34oN2oiOlQkSZ7+m9isf41cuUDU3P Q59rS/vVHbdEovgsi0ktwE+kFYbgycfTOPmr71Fg7pQxdyba1py/3ut3H0oJIPJPaUu6 Jco1epyeUeSSqlpfDRDeR2U/+zcXmFrnHbpr3y3u+gYse7sMp212ntWapvKSjPqqjbzJ 3row== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si9369512pfe.179.2019.09.02.02.57.15; Mon, 02 Sep 2019 02:57:29 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731434AbfIBJxw (ORCPT + 99 others); Mon, 2 Sep 2019 05:53:52 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46816 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731381AbfIBJxb (ORCPT ); Mon, 2 Sep 2019 05:53:31 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id B1F6C28CBBD From: Enric Balletbo i Serra To: linux-kernel@vger.kernel.org Cc: Jonathan Corbet , Krzysztof Kozlowski , Will Deacon , MyungJoo Ham , Chanwoo Choi , Benson Leung , Guenter Roeck , Jonathan Cameron , Dmitry Torokhov , Mauro Carvalho Chehab , Lee Jones , Sebastian Reichel , Thierry Reding , Alexandre Belloni , Liam Girdwood , Mark Brown , Neil Armstrong , Greg Kroah-Hartman , Collabora kernel ML , arnd@arndb.de, Andy Shevchenko , Gwendal Grignou Subject: [PATCH v7 07/10] mfd: cros_ec: Use kzalloc and cros_ec_cmd_xfer_status helper Date: Mon, 2 Sep 2019 11:53:06 +0200 Message-Id: <20190902095309.18574-8-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190902095309.18574-1-enric.balletbo@collabora.com> References: <20190902095309.18574-1-enric.balletbo@collabora.com> 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 This patch makes use of cros_ec_cmd_xfer_status() instead of cros_ec_cmd_xfer() so we can remove some redundant code. It also uses kzalloc instead of kmalloc so we can remove more redundant code. Signed-off-by: Enric Balletbo i Serra Acked-by: Andy Shevchenko Reviewed-by: Gwendal Grignou Tested-by: Gwendal Grignou Acked-for-MFD-by: Lee Jones --- Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/mfd/cros_ec_dev.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 091d428f5531..148f39c79f41 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -30,18 +30,15 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature) if (ec->features[0] == -1U && ec->features[1] == -1U) { /* features bitmap not read yet */ - - msg = kmalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); + msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); if (!msg) return -ENOMEM; - msg->version = 0; msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; msg->insize = sizeof(ec->features); - msg->outsize = 0; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0 || msg->result != EC_RES_SUCCESS) { + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); + if (ret < 0) { dev_warn(ec->dev, "cannot get EC features: %d/%d\n", ret, msg->result); memset(ec->features, 0, sizeof(ec->features)); @@ -90,8 +87,8 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) params = (struct ec_params_motion_sense *)msg->data; params->cmd = MOTIONSENSE_CMD_DUMP; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0 || msg->result != EC_RES_SUCCESS) { + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); + if (ret < 0) { dev_warn(ec->dev, "cannot get EC sensor information: %d/%d\n", ret, msg->result); goto error; @@ -118,8 +115,8 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) for (i = 0; i < sensor_num; i++) { params->cmd = MOTIONSENSE_CMD_INFO; params->info.sensor_num = i; - ret = cros_ec_cmd_xfer(ec->ec_dev, msg); - if (ret < 0 || msg->result != EC_RES_SUCCESS) { + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); + if (ret < 0) { dev_warn(ec->dev, "no info for EC sensor %d : %d/%d\n", i, ret, msg->result); continue; -- 2.20.1