diff options
author | Guy Shapiro <guy.shapiro@mobi-wize.com> | 2016-11-30 13:25:11 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2016-11-30 20:44:36 -0500 |
commit | accbcea3465b2038fa8aa66cfa8f40db7ab1c83c (patch) | |
tree | 2f97f94d26e2db4532917fddfd0e033d40a495b8 | |
parent | 70f5a294ad2eec3f896dafb83075cb8f04d65e92 (diff) |
Input: imx6ul_tsc - convert int to u32
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 <guy.shapiro@mobi-wize.com>
Reported-by: Bjørn Forsman <bjorn.forsman@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/imx6ul_tsc.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index 5babefef99a1..d2a39120f37f 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c | |||
@@ -91,9 +91,9 @@ struct imx6ul_tsc { | |||
91 | struct clk *adc_clk; | 91 | struct clk *adc_clk; |
92 | struct gpio_desc *xnur_gpio; | 92 | struct gpio_desc *xnur_gpio; |
93 | 93 | ||
94 | int measure_delay_time; | 94 | u32 measure_delay_time; |
95 | int pre_charge_time; | 95 | u32 pre_charge_time; |
96 | int average_samples; | 96 | u32 average_samples; |
97 | 97 | ||
98 | struct completion completion; | 98 | struct completion completion; |
99 | }; | 99 | }; |
@@ -104,11 +104,11 @@ struct imx6ul_tsc { | |||
104 | */ | 104 | */ |
105 | static int imx6ul_adc_init(struct imx6ul_tsc *tsc) | 105 | static int imx6ul_adc_init(struct imx6ul_tsc *tsc) |
106 | { | 106 | { |
107 | int adc_hc = 0; | 107 | u32 adc_hc = 0; |
108 | int adc_gc; | 108 | u32 adc_gc; |
109 | int adc_gs; | 109 | u32 adc_gs; |
110 | int adc_cfg; | 110 | u32 adc_cfg; |
111 | int timeout; | 111 | unsigned long timeout; |
112 | 112 | ||
113 | reinit_completion(&tsc->completion); | 113 | reinit_completion(&tsc->completion); |
114 | 114 | ||
@@ -164,7 +164,7 @@ static int imx6ul_adc_init(struct imx6ul_tsc *tsc) | |||
164 | */ | 164 | */ |
165 | static void imx6ul_tsc_channel_config(struct imx6ul_tsc *tsc) | 165 | static void imx6ul_tsc_channel_config(struct imx6ul_tsc *tsc) |
166 | { | 166 | { |
167 | int adc_hc0, adc_hc1, adc_hc2, adc_hc3, adc_hc4; | 167 | u32 adc_hc0, adc_hc1, adc_hc2, adc_hc3, adc_hc4; |
168 | 168 | ||
169 | adc_hc0 = DISABLE_CONVERSION_INT; | 169 | adc_hc0 = DISABLE_CONVERSION_INT; |
170 | writel(adc_hc0, tsc->adc_regs + REG_ADC_HC0); | 170 | writel(adc_hc0, tsc->adc_regs + REG_ADC_HC0); |
@@ -189,8 +189,8 @@ static void imx6ul_tsc_channel_config(struct imx6ul_tsc *tsc) | |||
189 | */ | 189 | */ |
190 | static void imx6ul_tsc_set(struct imx6ul_tsc *tsc) | 190 | static void imx6ul_tsc_set(struct imx6ul_tsc *tsc) |
191 | { | 191 | { |
192 | int basic_setting = 0; | 192 | u32 basic_setting = 0; |
193 | int start; | 193 | u32 start; |
194 | 194 | ||
195 | basic_setting |= tsc->measure_delay_time << 8; | 195 | basic_setting |= tsc->measure_delay_time << 8; |
196 | basic_setting |= DETECT_4_WIRE_MODE | AUTO_MEASURE; | 196 | basic_setting |= DETECT_4_WIRE_MODE | AUTO_MEASURE; |
@@ -225,8 +225,8 @@ static int imx6ul_tsc_init(struct imx6ul_tsc *tsc) | |||
225 | 225 | ||
226 | static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) | 226 | static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) |
227 | { | 227 | { |
228 | int tsc_flow; | 228 | u32 tsc_flow; |
229 | int adc_cfg; | 229 | u32 adc_cfg; |
230 | 230 | ||
231 | /* TSC controller enters to idle status */ | 231 | /* TSC controller enters to idle status */ |
232 | tsc_flow = readl(tsc->tsc_regs + REG_TSC_FLOW_CONTROL); | 232 | tsc_flow = readl(tsc->tsc_regs + REG_TSC_FLOW_CONTROL); |
@@ -243,8 +243,8 @@ static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) | |||
243 | static bool tsc_wait_detect_mode(struct imx6ul_tsc *tsc) | 243 | static bool tsc_wait_detect_mode(struct imx6ul_tsc *tsc) |
244 | { | 244 | { |
245 | unsigned long timeout = jiffies + msecs_to_jiffies(2); | 245 | unsigned long timeout = jiffies + msecs_to_jiffies(2); |
246 | int state_machine; | 246 | u32 state_machine; |
247 | int debug_mode2; | 247 | u32 debug_mode2; |
248 | 248 | ||
249 | do { | 249 | do { |
250 | if (time_after(jiffies, timeout)) | 250 | if (time_after(jiffies, timeout)) |
@@ -262,10 +262,10 @@ static bool tsc_wait_detect_mode(struct imx6ul_tsc *tsc) | |||
262 | static irqreturn_t tsc_irq_fn(int irq, void *dev_id) | 262 | static irqreturn_t tsc_irq_fn(int irq, void *dev_id) |
263 | { | 263 | { |
264 | struct imx6ul_tsc *tsc = dev_id; | 264 | struct imx6ul_tsc *tsc = dev_id; |
265 | int status; | 265 | u32 status; |
266 | int value; | 266 | u32 value; |
267 | int x, y; | 267 | u32 x, y; |
268 | int start; | 268 | u32 start; |
269 | 269 | ||
270 | status = readl(tsc->tsc_regs + REG_TSC_INT_STATUS); | 270 | status = readl(tsc->tsc_regs + REG_TSC_INT_STATUS); |
271 | 271 | ||
@@ -305,8 +305,8 @@ static irqreturn_t tsc_irq_fn(int irq, void *dev_id) | |||
305 | static irqreturn_t adc_irq_fn(int irq, void *dev_id) | 305 | static irqreturn_t adc_irq_fn(int irq, void *dev_id) |
306 | { | 306 | { |
307 | struct imx6ul_tsc *tsc = dev_id; | 307 | struct imx6ul_tsc *tsc = dev_id; |
308 | int coco; | 308 | u32 coco; |
309 | int value; | 309 | u32 value; |
310 | 310 | ||
311 | coco = readl(tsc->adc_regs + REG_ADC_HS); | 311 | coco = readl(tsc->adc_regs + REG_ADC_HS); |
312 | if (coco & 0x01) { | 312 | if (coco & 0x01) { |