netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Johan Hovold <johan@kernel.org>, Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 8/9] net: phy: micrel: clean up led-mode setup
Date: Wed, 12 Nov 2014 00:41:31 +0300	[thread overview]
Message-ID: <5462828B.8090303@cogentembedded.com> (raw)
In-Reply-To: <1415732415-10363-9-git-send-email-johan@kernel.org>

Hello.

On 11/11/2014 10:00 PM, Johan Hovold wrote:

> Clean up led-mode setup by introducing proper defines for PHY Control
> registers 1 and 2 and only passing the register to the setup function.

    Not sure that's really better that it was before (modulo naming).

> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>   drivers/net/phy/micrel.c | 31 ++++++++++++++++++++++---------
>   1 file changed, 22 insertions(+), 9 deletions(-)

> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index ec9ce35e934b..12e18f7273ce 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -47,8 +47,12 @@
>   #define	KSZPHY_INTCS_ALL			(KSZPHY_INTCS_LINK_UP |\
>   						KSZPHY_INTCS_LINK_DOWN)
>
> -/* general PHY control reg in vendor specific block. */
> -#define	MII_KSZPHY_CTRL			0x1F
> +/* PHY Control 1 */
> +#define	MII_KSZPHY_CTRL_1			0x1e
> +
> +/* PHY Control 2 / PHY Control (if no PHY Control 1) */
> +#define	MII_KSZPHY_CTRL_2			0x1f
> +#define	MII_KSZPHY_CTRL				MII_KSZPHY_CTRL_2
>   /* bitmap of PHY register to set interrupt mode */
>   #define KSZPHY_CTRL_INT_ACTIVE_HIGH		BIT(9)
>   #define KSZ9021_CTRL_INT_ACTIVE_HIGH		BIT(14)
> @@ -158,13 +162,12 @@ static int ks8737_config_intr(struct phy_device *phydev)
>   	return rc < 0 ? rc : 0;
>   }
>
> -static int kszphy_setup_led(struct phy_device *phydev,
> -			    unsigned int reg, unsigned int shift)
> +static int kszphy_setup_led(struct phy_device *phydev, u32 reg)
>   {
>
>   	struct device *dev = &phydev->dev;
>   	struct device_node *of_node = dev->of_node;
> -	int rc, temp;
> +	int rc, temp, shift;
>   	u32 val;
>
>   	if (!of_node && dev->parent->of_node)
> @@ -178,6 +181,17 @@ static int kszphy_setup_led(struct phy_device *phydev,
>   		return -EINVAL;
>   	}
>
> +	switch (reg) {
> +	case MII_KSZPHY_CTRL_1:
> +		shift = 14;
> +		break;
> +	case MII_KSZPHY_CTRL_2:
> +		shift = 4;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
>   	temp = phy_read(phydev, reg);
>   	if (temp < 0) {
>   		rc = temp;
> @@ -220,15 +234,14 @@ static int kszphy_config_init(struct phy_device *phydev)
>
>   static int kszphy_config_init_led8041(struct phy_device *phydev)
>   {
> -	/* single led control, register 0x1e bits 15..14 */
> -	return kszphy_setup_led(phydev, 0x1e, 14);
> +	return kszphy_setup_led(phydev, MII_KSZPHY_CTRL_1);
>   }
>
>   static int ksz8021_config_init(struct phy_device *phydev)
>   {
>   	int rc;
>
> -	kszphy_setup_led(phydev, 0x1f, 4);
> +	kszphy_setup_led(phydev, MII_KSZPHY_CTRL_2);
>
>   	rc = ksz_config_flags(phydev);
>   	if (rc < 0)
> @@ -243,7 +256,7 @@ static int ks8051_config_init(struct phy_device *phydev)
>   {
>   	int rc;
>
> -	kszphy_setup_led(phydev, 0x1f, 4);
> +	kszphy_setup_led(phydev, MII_KSZPHY_CTRL_2);
>
>   	rc = ksz_config_flags(phydev);
>   	return rc < 0 ? rc : 0;

WBR, Sergei

  reply	other threads:[~2014-11-11 21:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-11 19:00 [PATCH 0/9] net: phy: micrel: refactoring and KSZ8081/KSZ8091 features Johan Hovold
2014-11-11 19:00 ` [PATCH 1/9] dt/bindings: fix documentation of ethernet-phy compatible property Johan Hovold
2014-11-11 19:00 ` [PATCH 2/9] net: phy: micrel: fix config_intr error handling Johan Hovold
2014-11-11 19:00 ` [PATCH 3/9] net: phy: micrel: use BIT macro Johan Hovold
2014-11-11 19:00 ` [PATCH 4/9] net: phy: micrel: refactor broadcast disable Johan Hovold
2014-11-11 19:00 ` [PATCH 5/9] net: phy: micrel: disable broadcast for KSZ8081/KSZ8091 Johan Hovold
2014-11-11 19:00 ` [PATCH 6/9] net: phy: micrel: add led-mode sanity check Johan Hovold
2014-11-11 19:00 ` [PATCH 7/9] net: phy: micrel: refactor led-mode error handling Johan Hovold
2014-11-11 19:00 ` [PATCH 8/9] net: phy: micrel: clean up led-mode setup Johan Hovold
2014-11-11 21:41   ` Sergei Shtylyov [this message]
2014-11-11 21:43     ` Florian Fainelli
2014-11-12  9:29       ` Johan Hovold
2014-11-11 19:00 ` [PATCH 9/9] net: phy: micrel: enable led-mode for KSZ8081/KSZ8091 Johan Hovold
2014-11-12 18:56 ` [PATCH 0/9] net: phy: micrel: refactoring and KSZ8081/KSZ8091 features 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=5462828B.8090303@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).