netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH] net: phy: fixed-phy: Drop GPIO from fixed_phy_add()
Date: Tue, 15 Jan 2019 02:46:04 +0100	[thread overview]
Message-ID: <20190115014604.GC8882@lunn.ch> (raw)
In-Reply-To: <20190114080225.3805-1-linus.walleij@linaro.org>

On Mon, Jan 14, 2019 at 09:02:25AM +0100, Linus Walleij wrote:
> All users of the fixed_phy_add() pass -1 as GPIO number
> to the fixed phy driver, and all users of fixed_phy_register()
> pass -1 as GPIO number as well, except for the device
> tree MDIO bus.
> 
> Any new users should create a proper device and pass the
> GPIO as a descriptor associated with the device so delete
> the GPIO argument from the calls and drop the code looking
> requesting a GPIO in fixed_phy_add().
> 
> In fixed phy_register(), investigate the "fixed-link"
> node and pick the GPIO descriptor from "link-gpios" if
> this property exists. Move the corresponding code out
> of of_mdio.c as the fixed phy code anyways requires
> OF to be in use.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Hi Linus

I tested on the zii-devel-b, which i think is the only mainline board
using a GPIO. So

Tested-by: Andrew Lunn <andrew@lunn.ch>

> +int fixed_phy_add(unsigned int irq, int phy_addr,
> +		  struct fixed_phy_status *status) {
> +	return fixed_phy_add_gpiod(irq, phy_addr, status, NULL);
>  }

This seems like the sort of wrapper function which could go in the
header file. At lease please add a blank line.

> +#ifdef CONFIG_OF_GPIO
> +static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
> +{
> +	struct device_node *fixed_link_node;
> +	struct gpio_desc *gpiod;
> +
> +	if (!np)
> +		return NULL;
> +
> +	fixed_link_node = of_get_child_by_name(np, "fixed-link");
> +	if (!fixed_link_node)
> +		return NULL;
> +
> +	/*
> +	 * As the fixed link is just a device tree node without any
> +	 * Linux device associated with it, we simply have to rip out
> +	 * the GPIO descriptor from the device tree like this.

I don't really like the "rip it out". It makes it sound like the
binding is doing something wrong. It is not. Switches are complex
devices and need a complex binding to describe the hardware.

> +	 */
> +	gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
> +				       GPIOD_IN, "mdio");
> +	of_node_put(fixed_link_node);
> +	if (IS_ERR(gpiod)) {
> +		/* Just return and bail on deferrals */
> +		if (PTR_ERR(gpiod) == -EPROBE_DEFER)
> +			return gpiod;

I'm not sure the comment is adding much here. This is pretty much
normal handling of EPROBE_DEFER.

> +		pr_err("error getting GPIO for fixed link, proceed without\n");

It would be nice to use %pOF to print fixed_link_node. There can be
multiple fixed_link devices and knowing which one failed could be
useful.

Thanks
	Andrew

  parent reply	other threads:[~2019-01-15  1:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14  8:02 [PATCH] net: phy: fixed-phy: Drop GPIO from fixed_phy_add() Linus Walleij
2019-01-14 14:15 ` Andrew Lunn
2019-01-15  1:46 ` Andrew Lunn [this message]
2019-01-15  1:48 ` Andrew Lunn

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=20190115014604.GC8882@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.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).