Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2867345imm; Mon, 13 Aug 2018 01:43:56 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzw1TDK8DLQTM83VWAaAzsfatHKS/1ByheIvoHOKFeohSOHpJNrLjn1iTK3ilDJ5QCCI740 X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr16091017plz.3.1534149835990; Mon, 13 Aug 2018 01:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534149835; cv=none; d=google.com; s=arc-20160816; b=ffjXq0+/NSPHj9fZBzaUNUp25NQF0jZa3+2oTBWTRDr+dkd8GMbGhW2VLxAS6CQqrE kW/EWik5IBG43NRoAo6hapRdPd6dejxD1wc8kmY5zP/L1pH+R4n9dMV1F4XLtW+UmIyw GZP4XLYn0zs9RDbv/e0zO1msKf/FpxJRVGAWztk8/DlGvSFBq3LflWCxsto+bxp72or5 ZPHp0FDPpGTucSz11u+VgeOWcKcMaDkjydKA+TrA0u0O0EE4ULGNf8DLuHm9WzSkB58D S/a6IM8j6w3gMYfeoUYrJbOAfB+yNnlEjoz8aRXpdOG50SIP72m1ktel74iPsoFwUnWE mBtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=jm4Cpgx4WeLWKUrt+TkdlatQemTad7Xng5yANkMiZuE=; b=hWgVNvV63IGbNHDAz5U6caLObYCtONQp/BqPLsB6cXZeX3hciQccpTYjcOkLlIwaeU 3o58yaT3ukfMK9vABBinwiPS/DFOnjksnFeWQOfnTo4bEE/ePe9unCmj0p4VkLDdIwfe u7soi3OPuNhLWJKPhjE0HWv+8pl8ydho+H4OPO9sLjqsA19oI/a1x/gtbwX/TIrt357L CgZ39XAfxjI8wbuKJxT8lB3FjU4nmk5TL0W/40tqg+C3sJJ52tL2s46d2a6j1YSuqtIA LslKqW+9S0iPF6t+khPQpqHV1510IU/RZzaCPhjTTHqIZPw1pyRpxcgm6tjYG7L7d5ub +mIA== 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 x33-v6si13818288plb.160.2018.08.13.01.43.38; Mon, 13 Aug 2018 01:43:55 -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 S1728627AbeHMKxu (ORCPT + 99 others); Mon, 13 Aug 2018 06:53:50 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:44431 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728192AbeHMKxu (ORCPT ); Mon, 13 Aug 2018 06:53:50 -0400 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fp7xv-0002iX-Dw; Mon, 13 Aug 2018 10:12:39 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fp7xu-0007T6-Ev; Mon, 13 Aug 2018 10:12:38 +0200 Date: Mon, 13 Aug 2018 10:12:38 +0200 From: Sascha Hauer To: Richard Weinberger 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 Message-ID: <20180813081238.crujoer2qprhn27y@pengutronix.de> References: <20180704124137.13396-1-s.hauer@pengutronix.de> <20180704124137.13396-6-s.hauer@pengutronix.de> <20180813063127.kpxw6d5amna5wpas@pengutronix.de> <8387142.nbJ7LYRgBX@blindfold> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8387142.nbJ7LYRgBX@blindfold> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 10:05:21 up 61 days, 17:14, 64 users, load average: 0.30, 0.13, 0.10 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 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 On Mon, Aug 13, 2018 at 08:34:00AM +0200, Richard Weinberger wrote: > 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. Do you have a suggestion for a helper function? lpt.c is full of rather non obvious arithmetic operations and I couldn't find a helper function that could be reused at least once in the code. I tried with: static int lnum_to_pnode_num(struct ubifs_info *c, int lnum) { return (lnum - c->main_first) >> UBIFS_LPT_FANOUT_SHIFT; } But I am not sure this really improves things Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |