From patchwork Mon Jan 22 08:00:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yeh, Andy" X-Patchwork-Id: 10177457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0A83600F5 for ; Mon, 22 Jan 2018 08:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2C6B27CAF for ; Mon, 22 Jan 2018 08:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2F9027D4A; Mon, 22 Jan 2018 08:06:18 +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=-6.9 required=2.0 tests=BAYES_00,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 7A35627CAF for ; Mon, 22 Jan 2018 08:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751004AbeAVIGQ (ORCPT ); Mon, 22 Jan 2018 03:06:16 -0500 Received: from mga01.intel.com ([192.55.52.88]:9675 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbeAVIGQ (ORCPT ); Mon, 22 Jan 2018 03:06:16 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:06:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="diff'?scan'208";a="13064039" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by fmsmga002.fm.intel.com with ESMTP; 22 Jan 2018 00:06:14 -0800 Received: from pgsmsx111.gar.corp.intel.com ([169.254.2.98]) by PGSMSX107.gar.corp.intel.com ([169.254.7.200]) with mapi id 14.03.0319.002; Mon, 22 Jan 2018 16:00:24 +0800 From: "Yeh, Andy" To: Sakari Ailus , "linux-media@vger.kernel.org" Subject: RE: [PATCH 1/1] imx258: Fix sparse warnings Thread-Topic: [PATCH 1/1] imx258: Fix sparse warnings Thread-Index: AQHTkQdBfSA7ZYYRr0GJDcMTFyVviKN/heUQ Date: Mon, 22 Jan 2018 08:00:23 +0000 Deferred-Delivery: Mon, 22 Jan 2018 07:59:46 +0000 Message-ID: <8E0971CCB6EA9D41AF58191A2D3978B61D4E66C1@PGSMSX111.gar.corp.intel.com> References: <20180119092327.26731-1-sakari.ailus@linux.intel.com> In-Reply-To: <20180119092327.26731-1-sakari.ailus@linux.intel.com> Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmQ5YzMwMjUtNDI0NS00ODAxLTg2ZDgtYTQ1MjkzOTAwMjk4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJPeVFaU2c1ODRMTXpvMVdPU1RhSXp1UWhYTUlPV3VjNjIyTGNLaWhWaHdZQlVSZjJvRmM5QVhONkxwdWxOak9lIn0= x-ctpclassification: CTP_NT x-originating-ip: [172.30.20.205] MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Sakari, I verified the patch multiple times but the code cannot work. Regards, Andy -----Original Message----- From: Sakari Ailus [mailto:sakari.ailus@linux.intel.com] Sent: Friday, January 19, 2018 5:23 PM To: linux-media@vger.kernel.org Cc: Yeh, Andy Subject: [PATCH 1/1] imx258: Fix sparse warnings Fix a few sparse warnings related to conversion between CPU and big endian. Also simplify the code in the process. Signed-off-by: Sakari Ailus --- Hi Andy, There were a few issues Sparse found in the imx258 driver. Could you test the patch, please? drivers/media/i2c/imx258.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); - int buf_i, val_i; - u8 buf[6], *val_p; + u8 __buf[6], *buf = __buf; + int i; if (len > 4) return -EINVAL; - buf[0] = reg >> 8; - buf[1] = reg & 0xff; + *buf++ = reg >> 8; + *buf++ = reg & 0xff; - val = cpu_to_be32(val); - val_p = (u8 *)&val; - buf_i = 2; - val_i = 4 - len; - - while (val_i < 4) - buf[buf_i++] = val_p[val_i++]; + for (i = len - 1; i >= 0; i++) + *buf++ = (u8)(val >> (i << 3)); if (i2c_master_send(client, buf, len + 2) != len + 2) return -EIO; -- 2.11.0 diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index a7e58bd23de7..b73c25ae8725 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -440,10 +440,10 @@ static int imx258_read_reg(struct imx258 *imx258, u16 reg, u32 len, u32 *val) { struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); struct i2c_msg msgs[2]; + __be16 reg_addr_be = cpu_to_be16(reg); + __be32 data_be = 0; u8 *data_be_p; int ret; - u32 data_be = 0; - u16 reg_addr_be = cpu_to_be16(reg); if (len > 4) return -EINVAL; @@ -474,22 +474,17 @@ static int imx258_read_reg(struct imx258 *imx258, u16 reg, u32 len, u32 *val) static int imx258_write_reg(struct imx258 *imx258, u16 reg, u32 len, u32 val) {