From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0096.outbound.protection.outlook.com ([104.47.36.96]:62018 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387918AbeITIbO (ORCPT ); Thu, 20 Sep 2018 04:31:14 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Dan Carpenter , Guenter Roeck , Sasha Levin Subject: [PATCH AUTOSEL 4.4 6/7] hwmon: (adt7475) Make adt7475_read_word() return errors Date: Thu, 20 Sep 2018 02:49:39 +0000 Message-ID: <20180920024932.58727-6-alexander.levin@microsoft.com> References: <20180920024932.58727-1-alexander.levin@microsoft.com> In-Reply-To: <20180920024932.58727-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Dan Carpenter [ Upstream commit f196dec6d50abb2e65fb54a0621b2f1b4d922995 ] The adt7475_read_word() function was meant to return negative error codes on failure. Signed-off-by: Dan Carpenter Reviewed-by: Tokunori Ikegami Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/adt7475.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 3cefd1aeb24f..9c262d955331 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -274,14 +274,18 @@ static inline u16 volt2reg(int channel, long volt, u8= bypass_attn) return clamp_val(reg, 0, 1023) & (0xff << 2); } =20 -static u16 adt7475_read_word(struct i2c_client *client, int reg) +static int adt7475_read_word(struct i2c_client *client, int reg) { - u16 val; + int val1, val2; =20 - val =3D i2c_smbus_read_byte_data(client, reg); - val |=3D (i2c_smbus_read_byte_data(client, reg + 1) << 8); + val1 =3D i2c_smbus_read_byte_data(client, reg); + if (val1 < 0) + return val1; + val2 =3D i2c_smbus_read_byte_data(client, reg + 1); + if (val2 < 0) + return val2; =20 - return val; + return val1 | (val2 << 8); } =20 static void adt7475_write_word(struct i2c_client *client, int reg, u16 val= ) --=20 2.17.1