Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp831722pxb; Thu, 31 Mar 2022 19:44:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjg2u8UgcpOEeH2QwBVoUpTkl3Tyo81+oOUTEnkXOLLWrH06aB3+ympuXVJUfBu4zxirL4 X-Received: by 2002:a17:902:c215:b0:14f:f1c2:9fe3 with SMTP id 21-20020a170902c21500b0014ff1c29fe3mr8330409pll.145.1648781085831; Thu, 31 Mar 2022 19:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648781085; cv=none; d=google.com; s=arc-20160816; b=RT+9rVq06H36pD4ERw1Rp0eUkiAy+p0n+Ye149FP5nRR3IeGtGpkH6iDUO6aesSUod ORtJzijMegNUUgW7gPEMU6YuWtvYXhATQCsXaDHJnF/k6Y4tjPAniyalp+844kigf/af dRRc80KSWBpRjpiiH4FUYa3yvYgaPvw+cyCb3w1BxS6AoMRK+ijiJsYTPP6nDso5xAMe 7FcjbY9aFCU8EUGjQGRz9dSESFnPmhTF52Hg9Z2zOImhbU+hhS7XQkuO7gcW8XHkxj4w 4i7fbNEaPOx+0AiNZvnshot+mG5gFXYp1jikz5FdfJ1ef1jL2FQsIijzYshzES1f8PFW BPBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7SP21vb4U1rgi2I4Q8AKkwyUmZpAKc0TGJVD/RSbaHI=; b=rzc29RuSwb+z1yguhQxSs8GroZKUIwT0DdqW2h07EvwTEZ19X9xRqxWK2kAut7lILb u2DjhH20kr29wg13jTgdH0Ci0RsluUKFL3XtHyj2kKPvxP2wh7s0EMSRUyChcgyOGJy/ TMgt0YUh4M9hu7SB3SRplotGa4x3UwptQ4gxYBx57vjDvRKRiChq1VeaRtRaQuj80k6I 15aN7NSXtj3Dp0+ja089ZwsWtXVqd4dCMS4qU6OeWZRDPkqmhKpgf27Mm0JTRVy560p7 ei05/qbeZ3TzO3h3GD2p53N2TR73IcddWKhb80fBy5/dC3pYNqJHgvapUdqwTpWZigWQ HoAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BDrMiG+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a170903024e00b00153b2d16507si1067736plh.271.2022.03.31.19.44.31; Thu, 31 Mar 2022 19:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BDrMiG+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241960AbiCaVvc (ORCPT + 99 others); Thu, 31 Mar 2022 17:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233935AbiCaVvb (ORCPT ); Thu, 31 Mar 2022 17:51:31 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74471554A6 for ; Thu, 31 Mar 2022 14:49:43 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id y10so825542edv.7 for ; Thu, 31 Mar 2022 14:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7SP21vb4U1rgi2I4Q8AKkwyUmZpAKc0TGJVD/RSbaHI=; b=BDrMiG+XdSewJSHn6PkoOIbnz7uJb91+cpAZ/uEKfi7Sxj3G7NjqZnIklCa7yXE5lV Y9B6+aYw90o+blb++BPt9hBaAKyJcSm8sK2Oc0gT7NOCPBZsgocAP5oIUiEYDn+RPOaS n23mAnadGM+75XHonxATA2Z5W9xOiYh4taXnsTbFskEuEnYEOFW+RhRNBWF+NabAIb1c 3HmU+eF3JQ5K5HH8MxY32AysIXTJZ80flZTY0KWc599tjuq6j7uBQJeyBgL+yNEGc0lI e4oT5bz2S5NqRN7i6UmKFeYXOPT+/HVdIlJtgE8oXsMFrHHfkYbkUYtHpSrPI39kFA76 7gTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7SP21vb4U1rgi2I4Q8AKkwyUmZpAKc0TGJVD/RSbaHI=; b=yu9+0pik5E47H2+z5jLAPAdNk7N+QAw3V7x1TkZEKo0XWJ2unzkG+JfX6KDbspkXBH RIkQuzuq5Jy3cSitKA3mWLG3k2R/VF066bjf5jINtUlj5BvtlumHlc7p2V/r5prsXXd1 qIEtxIb08anmJ5EQfEYbKQ+7RPaCwXVWyHOHoo+Z18i9kPSPHpDmwWccTx2Xt78UfK9l 5JHGrxKu/mW7Cdwyqe46bv7I2NwtWsqEtBmEmwMjxFrl7HWPQY/d9RTFenL70iYcA3oR +bz483n5ANSDugcCE7AjrL+Wp4OgY5FrVvLU9kVVn930NSdXMdegITkIQYBLzmXMyKe0 Evmw== X-Gm-Message-State: AOAM5327NDv3DBdf1BKY5husj4RFIrSyMiAmVkJ6tcKoriox8FzkyLmJ cy8a2OkTFjyobBtvxgyRrRY= X-Received: by 2002:a05:6402:f1c:b0:41b:54d2:ef1b with SMTP id i28-20020a0564020f1c00b0041b54d2ef1bmr15939221eda.185.1648763382014; Thu, 31 Mar 2022 14:49:42 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id b8-20020a056402350800b00419407f0dd9sm311698edd.0.2022.03.31.14.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:49:41 -0700 (PDT) From: Jakob Koschel To: Lubomir Rintel Cc: Russell King , "Russell King (Oracle)" , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Mike Rapoport , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH 1/3] ARM: ioremap: remove usage of list iterator for list_add() after the loop body Date: Thu, 31 Mar 2022 23:47:17 +0200 Message-Id: <20220331214719.881886-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Before, the code implicitly used the head when no element was found when using &pos->list. Since the new variable is only set if an element was found, the list_add() is performed within the loop and only done after the loop if it is done on the list head directly. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- arch/arm/mm/ioremap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index aa08bcb72db9..417fd5ffa162 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -90,7 +90,7 @@ struct static_vm *find_static_vm_vaddr(void *vaddr) void __init add_static_vm_early(struct static_vm *svm) { - struct static_vm *curr_svm; + struct static_vm *curr_svm = NULL, *iter; struct vm_struct *vm; void *vaddr; @@ -98,13 +98,17 @@ void __init add_static_vm_early(struct static_vm *svm) vm_area_add_early(vm); vaddr = vm->addr; - list_for_each_entry(curr_svm, &static_vmlist, list) { - vm = &curr_svm->vm; + list_for_each_entry(iter, &static_vmlist, list) { + vm = &iter->vm; - if (vm->addr > vaddr) + if (vm->addr > vaddr) { + curr_svm = iter; + list_add_tail(&svm->list, &iter->list); break; + } } - list_add_tail(&svm->list, &curr_svm->list); + if (!curr_svm) + list_add_tail(&svm->list, &static_vmlist); } int ioremap_page(unsigned long virt, unsigned long phys, base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275 -- 2.25.1