diff mbox series

x86/rtc: Simplify PNP ids check

Message ID 20221214212447.4058-1-hdegoede@redhat.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series x86/rtc: Simplify PNP ids check | expand

Commit Message

Hans de Goede Dec. 14, 2022, 9:24 p.m. UTC
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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/x86/kernel/rtc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Rafael J. Wysocki Dec. 21, 2022, 1:55 p.m. UTC | #1
On Wed, Dec 14, 2022 at 10:25 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/x86/kernel/rtc.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
> index 349046434513..1309b9b05338 100644
> --- a/arch/x86/kernel/rtc.c
> +++ b/arch/x86/kernel/rtc.c
> @@ -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
>
diff mbox series

Patch

diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 349046434513..1309b9b05338 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -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