lantiq: Fix bug in error handling of timer driver
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 4 Jun 2023 12:05:03 +0000 (14:05 +0200)
committerMartin Schiller <ms@dev.tdt.de>
Wed, 15 May 2024 06:54:58 +0000 (08:54 +0200)
If the reverted timer driver fails to allocate interrupts handle the
error better.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
[moved printk before the cleanup for-loop]
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
target/linux/lantiq/patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch
target/linux/lantiq/patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch

index 16b87ed0a5cfc69c740c82da055ea1f34577688f..5721e017b3da08e3f3b64e0814a5a0dc61ce8bd3 100644 (file)
@@ -981,7 +981,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +int __init lq_gptu_init(void)
 +{
 +      int ret;
-+      unsigned int i;
++      int i;
 +
 +      ltq_w32(0, LQ_GPTU_IRNEN);
 +      ltq_w32(0xfff, LQ_GPTU_IRNCR);
@@ -1007,10 +1007,10 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      for (i = 0; i < timer_dev.number_of_timers; i++) {
 +              ret = request_irq(TIMER_INTERRUPT + i, timer_irq_handler, IRQF_TIMER, gptu_miscdev.name, &timer_dev.timer[i]);
 +              if (ret) {
-+                      for (; i >= 0; i--)
++                      printk(KERN_ERR "gptu: failed in requesting irq (%d), get error %d\n", i, -ret);
++                      for (i--; i >= 0; i--)
 +                              free_irq(TIMER_INTERRUPT + i, &timer_dev.timer[i]);
 +                      misc_deregister(&gptu_miscdev);
-+                      printk(KERN_ERR "gptu: failed in requesting irq (%d), get error %d\n", i, -ret);
 +                      return ret;
 +              } else {
 +                      timer_dev.timer[i].irq = TIMER_INTERRUPT + i;
index 16b87ed0a5cfc69c740c82da055ea1f34577688f..5721e017b3da08e3f3b64e0814a5a0dc61ce8bd3 100644 (file)
@@ -981,7 +981,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +int __init lq_gptu_init(void)
 +{
 +      int ret;
-+      unsigned int i;
++      int i;
 +
 +      ltq_w32(0, LQ_GPTU_IRNEN);
 +      ltq_w32(0xfff, LQ_GPTU_IRNCR);
@@ -1007,10 +1007,10 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
 +      for (i = 0; i < timer_dev.number_of_timers; i++) {
 +              ret = request_irq(TIMER_INTERRUPT + i, timer_irq_handler, IRQF_TIMER, gptu_miscdev.name, &timer_dev.timer[i]);
 +              if (ret) {
-+                      for (; i >= 0; i--)
++                      printk(KERN_ERR "gptu: failed in requesting irq (%d), get error %d\n", i, -ret);
++                      for (i--; i >= 0; i--)
 +                              free_irq(TIMER_INTERRUPT + i, &timer_dev.timer[i]);
 +                      misc_deregister(&gptu_miscdev);
-+                      printk(KERN_ERR "gptu: failed in requesting irq (%d), get error %d\n", i, -ret);
 +                      return ret;
 +              } else {
 +                      timer_dev.timer[i].irq = TIMER_INTERRUPT + i;