From patchwork Thu Aug 23 21:24:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10574581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D954A1390 for ; Thu, 23 Aug 2018 21:24:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD712C84B for ; Thu, 23 Aug 2018 21:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFCC02C8A0; Thu, 23 Aug 2018 21:24:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 629672C84B for ; Thu, 23 Aug 2018 21:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727580AbeHXA4O (ORCPT ); Thu, 23 Aug 2018 20:56:14 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:53166 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727584AbeHXA4N (ORCPT ); Thu, 23 Aug 2018 20:56:13 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by albert.telenet-ops.be with bizsmtp id SlQd1y0013XaVaC06lQdPb; Thu, 23 Aug 2018 23:24:37 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1fsx5p-0005i0-0E; Thu, 23 Aug 2018 23:24:37 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1fsx5o-0004Xu-Um; Thu, 23 Aug 2018 23:24:36 +0200 From: Geert Uytterhoeven To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Mathieu Othacehe Cc: Arnd Bergmann , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] iio: light: isl29501: Simplify code to kill compiler warning Date: Thu, 23 Aug 2018 23:24:35 +0200 Message-Id: <20180823212436.17423-1-geert@linux-m68k.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With gcc 4.1.2: drivers/iio/proximity/isl29501.c: In function ‘isl29501_register_write’: drivers/iio/proximity/isl29501.c:235: warning: ‘msb’ may be used uninitialized in this function While this is a false positive, it can easily be avoided by removing the "msb" intermediate variable. Remove the "lsb" intermediate variable for consistency. Signed-off-by: Geert Uytterhoeven --- Compile-tested only. --- drivers/iio/proximity/isl29501.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c index e5e94540f404dd2c..5ae549075b27c50d 100644 --- a/drivers/iio/proximity/isl29501.c +++ b/drivers/iio/proximity/isl29501.c @@ -232,7 +232,6 @@ static u32 isl29501_register_write(struct isl29501_private *isl29501, u32 value) { const struct isl29501_register_desc *reg = &isl29501_registers[name]; - u8 msb, lsb; int ret; if (!reg->msb && value > U8_MAX) @@ -241,22 +240,15 @@ static u32 isl29501_register_write(struct isl29501_private *isl29501, if (value > U16_MAX) return -ERANGE; - if (!reg->msb) { - lsb = value & 0xFF; - } else { - msb = (value >> 8) & 0xFF; - lsb = value & 0xFF; - } - mutex_lock(&isl29501->lock); if (reg->msb) { ret = i2c_smbus_write_byte_data(isl29501->client, - reg->msb, msb); + reg->msb, value >> 8); if (ret < 0) goto err; } - ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, lsb); + ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, value); err: mutex_unlock(&isl29501->lock);