Skip to contentSkip to conversation

Input: ep93xx_keypad - Fix handling of platform_get_irq() error

PATCH Superseded Krzysztof Kozlowski 2 participants 5 messages Aug 27, 2020 – Aug 28, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Input: ep93xx_keypad - Fix handling of platform_get_irq() error

platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.

Fixes 60214f058f44 ("Input: ep93xx_keypad - update driver to new core support")
---
 drivers/input/keyboard/ep93xx_keypad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/ep93xx_keypad.c +2 -2
index 7c70492d9d6b..f831f01501d5 100644
@@ -250,8 +250,8 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
 	}
 
 	keypad->irq = platform_get_irq(pdev, 0);
-	if (!keypad->irq) {
-		err = -ENXIO;
+	if (keypad->irq < 0) {
+		err = keypad->irq;
 		goto failed_free;
 	}
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/4 Input: omap4-keypad - Fix handling of platform_get_irq() error

platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.

Fixes f3a1ba60dbdb ("Input: omap4-keypad - use platform device helpers")
---
 drivers/input/keyboard/omap4-keypad.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/omap4-keypad.c +2 -4
index 94c94d7f5155..b075f1af0305 100644
@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 	}
 
 	irq = platform_get_irq(pdev, 0);
-	if (!irq) {
-		dev_err(&pdev->dev, "no keyboard irq assigned\n");
-		return -EINVAL;
-	}
+	if (irq < 0)
+		return -irq;
 
 	keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL);
 	if (!keypad_data) {
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/4 Input: sun4i-ps2 - Fix handling of platform_get_irq() error

In reply to Krzysztof Kozlowski

platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.

Fixes e443631d20f5 ("Input: serio - add support for Alwinner A10/A20 PS/2 controller")
---
 drivers/input/serio/sun4i-ps2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/input/serio/sun4i-ps2.c +2 -3
index a681a2c04e39..7da1ea8741fc 100644
@@ -265,9 +265,8 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
 
 	/* Get IRQ for the device */
 	irq = platform_get_irq(pdev, 0);
-	if (!irq) {
-		dev_err(dev, "no IRQ found\n");
-		error = -ENXIO;
+	if (irq < 0) {
+		error = irq;
 		goto err_disable_clk;
 	}
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/4 Input: twl4030_keypad - Fix handling of platform_get_irq() error

In reply to Krzysztof Kozlowski

platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.

Fixes 7abf38d6d13c ("Input: twl4030-keypad - add device tree support")
---
 drivers/input/keyboard/twl4030_keypad.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/twl4030_keypad.c +2 -4
index af3a6824f1a4..c971a06c2c6a 100644
@@ -376,10 +376,8 @@ static int twl4030_kp_probe(struct platform_device *pdev)
 	}
 
 	kp->irq = platform_get_irq(pdev, 0);
-	if (!kp->irq) {
-		dev_err(&pdev->dev, "no keyboard irq assigned\n");
-		return -EINVAL;
-	}
+	if (kp->irq < 0)
+		return kp->irq;
 
 	error = matrix_keypad_build_keymap(keymap_data, NULL,
 					   TWL4030_MAX_ROWS,
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH 3/4] Input: twl4030_keypad - Fix handling of platform_get_irq() error

I love your patch! Perhaps something to improve:

Hi Krzysztof,

I love your patch! Perhaps something to improve:

[auto build test WARNING on input/next]
[also build test WARNING on sunxi/sunxi/for-next linus/master v5.9-rc2 next-20200827] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Krzysztof-Kozlowski/Input-ep93xx_keypad-Fix-handling-of-platform_get_irq-error/20200827-152706
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: i386-randconfig-m021-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
drivers/input/keyboard/twl4030_keypad.c:379 twl4030_kp_probe() warn: unsigned 'kp->irq' is never less than zero.

# https://github.com/0day-ci/linux/commit/d83af6799bafdf8f1f84ddfc48876f621735963b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Krzysztof-Kozlowski/Input-ep93xx_keypad-Fix-handling-of-platform_get_irq-error/20200827-152706 git checkout d83af6799bafdf8f1f84ddfc48876f621735963b
vim +379 drivers/input/keyboard/twl4030_keypad.c

318
319 /*
320 * Registers keypad device with input subsystem
321 * and configures TWL4030 keypad registers
322 */
323 static int twl4030_kp_probe(struct platform_device *pdev)
324 {
325 struct twl4030_keypad_data *pdata = dev_get_platdata(&pdev->dev);
326 const struct matrix_keymap_data *keymap_data = NULL;
327 struct twl4030_keypad *kp;
328 struct input_dev *input;
329 u8 reg;
330 int error;
331
332 kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
333 if (!kp)
334 return -ENOMEM;
335
336 input = devm_input_allocate_device(&pdev->dev);
337 if (!input)
338 return -ENOMEM;
339
340 /* get the debug device */
341 kp->dbg_dev = &pdev->dev;
342 kp->input = input;
343
344 /* setup input device */
345 input->name = "TWL4030 Keypad";
346 input->phys = "twl4030_keypad/input0";
347
348 input->id.bustype = BUS_HOST;
349 input->id.vendor = 0x0001;
350 input->id.product = 0x0001;
351 input->id.version = 0x0003;
352
353 if (pdata) {
354 if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
355 dev_err(&pdev->dev, "Missing platform_data\n");
356 return -EINVAL;
357 }
358
359 kp->n_rows = pdata->rows;
360 kp->n_cols = pdata->cols;
361 kp->autorepeat = pdata->rep;
362 keymap_data = pdata->keymap_data;
363 } else {
364 error = matrix_keypad_parse_properties(&pdev->dev, &kp->n_rows,
365 &kp->n_cols);
366 if (error)
367 return error;
368
369 kp->autorepeat = true;
370 }
371
372 if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) {
373 dev_err(&pdev->dev,
374 "Invalid rows/cols amount specified in platform/devicetree data\n");
375 return -EINVAL;
376 }
377
378 kp->irq = platform_get_irq(pdev, 0);

 > 379		if (kp->irq < 0)
   380			return kp->irq;
   381	
   382		error = matrix_keypad_build_keymap(keymap_data, NULL,
   383						   TWL4030_MAX_ROWS,
   384						   1 << TWL4030_ROW_SHIFT,
   385						   kp->keymap, input);

386 if (error) {
387 dev_err(kp->dbg_dev, "Failed to build keymap\n");
388 return error;
389 }
390
391 input_set_capability(input, EV_MSC, MSC_SCAN);
392 /* Enable auto repeat feature of Linux input subsystem */
393 if (kp->autorepeat)
394 __set_bit(EV_REP, input->evbit);
395
396 error = input_register_device(input);
397 if (error) {
398 dev_err(kp->dbg_dev,
399 "Unable to register twl4030 keypad device\n");
400 return error;
401 }
402
403 error = twl4030_kp_program(kp);
404 if (error)
405 return error;
406
407 /*
408 * This ISR will always execute in kernel thread context because of
409 * the need to access the TWL4030 over the I2C bus.
410 *
411 * NOTE: we assume this host is wired to TWL4040 INT1, not INT2 ...
412 */
413 error = devm_request_threaded_irq(&pdev->dev, kp->irq, NULL, do_kp_irq,
414 0, pdev->name, kp);
415 if (error) {
416 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d: %d\n",
417 kp->irq, error);
418 return error;
419 }
420
421 /* Enable KP and TO interrupts now. */
422 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);
423 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {
424 /* mask all events - we don't care about the result */
425 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);
426 return -EIO;
427 }
428
429 return 0;
430 }
431

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org