summaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lpt.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-09-07 08:36:27 -0400
committerRichard Weinberger <richard@nod.at>2018-10-23 07:48:21 -0400
commite635cf8c3bbd7b9bd3e282156c6cc4f818b72ee9 (patch)
treefbb160a3565fd646297943f514b0837f22a4c53d /fs/ubifs/lpt.c
parent0e26b6e2551e21df72c140e46819523e1b686009 (diff)
ubifs: Implement ubifs_lpt_lookup using ubifs_pnode_lookup
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 <s.hauer@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r--fs/ubifs/lpt.c20
1 files 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)
1480 */ 1480 */
1481struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum) 1481struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum)
1482{ 1482{
1483 int err, i, h, iip, shft; 1483 int i, iip;
1484 struct ubifs_nnode *nnode;
1485 struct ubifs_pnode *pnode; 1484 struct ubifs_pnode *pnode;
1486 1485
1487 if (!c->nroot) {
1488 err = ubifs_read_nnode(c, NULL, 0);
1489 if (err)
1490 return ERR_PTR(err);
1491 }
1492 nnode = c->nroot;
1493 i = lnum - c->main_first; 1486 i = lnum - c->main_first;
1494 shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; 1487 pnode = ubifs_pnode_lookup(c, i >> UBIFS_LPT_FANOUT_SHIFT);
1495 for (h = 1; h < c->lpt_hght; h++) {
1496 iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
1497 shft -= UBIFS_LPT_FANOUT_SHIFT;
1498 nnode = ubifs_get_nnode(c, nnode, iip);
1499 if (IS_ERR(nnode))
1500 return ERR_CAST(nnode);
1501 }
1502 iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
1503 pnode = ubifs_get_pnode(c, nnode, iip);
1504 if (IS_ERR(pnode)) 1488 if (IS_ERR(pnode))
1505 return ERR_CAST(pnode); 1489 return ERR_CAST(pnode);
1506 iip = (i & (UBIFS_LPT_FANOUT - 1)); 1490 iip = (i & (UBIFS_LPT_FANOUT - 1));