Skip to contentSkip to conversation

x86/rtc: Simplify PNP ids check

PATCH In review Hans de Goede 2 participants 2 messages Dec 14, 2022 – Dec 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/rtc: Simplify PNP ids check

compare_pnp_id() already iterates over the single linked pnp_ids list starting with the id past to it.

So there is no need for add_rtc_cmos() to call compare_pnp_id() for each id on the list.

---
 arch/x86/kernel/rtc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/rtc.c +3 -6
index 349046434513..1309b9b05338 100644
@@ -138,15 +138,12 @@ static __init int add_rtc_cmos(void)
 	static const char * const ids[] __initconst =
 	    { "PNP0b00", "PNP0b01", "PNP0b02", };
 	struct pnp_dev *dev;
-	struct pnp_id *id;
 	int i;
 
 	pnp_for_each_dev(dev) {
-		for (id = dev->id; id; id = id->next) {
-			for (i = 0; i < ARRAY_SIZE(ids); i++) {
-				if (compare_pnp_id(id, ids[i]) != 0)
-					return 0;
-			}
+		for (i = 0; i < ARRAY_SIZE(ids); i++) {
+			if (compare_pnp_id(dev->id, ids[i]) != 0)
+				return 0;
 		}
 	}
 #endif
Signature · 1 line
2.38.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Hans de Goede

compare_pnp_id() already iterates over the single linked pnp_ids list starting with the id past to it.

So there is no need for add_rtc_cmos() to call compare_pnp_id() for each id on the list.

Quoted 30 lines
---
 arch/x86/kernel/rtc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/rtc.c +3 -7
index 349046434513..1309b9b05338 100644
@@ -138,15 +138,12 @@ static __init int add_rtc_cmos(void)
        static const char * const ids[] __initconst =
            { "PNP0b00", "PNP0b01", "PNP0b02", };
        struct pnp_dev *dev;
-       struct pnp_id *id;
        int i;
 
        pnp_for_each_dev(dev) {
-               for (id = dev->id; id; id = id->next) {
-                       for (i = 0; i < ARRAY_SIZE(ids); i++) {
-                               if (compare_pnp_id(id, ids[i]) != 0)
-                                       return 0;
-                       }
+               for (i = 0; i < ARRAY_SIZE(ids); i++) {
+                       if (compare_pnp_id(dev->id, ids[i]) != 0)
+                               return 0;
                }
        }
 #endif
--

2.38.1