From patchwork Mon Jul 25 09:59:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 72699 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1057154qga; Mon, 25 Jul 2016 02:59:42 -0700 (PDT) X-Received: by 10.66.193.39 with SMTP id hl7mr27792712pac.10.1469440771212; Mon, 25 Jul 2016 02:59:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si25322297pfb.247.2016.07.25.02.59.30; Mon, 25 Jul 2016 02:59:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752449AbcGYJ7a (ORCPT + 3 others); Mon, 25 Jul 2016 05:59:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:36815 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbcGYJ72 (ORCPT ); Mon, 25 Jul 2016 05:59:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A3B8FAD1C; Mon, 25 Jul 2016 09:59:27 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: Linus Walleij , Jonathan Cameron , Jiri Slaby Subject: [patch added to 3.12-stable] iio: accel: kxsd9: fix the usage of spi_w8r8() Date: Mon, 25 Jul 2016 11:59:13 +0200 Message-Id: <20160725095923.9322-9-jslaby@suse.cz> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160725095923.9322-1-jslaby@suse.cz> References: <20160725095923.9322-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Linus Walleij This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. -- 2.9.2 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html =============== commit 0c1f91b98552da49d9d8eed32b3132a58d2f4598 upstream. These two spi_w8r8() calls return a value with is used by the code following the error check. The dubious use was caused by a cleanup patch. Fixes: d34dbee8ac8e ("staging:iio:accel:kxsd9 cleanup and conversion to iio_chan_spec.") Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron Signed-off-by: Jiri Slaby --- drivers/iio/accel/kxsd9.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 34277153c211..61dcbcf73c22 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -81,7 +81,7 @@ static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro) mutex_lock(&st->buf_lock); ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); - if (ret) + if (ret < 0) goto error_ret; st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C); st->tx[1] = (ret & ~KXSD9_FS_MASK) | i; @@ -163,7 +163,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_SCALE: ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); - if (ret) + if (ret < 0) goto error_ret; *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK]; ret = IIO_VAL_INT_PLUS_MICRO;