net: mdio-gpio: Allow for unspecified bus id
authorBert Vermeulen <bert@biot.com>
Fri, 8 May 2015 14:18:49 +0000 (16:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 10 May 2015 23:42:11 +0000 (19:42 -0400)
When the bus id was supplied via a struct platform_device, the driver wasn't
handling -1 to mean an unspecified id of the only instance of this driver,
as the platform spec requires.

Signed-off-by: Bert Vermeulen <bert@biot.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio-gpio.c

index c9cb486c753d053c8b6da529a0c078d89f9c2a2f..53d18150f4e291bb4bb047a18a9877d3a82a08f4 100644 (file)
@@ -168,7 +168,10 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
                if (!new_bus->irq[i])
                        new_bus->irq[i] = PHY_POLL;
 
-       snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
+       if (bus_id != -1)
+               snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
+       else
+               strncpy(new_bus->id, "gpio", MII_BUS_ID_SIZE);
 
        if (devm_gpio_request(dev, bitbang->mdc, "mdc"))
                goto out_free_bus;