From patchwork Thu Jul 7 16:36:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 588122 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp739989mab; Thu, 7 Jul 2022 09:36:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uUganNKNYtmW5W5zHO11/oYGUFM7+QGuu0V6Ew5ZP4YQxu4o7gd+/P4nGRitafWAAA249l X-Received: by 2002:a05:6a00:2445:b0:528:5a5b:67d3 with SMTP id d5-20020a056a00244500b005285a5b67d3mr27678393pfj.32.1657211815895; Thu, 07 Jul 2022 09:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657211815; cv=none; d=google.com; s=arc-20160816; b=DP+cTZwaKsRP00Junah4owEUkLEJ2Cp5Q52oSf7sOLNqlffBnAMo3MRpnmWHHoGYmE LIrtAdPc85kyRLEMPWlWm1RFESBgPKJtooCkTA5i78jvsrTIJ+8bxLrGoVQXybKDLMcj 0Di3YkQBiAENKfXFkVBkTfCfnOQRjgdOtT8MajEqTsIm7wRGtENMYDAcDM4n4vCxBEtn NBsOkhRHidfMQn6JBeJpsO48KSKkwCwoUiQUre62ysnhFpQPhQR1krw5bGp4bJO2va51 SYHV4fLjqiY+WCi0HPg8/XLx7QOZhREa3XvqKQ//rSeE1nq8LEXwG5DX6/dZfpY5vGGz NRBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=vEczAtxJawPbvNEeARMT5rPZDxcpWGoNBzv16PBlrMY=; b=HfxBoNBxj1vbm3cchdGoQmWwSWkzFb5S7/5X6ruaA+xvpb4ZgisERZNNEfuZMrdmdu TPNfnF4KAqJnA9kc54A+fsZv8HzaTy37we8uH0GHA/1/i6Z3iB5eFGU3w1t3CFDN2dgD IurWBmGiqYgAd/bdqrx5/UbT259QfRWZTHA/CxVkugwrT9YNOFts9W7KSxyDPaFAd8MA Qe1nRi6susQWJGXjg5Xb/7fRQsPZIXsXpUA35yczE/Y2ARsg255dLQCKnYCgH/F3TB7e lwtQoZSyW13vsP7lLBTmPLDKDzT88RoYiFpf0SGhaowPwijGYK2Fe36gRtCD9HzQNGxw 9jkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=g8dSS1RU; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=WtTIbV5N; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:3::133]) by mx.google.com with ESMTPS id w7-20020a636207000000b00412ac9d3590si5748624pgb.413.2022.07.07.09.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:36:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) client-ip=2607:7c80:54:3::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=g8dSS1RU; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=WtTIbV5N; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vEczAtxJawPbvNEeARMT5rPZDxcpWGoNBzv16PBlrMY=; b=g8dSS1RUM914gR sPa20EYJCyUslZX1wl9vN4ZO2Aw8Gp7FgmsJMTwHCOueSW+GbXDiPOzhabdmRW1X+k7lq9QxKd2KB WTyJDQd8asaH5a2ci+fj6gQyaKv4TF/6CKWsO/XU8neWSk+i24a9Vt/FeOPefcBDWZjvuZC7g0Jyq UNUgmG7yPo8fSnctoaZ/wx6HPkWg9Hs/GQhp/t0Q+n7EII7WxG3Vs90axjybDETj97UXAL6HzHWo3 +N/PYFlPOw0PXXp+2e8PZXELGaCyz2Tfr1V6KNVKW69Xy7nyaF+60NUpWY8gcUub6IvvHn59m+y2P zqGXHa4lDz+9637NvHCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9UUJ-00H0EW-Al; Thu, 07 Jul 2022 16:36:23 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9UUG-00H0CE-SJ for linux-mtd@lists.infradead.org; Thu, 07 Jul 2022 16:36:22 +0000 Received: by mail-ed1-x52c.google.com with SMTP id g1so16213637edb.12 for ; Thu, 07 Jul 2022 09:36:18 -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=gLHJBhKHjVuVR3mcBnbsIiyt4ymeaQeICW0gIztUwNk=; b=WtTIbV5NJdT9zJWs+mhSLRYyDgDLVvro/qoXQvONrI99p4YJdq9CJvunBXxk/s4flX 2fSST51RQKynfZABj3JPYqMiqNhpxOrjfGEOsZopM40wCsc+a9IJGONgwTmCPuxj8F2N 901RsE3W/IVPtf53qV+qeTwdwRmp8oB2buDdr/gQkn8pfV8Y1m/6DRWUT6F0vze+JhGJ nvkPnuMkGR5yLKqdA8e6iCG0N09O9rWjSCoqE1GZmKybAkqmkfj0m+LIsNEF/3LvSI45 70EYoKn0jJm/WLgq+v7qN1VC+G7divIXTl+23AMGmWncLv1mEE2p/0H+AcrOfWwjCcc8 QxrA== 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=gLHJBhKHjVuVR3mcBnbsIiyt4ymeaQeICW0gIztUwNk=; b=CGsf394a2+V/AFvMKOOMlz9lZ2XKrIaPvBnAXMMrSyf0BOQJJGkq3REOdpuIXEhdAL +AIL4n4yn0O1BytjMWQ43TVCZzvnHkEz5HlTrLHZzWz6ZcBLPvgjg4z5MzS37vW/NgXH X+rIRDUVhxZ9VHzbMgrDo2UCguYx0Cb3neOtUTU8ANpRpe2c1q1hq3XmoflnbvRyDxSj 6s9duDKVx/jSetRhxLfvdXl6JdRqcC0yqVKQGxN3UkYAgnPrJETcGzWxa1LB8qYme1E8 C75N2IypRLlX9YTMvsmQ4SmnlNBS6AAJAdZrx1wg2/iAHqE8WnLiMUlnEuTZ+XxQxAXj /IGA== X-Gm-Message-State: AJIora+hq53wxwkoutRL3yxTO7oSxtJBKUxpnbSUkeP/iJtifAPQb74e ndb0w2J961UC+9yHdmgxzJQ= X-Received: by 2002:a05:6402:2b88:b0:43a:6c58:6c64 with SMTP id fj8-20020a0564022b8800b0043a6c586c64mr29336124edb.348.1657211777713; Thu, 07 Jul 2022 09:36:17 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t27-20020a17090616db00b0071cbc7487e1sm19009030ejd.69.2022.07.07.09.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:36:16 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: ansuelsmth@gmail.com, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH 1/2] mtd: core: simplify (a bit) code find partition-matching dynamic OF node Date: Thu, 7 Jul 2022 18:36:06 +0200 Message-Id: <20220707163607.20729-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_093620_956991_31C23460 X-CRM114-Status: GOOD ( 14.71 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?utf-8?q?Spam_detection_software=2C_running_on_the_system_?= =?utf-8?q?=22bombadil=2Einfradead=2Eorg=22=2C?= =?utf-8?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_original?= =?utf-8?q?_message_has_been_attached_to_this_so_you_can_view_it_or_label?= =?utf-8?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?utf-8?q?_the_administrator_of_that_system_for_details=2E?= =?utf-8?q?_?= =?utf-8?q?_Content_preview=3A__From=3A_Rafa=C3=85=C2=82_Mi=C3=85=C2=82ecki_1?= =?utf-8?q?=2E_Don=27t_hardcode_=22partition-=22_string?= =?utf-8?q?_twice_2=2E_Use_simpler_logic_=26_use_-=3Ename_to_avoid_of=5Fprope?= =?utf-8?q?rty=5Fread=5Fstring=28=29?= =?utf-8?q?_Signed-off-by=3A_Rafa=C3=85=C2=82_Mi=C3=85=C2=82ecki_---_drivers/?= =?utf-8?q?mtd/mtdcore=2Ec_=7C_10_+++++-----?= =?utf-8?q?_1_file_changed=2C_5_insertions=28+=29=2C_5_deletions=28-=29_?= =?utf-8?q?_?= =?utf-8?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_required?= =?utf-8?q?=29?= =?utf-8?q?_?= =?utf-8?q?_pts_rule_name______________description?= =?utf-8?q?_----_----------------------_-------------------------------------?= =?utf-8?q?-------------?= =?utf-8?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_at_https?= =?utf-8?q?=3A//www=2Ednswl=2Eorg/=2C?= =?utf-8?q?_no_trust?= =?utf-8?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MmMgbGlzdGVkIGluXQ==?= =?utf-8?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?utf-8?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_record?= =?utf-8?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publish_an_?= =?utf-8?q?SPF_Record?= =?utf-8?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_abused_en?= =?utf-8?q?duser_mail?= =?utf-8?q?_provider?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freemail_use?= =?utf-8?q?rname_ends?= =?utf-8?q?_in_digit?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_author=27s_domain?= =?utf-8?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_valid_DK?= =?utf-8?q?IM_or_DK_signature?= =?utf-8?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_signature?= =?utf-8?q?=2C_not_necessarily?= =?utf-8?q?_valid?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_envelope-from_domain?= X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org From: Rafał Miłecki 1. Don't hardcode "partition-" string twice 2. Use simpler logic & use ->name to avoid of_property_read_string() Signed-off-by: Rafał Miłecki --- drivers/mtd/mtdcore.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index dc9b33990895..79c447fe30b4 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -573,15 +573,15 @@ static void mtd_check_of_node(struct mtd_info *mtd) /* Search if a partition is defined with the same name */ for_each_child_of_node(partitions, mtd_dn) { - offset = 0; - /* Skip partition with no/wrong prefix */ - if (!of_node_name_prefix(mtd_dn, "partition-")) + if (!of_node_name_prefix(mtd_dn, prefix)) continue; /* Label have priority. Check that first */ - if (of_property_read_string(mtd_dn, "label", &pname)) { - of_property_read_string(mtd_dn, "name", &pname); + if (!of_property_read_string(mtd_dn, "label", &pname)) { + offset = 0; + } else { + pname = mtd_dn->name; offset = prefix_len; }