From patchwork Tue Nov 29 12:40:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guy Shapiro X-Patchwork-Id: 9451981 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 78D8060756 for ; Tue, 29 Nov 2016 13:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B3A528319 for ; Tue, 29 Nov 2016 13:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6038028330; Tue, 29 Nov 2016 13:05: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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 5546D2832F for ; Tue, 29 Nov 2016 13:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbcK2NFV (ORCPT ); Tue, 29 Nov 2016 08:05:21 -0500 Received: from gateway31.websitewelcome.com ([192.185.143.47]:39230 "EHLO gateway31.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756906AbcK2NFT (ORCPT ); Tue, 29 Nov 2016 08:05:19 -0500 Received: from cm6.websitewelcome.com (cm6.websitewelcome.com [108.167.139.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 6424D32069F2C for ; Tue, 29 Nov 2016 06:41:34 -0600 (CST) Received: from gator3269.hostgator.com ([198.57.247.233]) by cm6.websitewelcome.com with id DohY1u01252sfJW01ohaxl; Tue, 29 Nov 2016 06:41:34 -0600 Received: from [213.57.90.22] (port=38528 helo=coyote.mobiwize) by gator3269.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.87) (envelope-from ) id 1cBhj1-0001Fb-Va; Tue, 29 Nov 2016 06:41:32 -0600 From: Guy Shapiro To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org Cc: haibo.chen@nxp.com, fabio.estevam@nxp.com, bjorn.forsman@gmail.com, Guy Shapiro Subject: [PATCH] input: touchscreen: imx6ul_tsc: convert int to u32 Date: Tue, 29 Nov 2016 14:40:49 +0200 Message-Id: <1480423249-2933-1-git-send-email-guy.shapiro@mobi-wize.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3269.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mobi-wize.com X-BWhitelist: no X-Source-IP: 213.57.90.22 X-Exim-ID: 1cBhj1-0001Fb-Va X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (coyote.mobiwize) [213.57.90.22]:38528 X-Source-Auth: guy.shapiro@mobi-wize.com X-Email-Count: 12 X-Source-Cap: bW9iaXdpemU7bW9iaXdpemU7Z2F0b3IzMjY5Lmhvc3RnYXRvci5jb20= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The code uses of_property_read_u32 and expects positive values. However, the values are stored in signed int variables. Additionally, the registers values are also stored in signed variables without a good reason (readl/writel expect u32). The only time this caused a real bug was in the new average-samples property, in which the property is numerically compared and implicitly expected to be positive. I believe it's better to change all the properties and registers to u32, for consistency and warnings reduction. Signed-off-by: Guy Shapiro Reported-by: Bjørn Forsman --- drivers/input/touchscreen/imx6ul_tsc.c | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index 31724d9..71ea2d8 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c @@ -86,9 +86,9 @@ struct imx6ul_tsc { struct clk *adc_clk; struct gpio_desc *xnur_gpio; - int measure_delay_time; - int pre_charge_time; - int average_samples; + u32 measure_delay_time; + u32 pre_charge_time; + u32 average_samples; struct completion completion; }; @@ -99,10 +99,10 @@ struct imx6ul_tsc { */ static int imx6ul_adc_init(struct imx6ul_tsc *tsc) { - int adc_hc = 0; - int adc_gc; - int adc_gs; - int adc_cfg; + u32 adc_hc = 0; + u32 adc_gc; + u32 adc_gs; + u32 adc_cfg; int timeout; reinit_completion(&tsc->completion); @@ -155,7 +155,7 @@ static int imx6ul_adc_init(struct imx6ul_tsc *tsc) */ static void imx6ul_tsc_channel_config(struct imx6ul_tsc *tsc) { - int adc_hc0, adc_hc1, adc_hc2, adc_hc3, adc_hc4; + u32 adc_hc0, adc_hc1, adc_hc2, adc_hc3, adc_hc4; adc_hc0 = DISABLE_CONVERSION_INT; writel(adc_hc0, tsc->adc_regs + REG_ADC_HC0); @@ -180,8 +180,8 @@ static void imx6ul_tsc_channel_config(struct imx6ul_tsc *tsc) */ static void imx6ul_tsc_set(struct imx6ul_tsc *tsc) { - int basic_setting = 0; - int start; + u32 basic_setting = 0; + u32 start; basic_setting |= tsc->measure_delay_time << 8; basic_setting |= DETECT_4_WIRE_MODE | AUTO_MEASURE; @@ -216,8 +216,8 @@ static int imx6ul_tsc_init(struct imx6ul_tsc *tsc) static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) { - int tsc_flow; - int adc_cfg; + u32 tsc_flow; + u32 adc_cfg; /* TSC controller enters to idle status */ tsc_flow = readl(tsc->tsc_regs + REG_TSC_FLOW_CONTROL); @@ -234,8 +234,8 @@ static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) static bool tsc_wait_detect_mode(struct imx6ul_tsc *tsc) { unsigned long timeout = jiffies + msecs_to_jiffies(2); - int state_machine; - int debug_mode2; + u32 state_machine; + u32 debug_mode2; do { if (time_after(jiffies, timeout)) @@ -253,10 +253,10 @@ static bool tsc_wait_detect_mode(struct imx6ul_tsc *tsc) static irqreturn_t tsc_irq_fn(int irq, void *dev_id) { struct imx6ul_tsc *tsc = dev_id; - int status; - int value; + u32 status; + u32 value; int x, y; - int start; + u32 start; status = readl(tsc->tsc_regs + REG_TSC_INT_STATUS); @@ -296,8 +296,8 @@ static irqreturn_t tsc_irq_fn(int irq, void *dev_id) static irqreturn_t adc_irq_fn(int irq, void *dev_id) { struct imx6ul_tsc *tsc = dev_id; - int coco; - int value; + u32 coco; + u32 value; coco = readl(tsc->adc_regs + REG_ADC_HS); if (coco & 0x01) {