Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2503691ybz; Sun, 3 May 2020 02:34:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJ5IqRBokQD8o1WnV36bnXmOtYHwCyN3iKMfqAekQUqTS31oQEEqJkXlsg8ATUgIHkvvt3X X-Received: by 2002:aa7:c98a:: with SMTP id c10mr10404430edt.94.1588498449749; Sun, 03 May 2020 02:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588498449; cv=none; d=google.com; s=arc-20160816; b=eZbq/EbIc0X9mI7IfBJIhX69PW8fkWf5mh9x9xEUiO7zU9ubbT50HsigYni5+mPQbE K5hFMrFPaL7r759JtbofE8nSwfuDFnXdzgyZHZ52RIbP4WAIzEQ4mQOju+63JhNWSUB1 DKxea9cuKlZBR/txQ/R8j6XQjlhyKflaMxsAiTgTiX6SOeGAOQALvQaUdINbp7VIITq4 OMb1jKNGtGx8DWbHnrsE8drqk2QD9aSQ8i87gF1dyj/OwvobL/kMkXlM+J9hbzezUz42 UuabhR4gsmPexxAGmT7cXM5av7vYiNBZFVyz9aqYkYx2/TOomE56+h9qdKMHwT13YNm1 gNvg== 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=1K9HR6HwCf2nmSwUHn99KqNtbjn4Ac+2ymZ0fApUQkA=; b=FJikcJoyNr4GcDlbNtcekLaJiJB9Wv6mpNWpSuExozEUcGsFUG6LZILzFKpMWVuFoE SQTti4bbTvI1HT/LSCcVCLiphGXxec/yEoPc9ma7qiAiJSTUCcAgg9mdM9nPCIMVxy2g 7adweSli2ci8VASxscgWkOnhwKgXvnmXoJdyl0o2QccGpkaA0SYm1a9kkYFYQxJW2RIw 1zjOlfHFvnn0RUEiw9rzXvESR00fS/VgvwppvVnPw/bkacPVyncCTVo4yVzaXa+RB5Ws j5NcJxrrcOX5HgymdY+n/nwV2qJBzNSRMX5bjIzOp0a7qcdnD9kdoGpKshJM35moM040 YwkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aDzrCnl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oq22si4547500ejb.213.2020.05.03.02.33.47; Sun, 03 May 2020 02:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aDzrCnl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbgECJcX (ORCPT + 99 others); Sun, 3 May 2020 05:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726445AbgECJcW (ORCPT ); Sun, 3 May 2020 05:32:22 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B66EC061A0C; Sun, 3 May 2020 02:32:22 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id k1so17250650wrx.4; Sun, 03 May 2020 02:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1K9HR6HwCf2nmSwUHn99KqNtbjn4Ac+2ymZ0fApUQkA=; b=aDzrCnl9cM0RFHjgLgy7hzS/vXj0mVa93H1A6hwYw6mGdnv+o6KWbqhE98L1gSA/Wm aeqeFhx070MpCze4t73nFhL9Skuc28zAq/9Za/pWTeggYHokEy7H6pZ18nsgs2C0ajN2 79w58jdcpq9pH8tgSD74Rs2/1F00dNCvC6hXDKFtHss07qVvnfUi3m/rnj5RQAQtbIPy uSXWPx2r1Pv2FDZa5rAA6qnqvqm4fz7MrtfdM+QL4N0xKzsnsRQhbpLiO6UqscMY5b/4 55JXA1BR+rEcD5FU/kBS61DlN1VEm+IDThKRIBCV3pDr38C1gX256L8YT02/kX9Mc/JS 97Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1K9HR6HwCf2nmSwUHn99KqNtbjn4Ac+2ymZ0fApUQkA=; b=H6PKOOW7+vi9z/2Kc6uPy/nKgv9ze0HmAo84+2sm1par3DrNFsLNNWRkH2G/NiwblU qTqSJBafe3O9f1TFKyvzab4ewwLoGu0GDOSsUZTqUOQh2jSvFhCKHdWskEvyzKSObRzp tXrvo6wQN2gh52NVTBpK3OKaSC4Lt3Z4+1OsFQ7QlvfOiRoEmJXdfPyuie+RDlroKPXN 6vw+UwLwQOe3RyxmeNjLZuLZshGvCo0m4M7dSIoW28C5KgkhkJm9wFeqh45IqkSvoEVq SVnTlmcRTfQUy8oSwfw6WPYjgLQNt4ml4D6eY9z7L/W7oX5XGdjgZivXpcqhK+UQXGC5 i7ww== X-Gm-Message-State: AGi0PubXvo2psabTgdMEDLYKJCSjQpt64N4CQ6/VhyMCgmiit/snEqqk r6acuIYVHfH52lAK6flkCHw= X-Received: by 2002:a5d:5273:: with SMTP id l19mr13196617wrc.42.1588498340795; Sun, 03 May 2020 02:32:20 -0700 (PDT) Received: from meru.home ([2a01:cb18:832e:5f00:1cf0:acc0:9003:83d6]) by smtp.gmail.com with ESMTPSA id e17sm10086963wrr.32.2020.05.03.02.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2020 02:32:20 -0700 (PDT) From: Mathieu Othacehe To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Othacehe Subject: [PATCH v7 1/5] iio: vcnl4000: Fix i2c swapped word reading. Date: Sun, 3 May 2020 11:29:55 +0200 Message-Id: <20200503092959.8806-2-m.othacehe@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200503092959.8806-1-m.othacehe@gmail.com> References: <20200503092959.8806-1-m.othacehe@gmail.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 The bytes returned by the i2c reading need to be swapped unconditionally. Otherwise, on be16 platforms, an incorrect value will be returned. Fixes: 62a1efb9f868 ("iio: add vcnl4000 combined ALS and proximity sensor") Signed-off-by: Mathieu Othacehe --- drivers/iio/light/vcnl4000.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 58e97462e803..e5f86bd00fb0 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -219,7 +219,6 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, u8 rdy_mask, u8 data_reg, int *val) { int tries = 20; - __be16 buf; int ret; mutex_lock(&data->vcnl4000_lock); @@ -246,13 +245,12 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask, goto fail; } - ret = i2c_smbus_read_i2c_block_data(data->client, - data_reg, sizeof(buf), (u8 *) &buf); + ret = i2c_smbus_read_word_swapped(data->client, data_reg); if (ret < 0) goto fail; mutex_unlock(&data->vcnl4000_lock); - *val = be16_to_cpu(buf); + *val = ret; return 0; -- 2.26.0