All of lore.kernel.org
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 2/3] net: hisilicon: new hip04 MDIO driver
Date: Mon, 21 Apr 2014 21:58:00 +0400	[thread overview]
Message-ID: <53555C28.4050303@cogentembedded.com> (raw)
In-Reply-To: <1397869980-21187-3-git-send-email-zhangfei.gao@linaro.org>

Hello.

On 04/19/2014 05:12 AM, Zhangfei Gao wrote:

> Hisilicon hip04 platform mdio driver
> Reuse Marvell phy drivers/net/phy/marvell.c

> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
[...]

> diff --git a/drivers/net/ethernet/hisilicon/hip04_mdio.c b/drivers/net/ethernet/hisilicon/hip04_mdio.c
> new file mode 100644
> index 0000000..19826a3
> --- /dev/null
> +++ b/drivers/net/ethernet/hisilicon/hip04_mdio.c
> @@ -0,0 +1,185 @@
> +

    Empty line not needed here.

> +/* Copyright (c) 2014 Linaro Ltd.
> + * Copyright (c) 2014 Hisilicon Limited.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */

[...]

> +static int hip04_mdio_reset(struct mii_bus *bus)
> +{
> +	int temp, err, i;
> +
> +	for (i = 0; i < PHY_MAX_ADDR; i++) {
> +		hip04_mdio_write(bus, i, 22, 0);

    Why? What kind of a register this is? <uapi/linux/mii.h> tells me it's 
MII_SREVISION...

> +		temp = hip04_mdio_read(bus, i, MII_BMCR);

    You're not checking for error...

> +		temp |= BMCR_RESET;
> +		err = hip04_mdio_write(bus, i, MII_BMCR, temp);

    Hmm, why you're open coding BMCR reset? There's phy_init_hw() doing this 
correctly...

> +		if (err < 0)
> +			return err;
> +	}
> +
> +	mdelay(500);
> +	return 0;
> +}
> +
> +static int hip04_mdio_probe(struct platform_device *pdev)
> +{
> +	struct resource *r;
> +	struct mii_bus *bus;
> +	struct hip04_mdio_priv *priv;
> +	int ret;
> +
> +	bus = mdiobus_alloc_size(sizeof(struct hip04_mdio_priv));
> +	if (!bus) {
> +		dev_err(&pdev->dev, "Cannot allocate MDIO bus\n");
> +		return -ENOMEM;
> +	}
> +
> +	bus->name = "hip04_mdio_bus";
> +	bus->read = hip04_mdio_read;
> +	bus->write = hip04_mdio_write;
> +	bus->reset = hip04_mdio_reset;

    Ah... However I don't think it a good implementation of that bus method...

[...]

WBR, Sergei

WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Zhangfei Gao <zhangfei.gao@linaro.org>,
	davem@davemloft.net, linux@arm.linux.org.uk, arnd@arndb.de,
	f.fainelli@gmail.com, mark.rutland@arm.com,
	David.Laight@ACULAB.COM, eric.dumazet@gmail.com,
	xuwei5@hisilicon.com
Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v8 2/3] net: hisilicon: new hip04 MDIO driver
Date: Mon, 21 Apr 2014 21:58:00 +0400	[thread overview]
Message-ID: <53555C28.4050303@cogentembedded.com> (raw)
In-Reply-To: <1397869980-21187-3-git-send-email-zhangfei.gao@linaro.org>

Hello.

On 04/19/2014 05:12 AM, Zhangfei Gao wrote:

> Hisilicon hip04 platform mdio driver
> Reuse Marvell phy drivers/net/phy/marvell.c

> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
[...]

> diff --git a/drivers/net/ethernet/hisilicon/hip04_mdio.c b/drivers/net/ethernet/hisilicon/hip04_mdio.c
> new file mode 100644
> index 0000000..19826a3
> --- /dev/null
> +++ b/drivers/net/ethernet/hisilicon/hip04_mdio.c
> @@ -0,0 +1,185 @@
> +

    Empty line not needed here.

> +/* Copyright (c) 2014 Linaro Ltd.
> + * Copyright (c) 2014 Hisilicon Limited.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */

[...]

