From patchwork Sun Oct 13 09:30:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 11187325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DD56112B for ; Sun, 13 Oct 2019 09:32:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02081206A3 for ; Sun, 13 Oct 2019 09:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570959149; bh=vv0x3V4u3Fs9k+8MDwLKn2jmOM3f5l4VL12Gif3ewN8=; h=From:To:Cc:Subject:Date:List-ID:From; b=0Zjmjuw4N+n/cxbV1XJveGXbpcU3PkdR3TZm1L/LIsnQw8sqdj87zYggseRm/fzog gPE5AfUGPrgCQ/ZzuKcYFcWcY10lgh+BCilJVZNUm6iwxRb/1l1Ys0+h6XOomIScOu 0hFxCrk7oiajmpSLs1Fkx2OAZW/A3HMn5V8+v20Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728489AbfJMJcY (ORCPT ); Sun, 13 Oct 2019 05:32:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:46644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728080AbfJMJcY (ORCPT ); Sun, 13 Oct 2019 05:32:24 -0400 Received: from localhost.localdomain (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 69EB420679; Sun, 13 Oct 2019 09:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570959143; bh=vv0x3V4u3Fs9k+8MDwLKn2jmOM3f5l4VL12Gif3ewN8=; h=From:To:Cc:Subject:Date:From; b=YkQEcJsBAKIdXzqvLn7D8KCQEBYA+mbKYNfTYeOfQiTBw/o7DhjFp+biKWQq0pgwz Fu/hIww+rwhTCz4GwpHm4MtsmXL5AH8Ids5l5cwFnH9ewlMlYeqhupD2Lahq0W/p0M D60f4d1OECvI4mV7vlMCAnbgEY/12Se1ZKJUEOoo= From: jic23@kernel.org To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jonathan Cameron , Lee Jones Subject: [PATCH] mfd: twl: endian fixups in i2c write and read wrappers. Date: Sun, 13 Oct 2019 10:30:15 +0100 Message-Id: <20191013093015.1395332-1-jic23@kernel.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Use a local variable to ensure correct endian types for intermediate results. Identified by sparse when building the IIO driver. Signed-off-by: Jonathan Cameron Cc: Lee Jones --- include/linux/mfd/twl.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/mfd/twl.h b/include/linux/mfd/twl.h index 44aff52a5002..089e8942223a 100644 --- a/include/linux/mfd/twl.h +++ b/include/linux/mfd/twl.h @@ -181,14 +181,18 @@ static inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) { } static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) { - val = cpu_to_le16(val); - return twl_i2c_write(mod_no, (u8*) &val, reg, 2); + __le16 value; + + value = cpu_to_le16(val); + return twl_i2c_write(mod_no, (u8 *) &value, reg, 2); } static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) { int ret; - ret = twl_i2c_read(mod_no, (u8*) val, reg, 2); - *val = le16_to_cpu(*val); + __le16 value; + + ret = twl_i2c_read(mod_no, (u8 *) &value, reg, 2); + *val = le16_to_cpu(value); return ret; }