Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp766420imm; Wed, 4 Jul 2018 05:44:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFuBW5OG8EvKp6CVdZtfQ9gdyhRZ17jzveBtkRqDzFn9E2oK5EW/A4mLreWsdxbQvyRiUF X-Received: by 2002:a17:902:59da:: with SMTP id d26-v6mr2015557plj.42.1530708282435; Wed, 04 Jul 2018 05:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530708282; cv=none; d=google.com; s=arc-20160816; b=CO9qIlBxHgLysFy+50lbYrbZ6ZnrUEyZtaux2WQ3qfHNajbNSAmZN+g8IZm3mIQx0/ Ssx8xzcHPjszRLAfs5EGn9rf5DGKNK1tDJHfY2uMPqOmQdezVSydhk0dDLETkUjksjM5 clgDaaNjxfGZJ9bjvhZyaeK1F3bw8xbGuzlbi/y3uSlBBCH/TFrLkVKl/uQvhZX7qcwn 6Xuddn5T2B40CaLNaoVgJzkcdsR9LUCJyD0Msopqfz1zhymvCeKg+YGXMVmBhDWIMFu7 ui7IXkiCwfzhxB+dLokmRv527t3p7VSIwPHnCGAfjVys+mEL9WBEHTc2rQqrwzmcpTh9 0P3Q== 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:arc-authentication-results; bh=/z/9OwKXPh/Fbykw1VqyUZTSphNln9nrIIZrkFXBju4=; b=eY/adqk86G+ejpYAvd9WKgO8SngXzgUcSmMrxyYSNopcw8l+J8T0j3aMvoy77teSZf 6pRBjy536VE42A82N7C3jjYR4C9JY9SiahakW+tSvYqSgwafJy5w0PeQPDqpFgnjtZg1 6/KN4DYZbcAq8+y9dkdaMeQu/NtLK7l1SHcx6dJE+FkeI95aC2fHjBDnZgxH1kWrHcte JbGxtI3iCiBTnH/RsKhXiqRo7Ttg12H+HqAxKgn3Y4eguvZ0z3a6M8Ev5S2HhhPiIa8r knrXDgk8QaBp5MUnpzOaHGiP/KTQqHJeyx4q3GVfOUoKKn8oZVzK809KNntV+DF/mLUG ZNZw== 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 n64-v6si3525386pgn.247.2018.07.04.05.44.27; Wed, 04 Jul 2018 05:44:42 -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 S934737AbeGDMm1 (ORCPT + 99 others); Wed, 4 Jul 2018 08:42:27 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37367 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934508AbeGDMmW (ORCPT ); Wed, 4 Jul 2018 08:42:22 -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 1fah6m-0001dN-Ep; Wed, 04 Jul 2018 14:42:08 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fah6l-0005Yy-Ey; Wed, 04 Jul 2018 14:42:07 +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 05/25] ubifs: implement ubifs_lpt_lookup using ubifs_pnode_lookup Date: Wed, 4 Jul 2018 14:41:17 +0200 Message-Id: <20180704124137.13396-6-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180704124137.13396-1-s.hauer@pengutronix.de> References: <20180704124137.13396-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 6cd6f23d4512..cde7b9484157 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c @@ -1478,27 +1478,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); if (IS_ERR(pnode)) return ERR_CAST(pnode); iip = (i & (UBIFS_LPT_FANOUT - 1)); -- 2.18.0