Message ID | 20200827072420.22848-3-krzk@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/4] Input: ep93xx_keypad - Fix handling of platform_get_irq() error | expand |
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
Reported-by: kernel test robot <lkp@intel.com>
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@lists.01.org
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c index af3a6824f1a4..c971a06c2c6a 100644 --- a/drivers/input/keyboard/twl4030_keypad.c +++ b/drivers/input/keyboard/twl4030_keypad.c @@ -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,
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") Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> --- drivers/input/keyboard/twl4030_keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)