Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3623277imu; Mon, 28 Jan 2019 08:01:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN7itNqXgZSiu0w6b9q4tKDGQwaqLB2l2AaHrN3S0FJgLmi5JIGmRrL6RUZblYjZknK9ZY/D X-Received: by 2002:a63:4e41:: with SMTP id o1mr20806375pgl.282.1548691306930; Mon, 28 Jan 2019 08:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691306; cv=none; d=google.com; s=arc-20160816; b=brG1jYZG3X1RF7Gc82ihV67Qt6qYB56yIGtVFqXl1J9p9RUz9dZoPwVZIhpMke9gS/ 9sQACfSSiv5zQ2CSboST9KnarXuYHg4o8VVvG0357/WuW20Hr53WSyg3AX3L2dA1g36x HDjLzqNF6lb17qqRg4Hl8fuZF/VyUP7+MzQw0J/fuLlJ/netz6H+myVeGt95XgY+6+kR 2Z4vJTuVQWoL5ywtbtcR37ZWAojQvUWbw0hjEXi+t+vVZ/Og//pZc4YuH6/IxfoepPlq fb5v2Nb7NoTQ3u/cFJvm3bYIyAsShlvZxv+QX/E3VsNDDmsh08vRefgO+CGei9o5nn5a KJNw== 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=FKXPVF3Rwmq8umNHgkDxRp9G8/QpnAgduZcDMA5FMTE=; b=r/3wdmI4MnixOYDq7pam3Ry/Sr2MGk4z1xTU3owXZm4nOvIGw5lSJttojxa4YGjMkf f/Ye8Lzd9dDjnRSQr32v7OIwqHEvFjw06KWHGMkPuHhDdWoXySCqZJ4gMPj1mS4g4DHe mMbX3+dpTchKxQOLayqikHgD/PnWbVsmbC71b6ocOcsytMByQYqtpBlklhSTCQvRoRuU b71iqTNpck0aLoM/5Q50SQi5bBAZSrK8IbJSZ1JLodQfqW1q10rfX2E+cuPQIbCLg5YY /Gx5s7WqC0RxYR+GwbL+C4cn4t46xIsaUdwPb3JMtDFva2eGL2J98oOojN8fslKSjWAE Q+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SivOAHz5; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si34040654pfg.254.2019.01.28.08.01.31; Mon, 28 Jan 2019 08:01:46 -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=@kernel.org header.s=default header.b=SivOAHz5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730579AbfA1P7d (ORCPT + 99 others); Mon, 28 Jan 2019 10:59:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:44820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728987AbfA1P7c (ORCPT ); Mon, 28 Jan 2019 10:59:32 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3F772175B; Mon, 28 Jan 2019 15:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691171; bh=t5Tx9wOUdjwV1AZezCkGQiVXL1YLa/2ZDs3LGxniwpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SivOAHz5ESyl1lEDcyb9QSLDnj7eXCWQWt14kv9ep4kBAEml4KQTaXRolJqqKXhxU usYUKpRPzPq/ux+kUwvxQrvj7PIdqBhNdqstjroRvHIiGDDI5GFiA4Rc2or4/JfKlE CnKeLbZKEjlQSxptUXCoq12ofyeB0Zaph6rnHdJY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Slawomir Stepien , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 002/258] staging: iio: adc: ad7280a: handle error from __ad7280_read32() Date: Mon, 28 Jan 2019 10:55:08 -0500 Message-Id: <20190128155924.51521-2-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Slawomir Stepien [ Upstream commit 0559ef7fde67bc6c83c6eb6329dbd6649528263e ] Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative error code. This change will ensure that this error is being passed up in the call stack, so it can be handled. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/staging/iio/adc/ad7280a.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index b736275c10f5..6a48ad067a8b 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr, if (ret) return ret; - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr, ad7280_delay(st); - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt, ad7280_delay(st); for (i = 0; i < cnt; i++) { - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st) return ret; for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { - __ad7280_read32(st, &val); + ret = __ad7280_read32(st, &val); + if (ret) + return ret; + if (val == 0) return n - 1; -- 2.19.1