Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2774413imm; Sun, 12 Aug 2018 23:35:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx3KyF6rZN9uEJxswc56ABY5v4zcO8G8mW2wKPi1C0ddtfgQ1Yya94MGeEjWG9LYP70YbH4 X-Received: by 2002:a63:4f63:: with SMTP id p35-v6mr15751123pgl.167.1534142147081; Sun, 12 Aug 2018 23:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534142147; cv=none; d=google.com; s=arc-20160816; b=VPIGYn2tta5WVmWPbK6ws+3w6RGyTuoPNCBdCRGIEfXwZAT+1lt574CsJYxPQfyoi1 WirxznQ8OWOiiInxPChhGTfRKxSaB35ElXzqtuGSkCAU/PUNKpTDfneVHXnwn/ZDiLiW Go3WErWIKqxB8Gu8Mb0yxd5SP2VGnEHe6nOeCVPTmYgW02khflp/+OPPP9kNgT0Ar5eT HK9TagC0zu06bFRg/HsjObWbK3UgwyshyhJMb5X7Y7QBk4Vx+WucrlORUCIVmXdZ3K3M bUu5DJPATtV5hrjqLLsikkhsY2PLxOvaAjSQjoo5W3s9uQblFx3K2ctJ2anxFVoa7a3A +Q3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8NUMOWUiDbQYl9KpjIuksBjKwM2ty9mUzSw9HByQkfE=; b=EUnzCGJSXCbZ2+Aim2Rjlt6Oj9NebuasSyTE0X4+M03/rsl6fnCQiuYT25oMpREUMK 69bq0FwwZE0WQP0H8hFGflcoCK+lqULvIE9aow5+Tqct6aNcxo8IW6UJdqXE3mC2R41q Hrzr8FK8pYrrW6OU1j0vxhLDvzawpIiQnzUhd+cUhWh5IejIBX993bxWjtLAjXI19Sqo QhHhexlCg8wmi8F6Oy44zCttAlh25aUZEhgX4W2RlwZ6lnEFnT03JKcsJF4kC1UUSqvY uYlB8rXVlHkON0jl0mmGmRLAomd6c4BotRSteyAQ3zG6LNTxwhmipXh0AVt4QTdmm3+p bExQ== 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 d2-v6si12875351plh.341.2018.08.12.23.35.32; Sun, 12 Aug 2018 23:35:47 -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 S1728456AbeHMJO4 (ORCPT + 99 others); Mon, 13 Aug 2018 05:14:56 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:46372 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbeHMJOz (ORCPT ); Mon, 13 Aug 2018 05:14:55 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id AF37F605D864; Mon, 13 Aug 2018 08:34:04 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id JBrJgCKQCAIS; Mon, 13 Aug 2018 08:34:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 2E017605D865; Mon, 13 Aug 2018 08:34:04 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id R2B0w-fWxP_C; Mon, 13 Aug 2018 08:34:04 +0200 (CEST) Received: from blindfold.localnet (089144210135.atnat0019.highway.a1.net [89.144.210.135]) by lithops.sigma-star.at (Postfix) with ESMTPSA id 602DE605D864; Mon, 13 Aug 2018 08:34:03 +0200 (CEST) From: Richard Weinberger To: Sascha Hauer Cc: linux-mtd@lists.infradead.org, David Gstir , linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 05/25] ubifs: implement ubifs_lpt_lookup using ubifs_pnode_lookup Date: Mon, 13 Aug 2018 08:34:00 +0200 Message-ID: <8387142.nbJ7LYRgBX@blindfold> In-Reply-To: <20180813063127.kpxw6d5amna5wpas@pengutronix.de> References: <20180704124137.13396-1-s.hauer@pengutronix.de> <20180704124137.13396-6-s.hauer@pengutronix.de> <20180813063127.kpxw6d5amna5wpas@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Montag, 13. August 2018, 08:31:27 CEST schrieb Sascha Hauer: > On Wed, Jul 04, 2018 at 02:41:17PM +0200, Sascha Hauer wrote: > > 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); > > This should be > > ubifs_pnode_lookup(c, i >> UBIFS_LPT_FANOUT_SHIFT); Can you please add a helper function for that? These shift games are always confusing and not easy to spot. Thanks, //richard