lkml.org 
[lkml]   [2019]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v5 3/3] net: ethernet: add ag71xx driver
    From
    From: Oleksij Rempel <o.rempel@pengutronix.de>
    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.

    \
     
     \ /
      Last update: 2019-05-20 19:52    [W:4.237 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site