> +static int hip04_mdio_reset(struct mii_bus *bus)
> +{
> +	int temp, err, i;
> +
> +	for (i = 0; i < PHY_MAX_ADDR; i++) {
> +		hip04_mdio_write(bus, i, 22, 0);

    Why? What kind of a register this is? <uapi/linux/mii.h> tells me it's 
MII_SREVISION...

> +		temp = hip04_mdio_read(bus, i, MII_BMCR);

    You're not checking for error...

> +		temp |= BMCR_RESET;
> +		err = hip04_mdio_write(bus, i, MII_BMCR, temp);

    Hmm, why you're open coding BMCR reset? There's phy_init_hw() doing this 
correctly...

> +		if (err < 0)
> +			return err;
> +	}
> +
> +	mdelay(500);
> +	return 0;
> +}
> +
> +static int hip04_mdio_probe(struct platform_device *pdev)
> +{
> +	struct resource *r;
> +	struct mii_bus *bus;
> +	struct hip04_mdio_priv *priv;
> +	int ret;
> +
> +	bus = mdiobus_alloc_size(sizeof(struct hip04_mdio_priv));
> +	if (!bus) {
> +		dev_err(&pdev->dev, "Cannot allocate MDIO bus\n");
> +		return -ENOMEM;
> +	}
> +
> +	bus->name = "hip04_mdio_bus";
> +	bus->read = hip04_mdio_read;
> +	bus->write = hip04_mdio_write;
> +	bus->reset = hip04_mdio_reset;

    Ah... However I don't think it a good implementation of that bus method...

[...]

WBR, Sergei

  reply	other threads:[~2014-04-21 17:58 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19  1:12 [PATCH v8 0/3] add hisilicon hip04 ethernet driver Zhangfei Gao
2014-04-19  1:12 ` Zhangfei Gao
2014-04-19  1:12 ` [PATCH v8 1/3] Documentation: add Device tree bindings for Hisilicon hip04 ethernet Zhangfei Gao
2014-04-19  1:12   ` Zhangfei Gao
2014-04-19  1:12 ` [PATCH v8 2/3] net: hisilicon: new hip04 MDIO driver Zhangfei Gao
2014-04-19  1:12   ` Zhangfei Gao
2014-04-21 17:58   ` Sergei Shtylyov [this message]
2014-04-21 17:58     ` Sergei Shtylyov
2014-04-21 18:03     ` Florian Fainelli
2014-04-21 18:03       ` Florian Fainelli
2014-04-21 18:21       ` Sergei Shtylyov
2014-04-21 18:21         ` Sergei Shtylyov
2014-04-22  6:03         ` zhangfei
2014-04-22  6:03           ` zhangfei
2014-04-22  8:22           ` Arnd Bergmann
2014-04-22  8:22             ` Arnd Bergmann
2014-04-22 14:16             ` zhangfei
2014-04-22 14:16               ` zhangfei
2014-04-22 14:30               ` Arnd Bergmann
2014-04-22 14:30                 ` Arnd Bergmann
2014-04-22 14:58                 ` zhangfei
2014-04-22 14:58                   ` zhangfei
2014-04-24 12:28                   ` Arnd Bergmann
2014-04-24 12:28                     ` Arnd Bergmann
2014-04-24 13:00                     ` zhangfei
2014-04-24 13:00                       ` zhangfei
2014-04-19  1:13 ` [PATCH v8 3/3] net: hisilicon: new hip04 ethernet driver Zhangfei Gao
2014-04-19  1:13   ` Zhangfei Gao
2014-12-07  0:42   ` Alexander Graf
2014-12-07  0:42     ` Alexander Graf
2014-12-07  3:28     ` Ding Tianhong
2014-12-07  3:28       ` Ding Tianhong
2014-12-07  3:28       ` Ding Tianhong
2014-12-07  9:49       ` Alexander Graf
2014-12-07  9:49         ` Alexander Graf
2014-12-07 20:09         ` Arnd Bergmann
2014-12-07 20:09           ` Arnd Bergmann
2014-12-08  1:48           ` Ding Tianhong
2014-12-08  1:48             ` Ding Tianhong
2014-12-10  3:51           ` Ding Tianhong
2014-12-10  3:51             ` Ding Tianhong
2014-12-10  3:51             ` Ding Tianhong
2014-12-10  6:45             ` Ding Tianhong
2014-12-10  6:45               ` Ding Tianhong
2014-12-10  6:45               ` Ding Tianhong
2014-12-10  9:35               ` Arnd Bergmann
2014-12-10  9:35                 ` Arnd Bergmann
2014-12-10 16:07                 ` David Miller
2014-12-10 16:07                   ` David Miller
2014-12-10 16:36                   ` Arnd Bergmann
2014-12-10 16:36                     ` Arnd Bergmann
2014-12-10 17:02                     ` David Miller
2014-12-10 17:02                       ` David Miller

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=53555C28.4050303@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.