ARM: orion5x/kirkwood/mv78xx0: fix MPP configuration corner cases
PATCH 1/1 ARM: orion5x/kirkwood/mv78xx0: fix MPP configuration corner cases
Wrong MPP configuration would cause <cpu>_mpp_conf loop infinitely
because the mpp list iterator would not be incremented.
--- arch/arm/mach-kirkwood/mpp.c | 5 +++-- arch/arm/mach-mv78xx0/mpp.c | 5 +++-- arch/arm/mach-orion5x/mpp.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-)
arch/arm/mach-kirkwood/mpp.c +3 -2
@@ -67,13 +67,13 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list)if (num >MPP_MAX ) {printk (KERN_ERR "kirkwood_mpp_conf: invalid MPP " "number (%u)\n" , num); -continue ; + goto next_pin; }if (!(*mpp_list & variant_mask)) {printk (KERN_WARNING "kirkwood_mpp_conf: requested MPP%u config " "unavailable on this hardware\n" , num); -continue ; + goto next_pin; } shift = (num &7 ) <<2 ;
@@ -89,6 +89,7 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list) gpio_mode =0 ;orion_gpio_set_valid (num, gpio_mode); +next_pin: mpp_list++; }
arch/arm/mach-mv78xx0/mpp.c +3 -2
@@ -62,13 +62,13 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list)if (num >MPP_MAX ) {printk (KERN_ERR "mv78xx0_mpp_conf: invalid MPP " "number (%u)\n" , num); -continue ; + goto next_pin; }if (!(*mpp_list & variant_mask)) {printk (KERN_WARNING "mv78xx0_mpp_conf: requested MPP%u config " "unavailable on this hardware\n" , num); -continue ; + goto next_pin; } shift = (num &7 ) <<2 ;
@@ -84,6 +84,7 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list) gpio_mode =0 ;orion_gpio_set_valid (num, gpio_mode); +next_pin: mpp_list++; }
arch/arm/mach-orion5x/mpp.c +3 -2
@@ -141,7 +141,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)else {printk (KERN_ERR "orion5x_mpp_conf: invalid MPP " "(%d)\n" , mode->mpp); -continue ; + goto next_pin; } num_type =determine_type_encoding (mode->mpp, mode->type);
@@ -149,7 +149,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)printk (KERN_ERR "orion5x_mpp_conf: invalid MPP " "combination (%d, %d)\n" , mode->mpp, mode->type); -continue ; + goto next_pin; } shift = (mode->mpp &7 ) <<2 ;
@@ -161,6 +161,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)orion_gpio_set_valid (mode->mpp, !!(mode->type ==MPP_GPIO )); +next_pin: mode++; }
Signature · 1 line
1.7.3.1
PATCH 1/1 ARM: orion5x/kirkwood/mv78xx0: fix MPP configuration corner cases
ping?
Quoted 96 lines · Mike Rapoport
Wrong MPP configuration would cause <cpu>_mpp_conf loop infinitely
because the mpp list iterator would not be incremented.Signed-off-by Mike Rapoport <[email protected]>--- arch/arm/mach-kirkwood/mpp.c | 5 +++-- arch/arm/mach-mv78xx0/mpp.c | 5 +++-- arch/arm/mach-orion5x/mpp.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-)arch/arm/mach-kirkwood/mpp.c +3
-2@@ -67,13 +67,13 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list)if (num >MPP_MAX ) {printk (KERN_ERR "kirkwood_mpp_conf: invalid MPP " "number (%u)\n" , num); -continue ; + goto next_pin; }if (!(*mpp_list & variant_mask)) {printk (KERN_WARNING "kirkwood_mpp_conf: requested MPP%u config " "unavailable on this hardware\n" , num); -continue ; + goto next_pin; } shift = (num &7 ) <<2 ;@@ -89,6 +89,7 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list) gpio_mode =0 ;orion_gpio_set_valid (num, gpio_mode); +next_pin: mpp_list++; }arch/arm/mach-mv78xx0/mpp.c +3
-2@@ -62,13 +62,13 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list)if (num >MPP_MAX ) {printk (KERN_ERR "mv78xx0_mpp_conf: invalid MPP " "number (%u)\n" , num); -continue ; + goto next_pin; }if (!(*mpp_list & variant_mask)) {printk (KERN_WARNING "mv78xx0_mpp_conf: requested MPP%u config " "unavailable on this hardware\n" , num); -continue ; + goto next_pin; } shift = (num &7 ) <<2 ;@@ -84,6 +84,7 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list) gpio_mode =0 ;orion_gpio_set_valid (num, gpio_mode); +next_pin: mpp_list++; }arch/arm/mach-orion5x/mpp.c +3
-2@@ -141,7 +141,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)else {printk (KERN_ERR "orion5x_mpp_conf: invalid MPP " "(%d)\n" , mode->mpp); -continue ; + goto next_pin; } num_type =determine_type_encoding (mode->mpp, mode->type);@@ -149,7 +149,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)printk (KERN_ERR "orion5x_mpp_conf: invalid MPP " "combination (%d, %d)\n" , mode->mpp, mode->type); -continue ; + goto next_pin; } shift = (mode->mpp &7 ) <<2 ;@@ -161,6 +161,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)orion_gpio_set_valid (mode->mpp, !!(mode->type ==MPP_GPIO )); +next_pin: mode++; }
Signature · 2 lines
Sincerely yours, Mike.
PATCH 1/1 ARM: orion5x/kirkwood/mv78xx0: fix MPP configuration corner cases
In reply to Mike RapoportQuoted 9 lines · Mike Rapoport
Wrong MPP configuration would cause <cpu>_mpp_conf loop infinitely
because the mpp list iterator would not be incremented.Signed-off-by Mike Rapoport <[email protected]>--- arch/arm/mach-kirkwood/mpp.c | 5 +++-- arch/arm/mach-mv78xx0/mpp.c | 5 +++-- arch/arm/mach-orion5x/mpp.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-)
[...]
Instead of adding gotos, could you simply replace the "while (*mpp_list)" loop with "for ( ; *mpp_list; mpp_list++)" ?
Nicolas
PATCH 1/1 ARM: orion5x/kirkwood/mv78xx0: fix MPP configuration corner cases
Quoted 11 lines · Nicolas Pitre
Quoted 9 lines · Mike Rapoport
Wrong MPP configuration would cause <cpu>_mpp_conf loop infinitely
because the mpp list iterator would not be incremented.Signed-off-by Mike Rapoport <[email protected]>--- arch/arm/mach-kirkwood/mpp.c | 5 +++-- arch/arm/mach-mv78xx0/mpp.c | 5 +++-- arch/arm/mach-orion5x/mpp.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-)
Quoted 4 lines
[...]
Instead of adding gotos, could you simply replace the "while (
*mpp_list)" loop with "for ( ;*mpp_list; mpp_list++)" ?
you'd have to remove the mpp_list++, but this would be in my view a nicer solution avoiding gotos and any re-occurence of this in the future.
Signature · 1 line
Ben