Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1775855imm; Fri, 7 Sep 2018 06:05:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbBK4JwHGuH0b2CmGgYF5KzAjLI16DTOI4bCeNH7Dxtlh4Co92JAbY3m+C7Kpi423l5mCdB X-Received: by 2002:a17:902:7586:: with SMTP id j6-v6mr7792479pll.295.1536325518353; Fri, 07 Sep 2018 06:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536325518; cv=none; d=google.com; s=arc-20160816; b=PGwvemFd6Q9aBKA1B+2CGVRz/wdn5MfJ19MIMHLeFk7lxsCvEwEBGVoI1GgpS4Dhev XOX5jz+62DdbDXIwfcuL5ZAyzjLkh+zETzdetjJ9iLuoqSat/sfM8WgzJotbYbHdJzx6 tbggajAkO0Bh4U78CuhuGdDKESFPRCnJgaOuAwkYj1/xINrZU/Da0Ceh+XfmoH8ioVkI ckKCt3t2hUfuVWMhSMY+887JwNywO2dpzz73sfqOl2JgbuzNmkz23lvZ2mSeUA6Cbs1I AWM6QWfv94Za0mbBUu1u1xB2XL3HmB7zLCkVsCyqeRnV0haUxrxcwcE/5uzcME+femhd JU5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=YGmJiRCnRJPdNCUilZpF1aqKg751lEldm6968DU2WKQ=; b=cD/oa5OfZuIuFGrelBFhc2dX16EZ15SaMCAArd153wLX5yVejRro51IVPcwlGMyzMd BuRvbQkqCSfV63vdv7En9+1AgLwH91DkWyG9IT+tmUixYsRZo3KQ9hR7E/YHEinNSdaT gaZ/SrBimKhnISmNZ7/upbM3gIzMwBWqqUYhvXqtPkVJqsZwFXzZgfVaGSFqEF7m1s/S 5Ij89GaU5q43l1ZX4aWhhv1xJO1sKJVWygSaUNJyk2a+tfOw90pa73o/ktna2uLi/YFz N/10ONJMozFyLM53Y4XxECOh1qQVOcZY2zTYMWpwm9HctbL21qo63+K1WXZ67cKFDz6p PEJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32-v6si8217383plc.475.2018.09.07.06.05.03; Fri, 07 Sep 2018 06:05:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729386AbeIGRTk (ORCPT + 99 others); Fri, 7 Sep 2018 13:19:40 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:45539 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbeIGRTj (ORCPT ); Fri, 7 Sep 2018 13:19:39 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fyG27-0007br-FK; Fri, 07 Sep 2018 14:38:43 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fyG26-00061u-Cg; Fri, 07 Sep 2018 14:38:42 +0200 From: Sascha Hauer To: linux-mtd@lists.infradead.org Cc: David Gstir , Richard Weinberger , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Sascha Hauer Subject: [PATCH 06/25] ubifs: implement ubifs_lpt_lookup using ubifs_pnode_lookup Date: Fri, 7 Sep 2018 14:36:27 +0200 Message-Id: <20180907123646.12688-7-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907123646.12688-1-s.hauer@pengutronix.de> References: <20180907123646.12688-1-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ubifs_lpt_lookup() starts by looking up the nth pnode in the LPT. We already have this functionality in ubifs_pnode_lookup(). Use this function rather than open coding its functionality. Signed-off-by: Sascha Hauer --- fs/ubifs/lpt.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index ed0c67fe7500..5f57af224b8f 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c @@ -1480,27 +1480,11 @@ struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i) */ struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum) { - int err, i, h, iip, shft; - struct ubifs_nnode *nnode; + int i, iip; struct ubifs_pnode *pnode; - if (!c->nroot) { - err = ubifs_read_nnode(c, NULL, 0); - if (err) - return ERR_PTR(err); - } - nnode = c->nroot; i = lnum - c->main_first; - shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; - for (h = 1; h < c->lpt_hght; h++) { - iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1)); - shft -= UBIFS_LPT_FANOUT_SHIFT; - nnode = ubifs_get_nnode(c, nnode, iip); - if (IS_ERR(nnode)) - return ERR_CAST(nnode); - } - iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1)); - pnode = ubifs_get_pnode(c, nnode, iip); + pnode = ubifs_pnode_lookup(c, i >> UBIFS_LPT_FANOUT_SHIFT); if (IS_ERR(pnode)) return ERR_CAST(pnode); iip = (i & (UBIFS_LPT_FANOUT - 1)); -- 2.18.0