* [PATCH] net: mdio-gpio: Allow for unspecified bus id
@ 2015-05-08 14:18 Bert Vermeulen
2015-05-08 15:48 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Bert Vermeulen @ 2015-05-08 14:18 UTC (permalink / raw)
To: f.fainelli, netdev, linux-kernel; +Cc: Bert Vermeulen
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>
---
drivers/net/phy/mdio-gpio.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index f5cddf5..7bd90db 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -165,7 +165,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;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id
2015-05-08 14:18 [PATCH] net: mdio-gpio: Allow for unspecified bus id Bert Vermeulen
@ 2015-05-08 15:48 ` Andrew Lunn
2015-05-08 16:01 ` Bert Vermeulen
2015-05-08 16:49 ` Andrew Lunn
2015-05-10 23:42 ` David Miller
2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2015-05-08 15:48 UTC (permalink / raw)
To: Bert Vermeulen; +Cc: f.fainelli, netdev, linux-kernel
On Fri, May 08, 2015 at 04:18:49PM +0200, Bert Vermeulen wrote:
> 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>
> ---
> drivers/net/phy/mdio-gpio.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
> index f5cddf5..7bd90db 100644
> --- a/drivers/net/phy/mdio-gpio.c
> +++ b/drivers/net/phy/mdio-gpio.c
> @@ -165,7 +165,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);
Hi Bert
What happens if there are multiple platform_device's with -1? You
should probably be using use idr_alloc().
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id
2015-05-08 15:48 ` Andrew Lunn
@ 2015-05-08 16:01 ` Bert Vermeulen
2015-05-08 16:46 ` Andrew Lunn
0 siblings, 1 reply; 6+ messages in thread
From: Bert Vermeulen @ 2015-05-08 16:01 UTC (permalink / raw)
To: Andrew Lunn; +Cc: f.fainelli, netdev, linux-kernel
On 05/08/2015 05:48 PM, Andrew Lunn wrote:
> On Fri, May 08, 2015 at 04:18:49PM +0200, Bert Vermeulen wrote:
>> 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>
>> ---
>> drivers/net/phy/mdio-gpio.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
>> index f5cddf5..7bd90db 100644
>> --- a/drivers/net/phy/mdio-gpio.c
>> +++ b/drivers/net/phy/mdio-gpio.c
>> @@ -165,7 +165,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);
>
> Hi Bert
>
> What happens if there are multiple platform_device's with -1? You
> should probably be using use idr_alloc().
It's an instance id per driver, not globally, and -1 specifically means it's
the only instance. From Documentation/driver-model/platform.txt:
> These are concatenated, so name/id "serial"/0 indicates bus_id "serial.0", and
> "serial/3" indicates bus_id "serial.3"; both would use the platform_driver
> named "serial". While "my_rtc"/-1 would be bus_id "my_rtc" (no instance id)
> and use the platform_driver called "my_rtc".
--
Bert Vermeulen bert@biot.com email/xmpp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id
2015-05-08 16:01 ` Bert Vermeulen
@ 2015-05-08 16:46 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-05-08 16:46 UTC (permalink / raw)
To: Bert Vermeulen; +Cc: f.fainelli, netdev, linux-kernel
> >> - 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);
> >
> > Hi Bert
> >
> > What happens if there are multiple platform_device's with -1? You
> > should probably be using use idr_alloc().
>
> It's an instance id per driver, not globally, and -1 specifically means it's
> the only instance. From Documentation/driver-model/platform.txt:
Ah, did not know there can only be one with -1. I've used i2c where
this does not apply when registering adaptors. It will allocate a
unique id to each added with id = -1.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id
2015-05-08 14:18 [PATCH] net: mdio-gpio: Allow for unspecified bus id Bert Vermeulen
2015-05-08 15:48 ` Andrew Lunn
@ 2015-05-08 16:49 ` Andrew Lunn
2015-05-10 23:42 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2015-05-08 16:49 UTC (permalink / raw)
To: Bert Vermeulen; +Cc: f.fainelli, netdev, linux-kernel
On Fri, May 08, 2015 at 04:18:49PM +0200, Bert Vermeulen wrote:
> 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>
> ---
> drivers/net/phy/mdio-gpio.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
> index f5cddf5..7bd90db 100644
> --- a/drivers/net/phy/mdio-gpio.c
> +++ b/drivers/net/phy/mdio-gpio.c
> @@ -165,7 +165,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;
> --
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: mdio-gpio: Allow for unspecified bus id
2015-05-08 14:18 [PATCH] net: mdio-gpio: Allow for unspecified bus id Bert Vermeulen
2015-05-08 15:48 ` Andrew Lunn
2015-05-08 16:49 ` Andrew Lunn
@ 2015-05-10 23:42 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-05-10 23:42 UTC (permalink / raw)
To: bert; +Cc: f.fainelli, netdev, linux-kernel
From: Bert Vermeulen <bert@biot.com>
Date: Fri, 8 May 2015 16:18:49 +0200
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-05-10 23:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 14:18 [PATCH] net: mdio-gpio: Allow for unspecified bus id Bert Vermeulen
2015-05-08 15:48 ` Andrew Lunn
2015-05-08 16:01 ` Bert Vermeulen
2015-05-08 16:46 ` Andrew Lunn
2015-05-08 16:49 ` Andrew Lunn
2015-05-10 23:42 ` David Miller
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).