Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp532758pjc; Mon, 20 May 2019 11:22:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxivqiClrtboOmVww7nntAWFnjwYWppEeuiEsEVpiitH71yhjO5i+LDLfxYhqWOZPRAErMj X-Received: by 2002:a63:c509:: with SMTP id f9mr77326045pgd.143.1558376534003; Mon, 20 May 2019 11:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558376533; cv=none; d=google.com; s=arc-20160816; b=c4W3m5tpvxUSXP8Ewxh8jt5fFEZNej3s+cpndLvao4/cqYADhN0WYR+45vk3tA+32W G/eS+/gpU+0RJGjYmRyMyse3S28+g1XLv/4KJxOJHlaRBk9GFsP3pRbGUE0+hooZMqKG xicLFz76djty5SH89ebc6Qnzc4Q37muXaRLNR2InUnOOViW/q4hkHkImkGS6NjXVe9iD wi1XY7K/VH+kyFvvExiisrGhmv3ZspC0aDc6r9w8FApwxfcixDymBptYBy/5wErBWaIG yl8jXUdC6Y6w3+lbT3yuvpSHumX3yRv4Ri03lBR7x7P/OE9X7E/WDAPffO6MugumpJwh CbMA== 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:from:subject:cc:to:message-id:date; bh=Sz0OIg5m8pUOhRCn+Mb0pHk18Q1roNUzyM1ccHeUrQg=; b=HVli28NcnWoGgIxN8v2zrhryUjZ8cIXY8eGlX7PCxkiikdThaj6wsnwtKbzxAIwhzR kPVBecC8fVNDic2KXJX466citH8mE7FMta9DKltKxJDhP5FVhQ70qCXZjhVTGdnZtAHy gQkxTxSdBlu2Ieyz4DIy6mnrSkeydoUK/rvp75AFe4qVdQXrg8TOESivuci5HrUFPRAe NtITM40TShAYc9V7mJC+plPG18yDQdhudLrcAjOR/pBkvfuY6gRyGHcHTk9tnB3XsbUQ m8yRy29MXAGWCs8aZ0ZIUwtgx1gjQYWn7SokdX1dG3sOD8nQpFcHSYnDNnXGBL018B48 SkSQ== 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 v10si18531510pgt.412.2019.05.20.11.21.58; Mon, 20 May 2019 11:22:13 -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 S1726575AbfETRwE (ORCPT + 99 others); Mon, 20 May 2019 13:52:04 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:55488 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726282AbfETRwC (ORCPT ); Mon, 20 May 2019 13:52:02 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::3d8]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 90F1514EC46B1; Mon, 20 May 2019 10:52:00 -0700 (PDT) Date: Mon, 20 May 2019 10:51:59 -0700 (PDT) Message-Id: <20190520.105159.1094490201484427551.davem@davemloft.net> To: o.rempel@pengutronix.de Cc: paul.burton@mips.com, ralf@linux-mips.org, jhogan@kernel.org, robh+dt@kernel.org, jcliburn@gmail.com, chris.snook@gmail.com, mark.rutland@arm.com, kernel@pengutronix.de, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, john@phrozen.org, nbd@nbd.name, netdev@vger.kernel.org, andrew@lunn.ch, gch981213@gmail.com, info@freifunk-bad-gandersheim.net Subject: Re: [PATCH v5 3/3] net: ethernet: add ag71xx driver From: David Miller In-Reply-To: <20190520070716.23668-4-o.rempel@pengutronix.de> References: <20190520070716.23668-1-o.rempel@pengutronix.de> <20190520070716.23668-4-o.rempel@pengutronix.de> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 20 May 2019 10:52:01 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oleksij Rempel Date: Mon, 20 May 2019 09:07:16 +0200 > +struct ag71xx_buf { > + union { > + struct sk_buff *skb; > + void *rx_buf; > + }; > + union { > + dma_addr_t dma_addr; > + unsigned int len; > + }; > +}; I find this double union very confusing. When using unions you should make it strictly clear which members are used together, at what times, and in which situations. Therefore, please use something like anonymous structures to group the members that are used together at the same time, something like: struct ag71xx_buf { union { struct { struct sk_buff *skb; dma_addr_t dma_addr; } tx; struct { void *rx_buf; unsigned int len; } rx; }; Or at the very least add a very big comment that explains the use of the union members. > +static int ag71xx_mdio_mii_read(struct mii_bus *bus, int addr, int reg) > +{ > + struct ag71xx *ag = bus->priv; > + struct net_device *ndev = ag->ndev; > + int err, val; Reverse christmas tree here please. > +static int ag71xx_mdio_mii_write(struct mii_bus *bus, int addr, int reg, > + u16 val) > +{ > + struct ag71xx *ag = bus->priv; > + struct net_device *ndev = ag->ndev; > + Likewise. > +static int ag71xx_mdio_probe(struct ag71xx *ag) > +{ > + static struct mii_bus *mii_bus; > + struct device *dev = &ag->pdev->dev; > + struct device_node *np = dev->of_node; > + struct net_device *ndev = ag->ndev; > + int err; Likewise. > +static int ag71xx_tx_packets(struct ag71xx *ag, bool flush) > +{ > + struct ag71xx_ring *ring = &ag->tx_ring; > + struct net_device *ndev = ag->ndev; > + bool dma_stuck = false; > + int ring_mask = BIT(ring->order) - 1; > + int ring_size = BIT(ring->order); > + int sent = 0; > + int bytes_compl = 0; > + int n = 0; Likewise. And so on, and so forth, for the rest of this file.