Skip to content

Commit e635cf8

Browse files
saschahauerrichardweinberger
authored andcommitted
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>
1 parent 0e26b6e commit e635cf8

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

fs/ubifs/lpt.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,27 +1480,11 @@ struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i)
14801480
*/
14811481
struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum)
14821482
{
1483-
int err, i, h, iip, shft;
1484-
struct ubifs_nnode *nnode;
1483+
int i, iip;
14851484
struct ubifs_pnode *pnode;
14861485

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;
14931486
i = lnum - c->main_first;
1494-
shft = c->lpt_hght * 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);
1487+
pnode = ubifs_pnode_lookup(c, i >> UBIFS_LPT_FANOUT_SHIFT);
15041488
if (IS_ERR(pnode))
15051489
return ERR_CAST(pnode);
15061490
iip = (i & (UBIFS_LPT_FANOUT - 1));

0 commit comments

Comments
 (0)