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; } From patchwork Thu Jul 7 16:36:07 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: 588123 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp740050mab; Thu, 7 Jul 2022 09:37:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulKMOcKYpraSd0NpLdCZprUmlYE74L56014JIC0iPQgehN+cu+srgrbG5YJXYw903OFUge X-Received: by 2002:a05:6a00:1a16:b0:528:692e:6637 with SMTP id g22-20020a056a001a1600b00528692e6637mr23310166pfv.69.1657211820964; Thu, 07 Jul 2022 09:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657211820; cv=none; d=google.com; s=arc-20160816; b=G3FKUeagz5S3LnbeH0YLBkAwZfXDf2/2bkplftE/aeI39+FdtqtGQd2BywHfGIGWpd 1xiTaPwGVITPiq1AS02sszAe1BRS7BQCzD/23q14mob5AGxj8my8zI4k/Pt/54/LX4Xu XEiN9XtBqdm+ALxDSwfzcnL/JDV5y+ffbldrzEIhTXTIXhmhdZNYoy2JMTNijfW76ssT Tl98pCkEzOsuCo1DUSi79zXSpnk8ocyciDFRoursrO1gsvPrcXIDLUuA5kPu1BeeRNTK Qp+fs1HUAraKFvDXGRCi8W/UHa122K7hg++TYevSNIpO4XSdLr5zq2iBYPnWllpU4Q64 evVg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=UYOUSxaVnke56HjCgHGXz1VwgH5NP+RVR5WfV86B8lc=; b=NXEgx6Ox/YnK4E+LxuiLSjsh/ttwwlo4tgYtzLgGpOXlX24CxAZdrW0f7cIjPC/AbY f8Dk1irPlb1rhzfoSPrp/jSRvF/frnm4Lain1ff0GGHxddCz3O3g0xvH1yb/uJ6VwkhY 8oQnlIWDW53IhBa8zJBipJSYNyG7wQ5uYVAGIH3LubIYXv8vXTnJyVhxch1ITxbAOoBk U43YK9FQPnUuu2bV0HTe+COvdZJV47QiFN6+hTYJIHxY/8NCmdW+37oltB3rybuOO45m Yp+sFuLvopo3XcvHUdyA4p2TPBa+PzbvMBA49L2G2XCsnbteENeSalntUeO5UfypKWcS +udQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=Avmji7rD; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="EMKT4/3o"; 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 h11-20020a17090ac38b00b001ef9099d441si12664725pjt.110.2022.07.07.09.37.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:37:00 -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=Avmji7rD; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="EMKT4/3o"; 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:References:In-Reply-To: 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: List-Owner; bh=UYOUSxaVnke56HjCgHGXz1VwgH5NP+RVR5WfV86B8lc=; b=Avmji7rDQ7tAvf /6zYqiNz0FoWWZ5Fx7qdzUZ8iwcj7iQtcHSmtJx4S5M7VmwshXSinFEIgSvZWiNasDfc4jX5Va/jI MuKLBmlgRsqIJG8+B1W02t5hVQ3XKzexsNp3UWELcsnUNpK51vG2X/LP2Li0GRBTe9kQnyydoBdVI OritnQ4J+BSUCZ0q4UUxEpuz/+uwGJDY5TiFuuu5bCovTYaVEJKqfRfvpaJ5CkCZ37RqjUHXyQzAR 33n/xSCmK7DYbG7RAj2FlfoTa269h6ONyH8x4EjkIE1pg+ESmkjhwQKw8Q0G0KEcGdXC0y0/JHTNI 5pEz7JmDvFiqp7Lw4BGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9UUM-00H0Fz-PO; Thu, 07 Jul 2022 16:36:26 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9UUH-00H0Cs-FI for linux-mtd@lists.infradead.org; Thu, 07 Jul 2022 16:36:23 +0000 Received: by mail-ed1-x536.google.com with SMTP id k30so15725040edk.8 for ; Thu, 07 Jul 2022 09:36:20 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=EpRFRQjTAtTr1M5DmE/x/HJDwd5mR/vVrtLFwi8k4Rc=; b=EMKT4/3otjt8/rvpIKCJ1b2up/bgSsRt4nctE5sS6+lnuOSbOyoeg/ktEO4LC2wrW7 Q99cck/TGy6MosOLQ75QZs/hGRX1dUfvsEr5F7N1QUKjI9uEwQb7rmyaaSlWtf8JrC0c DCSkH/e1WiRqMJ28VaobSI+VKrzLSssbI65UVRvM91xUA2iL3wO6q9S5rcuuhDpc64tv HK4bp1IrDrQWV7+oPb+9c7tdAJyd4OlbN8lvFtEzEIt1q1YVrEcEj2gzUgZHN2Xx5dZf JP0wpwymGrtRbjexM9FvahGJJnJDx9bWiqRuKCf7bdZb1XEC4v0Utps82E/SOutECnjk pcPw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EpRFRQjTAtTr1M5DmE/x/HJDwd5mR/vVrtLFwi8k4Rc=; b=kORM1tBwxq9sKhHef6wkOEgw1OWI2/C2ZsHPYUXWqAyPvwch2rhi1/3iXJWrqoarSF rwE4YXHFzjlCUjotFAioXLq1bZHT0LTb2iykLRX6ft3iWE8vuxIuKn3Q0yl4+ZJQJD2o /4eNdnf8b1biE9WYo7bNm8gORuhXJSC4vujrwmrhuod38BEeJSnTEfiIqEvMNLt9z2RF SFSwIcwpxpYqBlTJd6RRW+CN2PTdZYn1yMIddL7Z/wo0oovdrhrETQTr9dpeEdWIaswx BdNn4etx1u81NszJFD0bZlFSLw89M45wkgN/86H1foAprYuw+WoCOZh8bYy9LuI3XHIg cZiA== X-Gm-Message-State: AJIora9QadfCVOeLBPUwmsoR7mdYCm3538FpgNkKGFvGTNiDLR1x5/Jy xcX/hCi9RxiF/T9PL2vnB9k= X-Received: by 2002:aa7:d555:0:b0:43a:1be7:9e17 with SMTP id u21-20020aa7d555000000b0043a1be79e17mr37347794edr.183.1657211779662; Thu, 07 Jul 2022 09:36:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:36:19 -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 2/2] mtd: core: find OF node for every MTD partition Date: Thu, 7 Jul 2022 18:36:07 +0200 Message-Id: <20220707163607.20729-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220707163607.20729-1-zajec5@gmail.com> References: <20220707163607.20729-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220707_093621_566371_669DDA03 X-CRM114-Status: GOOD ( 15.05 ) 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_D?= =?utf-8?q?on=27t_limit_this_feature_to_the_=22nvmem-cells=22=2E?= =?utf-8?q?_There_are_more_cases_to_this=2E_1=2E_Dynamic_partitions_may_need_?= =?utf-8?q?to_be_handled?= =?utf-8?q?_with_parsers_This_applies_to_=22fixed-partitions=22_parser_and_al?= =?utf-8?q?l_custom_ones=2E?= =?utf-8?b?IDIuIFsuLi5dIA==?= =?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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MzYgbGlzdGVkIGluXQ==?= =?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 Don't limit this feature to the "nvmem-cells". There are more cases to this. 1. Dynamic partitions may need to be handled with parsers This applies to "fixed-partitions" parser and all custom ones. 2. Dynamic partitions can be handled with specific drivers Consider "u-boot,env" as specified in the u-boot,env.yaml. Signed-off-by: Rafał Miłecki --- drivers/mtd/mtdcore.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 79c447fe30b4..f7693736dde4 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -552,7 +552,6 @@ static void mtd_check_of_node(struct mtd_info *mtd) const char *pname, *prefix = "partition-"; int plen, mtd_name_len, offset, prefix_len; struct mtd_info *parent; - bool found = false; /* Check if MTD already has a device node */ if (dev_of_node(&mtd->dev)) @@ -588,19 +587,11 @@ static void mtd_check_of_node(struct mtd_info *mtd) plen = strlen(pname) - offset; if (plen == mtd_name_len && !strncmp(mtd->name, pname + offset, plen)) { - found = true; + mtd_set_of_node(mtd, mtd_dn); break; } } - if (!found) - goto exit_partitions; - - /* Set of_node only for nvmem */ - if (of_device_is_compatible(mtd_dn, "nvmem-cells")) - mtd_set_of_node(mtd, mtd_dn); - -exit_partitions: of_node_put(partitions); exit_parent: of_node_put(parent_dn);