Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7202356ybi; Mon, 22 Jul 2019 08:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbfyewv9MoCyb13hH4viTJKWBtUbN42p2XDjZDOFUnzYvzUX3coIF1t/6P/Tcg6ybMkFsk X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr73681514plb.139.1563810511932; Mon, 22 Jul 2019 08:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563810511; cv=none; d=google.com; s=arc-20160816; b=t+ONMi2vMCFgWFY6SKlCVio0qsSWPQpA0z9DDUVFatxh4Nm1sALiWjQ4+U13AsTzUk BRLL3dhRac751t6BmXgU6E9JuIx2VowVnLPexMX3nTAGJ6iGHSxM74hpQrntaP9h9oL+ 8201ryjjU+duaV0Nv6HnnSUBtcoFZwQaBIkz3ATR9J0KD9kLvCDbIpixOBhsjxvZVUQg QZJ+YX6OVT0qzEtBs8K/tlHl5lOQ6nHx+sruxdEu6PeMKN/hVRKdEKnF/larBbCRPEYh Q8LZzQkKkHRs/qLYbTK+/ScX/p//rgM0Ovdv+oEFQq8o3hh4T65FT0xdtz/G4CVQHskw Wm9g== 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=t08oBCJJqa7Wk+FqGjl4HsZgld15ANlRgSxszQrcpxY=; b=KllV4HFMdbRJ3y6HtrScEmT51MhpRAheU7CaazTdXrEtm+AQjAIO/4axyXyiykOtI3 AjgIyQbr6WfgQC+270wYHh+hIEqKd5CzbRbJNeLJ0K24rjR5IdwUOm5MBe5KQBrPqZ6G HZCUe2+iYxsAMNKXDFaBq8N0v7jtehM8l36J6Pw5rClftufrOurOCvCw9rR7rBght/+f A4mroyfltT6s3M7+C4+DrUzT8cf6N82RGFtpbypyaf1hSP83S4PjyUhMfXvlpKEks7i4 YPJknbeTnDOSFXZg5bNInWlhWof8yHjAnsI7rfqOpISsN4i6Q0E3qidaWZ28uyMsE18V 95yw== 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 m11si9183776pls.148.2019.07.22.08.48.16; Mon, 22 Jul 2019 08:48:31 -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 S1730576AbfGVNdY (ORCPT + 99 others); Mon, 22 Jul 2019 09:33:24 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:36392 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730345AbfGVNdU (ORCPT ); Mon, 22 Jul 2019 09:33:20 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id B0E6028B0BE 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 v5 07/11] mfd: cros_ec: Use kzalloc and cros_ec_cmd_xfer_status helper Date: Mon, 22 Jul 2019 15:32:53 +0200 Message-Id: <20190722133257.9336-8-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722133257.9336-1-enric.balletbo@collabora.com> References: <20190722133257.9336-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 --- 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 4300ad919d74..c6bf52d795f2 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -29,18 +29,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)); @@ -89,8 +86,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; @@ -117,8 +114,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