mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree@vger.kernel.org,
	Masami Hiramatsu <masami.hiramatsu@linaro.org>,
	Jassi Brar <jaswinder.singh@linaro.org>
Subject: Re: [PATCH net-next v2 2/2] net: ethernet: socionext: add AVE ethernet driver
Date: Wed, 18 Oct 2017 19:23:59 +0900	[thread overview]
Message-ID: <20171018192359.243C.4A936039@socionext.com> (raw)
In-Reply-To: <CAK7LNAR0Dy0aUjQKw7YxSbXZkpjn=1B7_knkSed6=EDVzL6v9w@mail.gmail.com>

On Mon, 16 Oct 2017 00:08:21 +0900 <yamada.masahiro@socionext.com> wrote:

> 2017-10-13 9:35 GMT+09:00 Kunihiko Hayashi <hayashi.kunihiko@socionext.com>:
> > +static int ave_probe(struct platform_device *pdev)
> > +{
> > +       struct device *dev = &pdev->dev;
> > +       struct device_node *np = dev->of_node;
> > +       u32 ave_id;
> > +       struct ave_private *priv;
> > +       const struct ave_soc_data *data;
> > +       phy_interface_t phy_mode;
> > +       struct net_device *ndev;
> > +       struct resource *res;
> > +       void __iomem *base;
> > +       int irq, ret = 0;
> > +       char buf[ETHTOOL_FWVERS_LEN];
> > +       const void *mac_addr;
> > +
> > +       data = of_device_get_match_data(dev);
> > +       if (WARN_ON(!data))
> > +               return -EINVAL;
> > +
> > +       phy_mode = of_get_phy_mode(np);
> > +       if (phy_mode < 0) {
> > +               dev_err(dev, "phy-mode not found\n");
> > +               return -EINVAL;
> > +       }
> > +       if ((!phy_interface_mode_is_rgmii(phy_mode)) &&
> > +           phy_mode != PHY_INTERFACE_MODE_RMII &&
> > +           phy_mode != PHY_INTERFACE_MODE_MII) {
> > +               dev_err(dev, "phy-mode is invalid\n");
> > +               return -EINVAL;
> > +       }
> > +
> > +       irq = platform_get_irq(pdev, 0);
> > +       if (irq < 0) {
> > +               dev_err(dev, "IRQ not found\n");
> > +               return irq;
> > +       }
> > +
> > +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +       base = devm_ioremap_resource(dev, res);
> > +       if (IS_ERR(base))
> > +               return PTR_ERR(base);
> > +
> > +       /* alloc netdevice */
> > +       ndev = alloc_etherdev(sizeof(struct ave_private));
> > +       if (!ndev) {
> > +               dev_err(dev, "can't allocate ethernet device\n");
> > +               return -ENOMEM;
> > +       }
> > +
> > +       ndev->netdev_ops = &ave_netdev_ops;
> > +       ndev->ethtool_ops = &ave_ethtool_ops;
> > +       SET_NETDEV_DEV(ndev, dev);
> > +
> > +       /* support hardware checksum */
> > +       ndev->features    |= (NETIF_F_IP_CSUM | NETIF_F_RXCSUM);
> > +       ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_RXCSUM);
> > +
> > +       ndev->max_mtu = AVE_MAX_ETHFRAME - (ETH_HLEN + ETH_FCS_LEN);
> > +
> > +       /* get mac address */
> > +       mac_addr = of_get_mac_address(np);
> > +       if (mac_addr)
> > +               ether_addr_copy(ndev->dev_addr, mac_addr);
> > +
> > +       /* if the mac address is invalid, use random mac address */
> > +       if (!is_valid_ether_addr(ndev->dev_addr)) {
> > +               eth_hw_addr_random(ndev);
> > +               dev_warn(dev, "Using random MAC address: %pM\n",
> > +                        ndev->dev_addr);
> > +       }
> > +
> > +       priv = netdev_priv(ndev);
> > +       priv->base = base;
> > +       priv->irq = irq;
> > +       priv->ndev = ndev;
> > +       priv->msg_enable = netif_msg_init(-1, AVE_DEFAULT_MSG_ENABLE);
> > +       priv->phy_mode = phy_mode;
> > +       priv->data = data;
> > +
> > +       if (IS_DESC_64BIT(priv)) {
> > +               priv->desc_size = AVE_DESC_SIZE_64;
> > +               priv->tx.daddr  = AVE_TXDM_64;
> > +               priv->rx.daddr  = AVE_RXDM_64;
> > +       } else {
> > +               priv->desc_size = AVE_DESC_SIZE_32;
> > +               priv->tx.daddr  = AVE_TXDM_32;
> > +               priv->rx.daddr  = AVE_RXDM_32;
> > +       }
> > +       priv->tx.ndesc = AVE_NR_TXDESC;
> > +       priv->rx.ndesc = AVE_NR_RXDESC;
> > +
> > +       u64_stats_init(&priv->stats_rx.syncp);
> > +       u64_stats_init(&priv->stats_tx.syncp);
> > +
> > +       /* get clock */
> 
> Please remove this super-obvious comment.

I'll check comments out and remove them unnecessary.

> > +       priv->clk = clk_get(dev, NULL);
> 
> Missing clk_put() in the failure path.
> 
> Why don't you use devm?
> 
> 
> 
> > +       if (IS_ERR(priv->clk))
> > +               priv->clk = NULL;
> 
> So, clk is optional, but
> you need to check EPROBE_DEFER.
> 
> 
> 
> 
> > +       /* get reset */
> 
> Remove.
> 
> 
> > +       priv->rst = reset_control_get(dev, NULL);
> > +       if (IS_ERR(priv->rst))
> > +               priv->rst = NULL;
> 
> 
> reset_control_get() is deprecated.  Do not use it in a new driver.
> 
> Again, missing reset_control_put().   devm?
> 
> 
> The reset seems optional (again, ignoring EPROBE_DEFER)
> but you did not use reset_control_get_optional, why?
> 
> From your code, this reset is used as shared.
> 
> 
> priv->rst = devm_reset_control_get_optional_shared(dev, NULL);
> if (IS_ERR(priv->rst))
>           return PTR_ERR(priv->rst);

The clk and reset are optional in the driver.
Referring to your suggested method, I'll fix the part of clk and reset.

> 
> 
> -- 
> Best Regards
> Masahiro Yamada

---
Best Regards,
Kunihiko Hayashi

  reply	other threads:[~2017-10-18 10:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  0:35 [PATCH net-next v2 0/2] add UniPhier AVE ethernet support Kunihiko Hayashi
2017-10-13  0:35 ` [PATCH net-next v2 1/2] dt-bindings: net: add DT bindings for Socionext UniPhier AVE Kunihiko Hayashi
2017-10-13 16:41   ` Masahiro Yamada
2017-10-18 10:23     ` Kunihiko Hayashi
2017-10-15 14:52   ` Masahiro Yamada
2017-10-13  0:35 ` [PATCH net-next v2 2/2] net: ethernet: socionext: add AVE ethernet driver Kunihiko Hayashi
2017-10-15 15:08   ` Masahiro Yamada
2017-10-18 10:23     ` Kunihiko Hayashi [this message]
2017-10-19  0:29       ` Masahiro Yamada
2017-10-19 10:35         ` Kunihiko Hayashi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171018192359.243C.4A936039@socionext.com \
    --to=hayashi.kunihiko@socionext.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=jaswinder.singh@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=masami.hiramatsu@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®