Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1256426ybl; Fri, 23 Aug 2019 16:19:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxY/lJZ1l12CNc+UOVxtwWNASS9RdkrNXwCY5WXlM0Vnj3cyGNyP5UDkQeW7TL4vS2BG7Md X-Received: by 2002:a17:902:e48d:: with SMTP id cj13mr7357766plb.177.1566602351121; Fri, 23 Aug 2019 16:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602351; cv=none; d=google.com; s=arc-20160816; b=FXTsLy31lMFm1gAybChC0JAOoOWrne1UdcY9FuMFitzQ6+qwTjIVYBv4rTMkugFiU5 az6NFpHYizx9f2chFOdMvfAoI44/odUsi1JBDj7vshwh/AFkd6rjGedsWldgmjG/6ixW HoHZFVmnc/shN0QKCr03VrZtmF3kd26WtbSNHEHkERCyN9XrIEyXP8rbLwlBNlRJP4op 3UTWnEdUkKGBiDXm5U+hx+AbEMSnrHdrb7ISMu1LKy4yPhfcYgR9wXzgpN764lqf496r Swed7DmXUFeOuiNMTxip1wGcS94pnqSIg29XVWdwExMJIFZYNDxvfbcXlzSStxg0DxIj YUSQ== 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=DzRmZ2ujFwx1of8IG/37qg2nyqMuUkwFepjj+8tQI+k=; b=yAklBXn5iZeHwTvbN0Ix6PhyvFvnbvHcNTVQpnKMMME5FJOUEuGPjqMxZWqZDLLZI9 QjSXMI7GlpYaRw3m+ERZ3ZgOp54gOLSrtVrx/Qc1S6v4Nc6/DoXwIWytr2BFllsJUk3O bBr17KzRQts6jXbYm1JCYRT1FvU+x8YcgAQgi32/Gc7Aw+HhUQbTQI7RDWMLfXd27Z08 O1IX+Zix3RFBuEIIYXP1cQ+bY/5B3cCV9EJ5jX+QeatAJ6b+YDf5cdF8+1u3PxtUT0GW sfFSuZpNxBuBMGJ3Zg5S1JKQNqZjto4NJts4F2IDcg00+elR6twa/eDGjwtbAu94SqLQ 4b7A== 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 i6si3836967pfb.122.2019.08.23.16.18.55; Fri, 23 Aug 2019 16:19:11 -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 S2394922AbfHWMyY (ORCPT + 99 others); Fri, 23 Aug 2019 08:54:24 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46386 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394917AbfHWMyX (ORCPT ); Fri, 23 Aug 2019 08:54:23 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 8E6E828D382 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 , Andy Shevchenko , Gwendal Grignou Subject: [PATCH v6 07/11] mfd: cros_ec: Use kzalloc and cros_ec_cmd_xfer_status helper Date: Fri, 23 Aug 2019 14:53:27 +0200 Message-Id: <20190823125331.5070-8-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190823125331.5070-1-enric.balletbo@collabora.com> References: <20190823125331.5070-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 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