[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmbObG9lRO8w0FkJ@shell.armlinux.org.uk>
Date: Mon, 10 Jun 2024 10:59:08 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: netdev@...r.kernel.org, andrew@...n.ch, horms@...nel.org,
kuba@...nel.org, jiri@...nulli.us, pabeni@...hat.com,
hfdevel@....net, naveenm@...vell.com, jdamato@...tly.com
Subject: Re: [PATCH net-next v9 4/6] net: tn40xx: add basic Rx handling
On Thu, Jun 06, 2024 at 08:26:06AM +0900, FUJITA Tomonori wrote:
> +static int tn40_rxdb_alloc_elem(struct tn40_rxdb *db)
> +{
> + return db->stack[--(db->top)];
Parens are unnecessary here.
> +static void tn40_rxdb_free_elem(struct tn40_rxdb *db, unsigned int n)
> +{
> + db->stack[(db->top)++] = n;
Same here.
> + dno = tn40_rxdb_available(db) - 1;
> + i = dno;
> + while (i > 0) {
> + page = page_pool_dev_alloc_pages(priv->page_pool);
> + if (!page)
> + break;
> +
> + idx = tn40_rxdb_alloc_elem(db);
> + tn40_set_rx_desc(priv, idx, page_pool_get_dma_addr(page));
> + dm = tn40_rxdb_addr_elem(db, idx);
> + dm->page = page;
> +
> + i--;
> + }
While reviewing the rxdb stack, I came across this - this while() loop
is an open-coded for() loop:
for (i = dno; i > 0; i--) {
page = page_pool_dev_alloc_pages(priv->page_pool);
...
dm->page = page;
}
Is there any reason not to use a for() loop here?
> + if (i != dno)
> + tn40_write_reg(priv, f->m.reg_wptr,
> + f->m.wptr & TN40_TXF_WPTR_WR_PTR);
...
>+struct tn40_rxdb {
> + int *stack;
> + struct tn40_rx_map *elems;
> + int nelem;
> + int top;
I assume neither of these should ever be negative, so should these be
"unsigned int" ?
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists