[openwrt/openwrt] lantiq: Fix bug in error handling of timer driver

LEDE Commits lede-commits at lists.infradead.org
Wed May 15 01:21:08 PDT 2024


nick pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/e79dacd962f9ef3b443eda376eba42512ac6e529

commit e79dacd962f9ef3b443eda376eba42512ac6e529
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Sun Jun 4 14:05:03 2023 +0200

    lantiq: Fix bug in error handling of timer driver
    
    If the reverted timer driver fails to allocate interrupts handle the
    error better.
    
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
    [moved printk before the cleanup for-loop]
    Signed-off-by: Martin Schiller <ms at dev.tdt.de>
---
 .../patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch     | 6 +++---
 .../patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch      | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/linux/lantiq/patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch b/target/linux/lantiq/patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch
index 16b87ed0a5..5721e017b3 100644
--- a/target/linux/lantiq/patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch
+++ b/target/linux/lantiq/patches-5.15/0008-MIPS-lantiq-backport-old-timer-code.patch
@@ -981,7 +981,7 @@ Signed-off-by: John Crispin <blogic at 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 at 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;
diff --git a/target/linux/lantiq/patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch b/target/linux/lantiq/patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch
index 16b87ed0a5..5721e017b3 100644
--- a/target/linux/lantiq/patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch
+++ b/target/linux/lantiq/patches-6.1/0008-MIPS-lantiq-backport-old-timer-code.patch
@@ -981,7 +981,7 @@ Signed-off-by: John Crispin <blogic at 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 at 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;




More information about the lede-commits mailing list