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.wall...@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 <and...@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