linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: davinci_mdio: Set of_node in the mdio bus
@ 2016-04-25 14:46 J.D. Schroeder
  2016-04-28 19:44 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: J.D. Schroeder @ 2016-04-25 14:46 UTC (permalink / raw)
  To: linux-kernel, netdev, davem, Grygorii.Strashko
  Cc: J.D. Schroeder, Ben McCauley

From: "J.D. Schroeder" <jay.schroeder@garmin.com>

Assigns the of_node from the platform device to the of_node of the
mdio bus so that it can be used in the mdio driver to properly match
a bus in the DT with a phandle in of_mdio_find_bus().

Signed-off-by: J.D. Schroeder <jay.schroeder@garmin.com>
Signed-off-by: Ben McCauley <ben.mccauley@garmin.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 4e7c9b9..b5e5f37 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -343,6 +343,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 		if (davinci_mdio_probe_dt(&data->pdata, pdev))
 			data->pdata = default_pdata;
 		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
+		data->bus->dev.of_node = dev->of_node;
 	} else {
 		data->pdata = pdata ? (*pdata) : default_pdata;
 		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: davinci_mdio: Set of_node in the mdio bus
  2016-04-25 14:46 [PATCH] net: davinci_mdio: Set of_node in the mdio bus J.D. Schroeder
@ 2016-04-28 19:44 ` David Miller
  2016-04-28 21:39   ` J.D. Schroeder
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2016-04-28 19:44 UTC (permalink / raw)
  To: Linux.HWI
  Cc: linux-kernel, netdev, Grygorii.Strashko, jay.schroeder, ben.mccauley

From: "J.D. Schroeder" <Linux.HWI@garmin.com>
Date: Mon, 25 Apr 2016 09:46:11 -0500

> From: "J.D. Schroeder" <jay.schroeder@garmin.com>
> 
> Assigns the of_node from the platform device to the of_node of the
> mdio bus so that it can be used in the mdio driver to properly match
> a bus in the DT with a phandle in of_mdio_find_bus().
> 
> Signed-off-by: J.D. Schroeder <jay.schroeder@garmin.com>
> Signed-off-by: Ben McCauley <ben.mccauley@garmin.com>
> ---
>  drivers/net/ethernet/ti/davinci_mdio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index 4e7c9b9..b5e5f37 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -343,6 +343,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>  		if (davinci_mdio_probe_dt(&data->pdata, pdev))
>  			data->pdata = default_pdata;
>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
> +		data->bus->dev.of_node = dev->of_node;
>  	} else {
>  		data->pdata = pdata ? (*pdata) : default_pdata;
>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",

You can't do this.

First of all, of_node objects are reference counted.  So even if this was a
legal thing to do you would have to drop the reference to the existing of_node
pointer and gain a reference to dev->of_node.

But even more importantly, it is the job of the bus driver to set that
bus->dev.of_node correctly, you should never override it in a driver like
this.

I'm not applying this, sorry.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: davinci_mdio: Set of_node in the mdio bus
  2016-04-28 19:44 ` David Miller
@ 2016-04-28 21:39   ` J.D. Schroeder
  2016-04-28 21:48     ` David Miller
  2016-04-28 23:19     ` Andrew Lunn
  0 siblings, 2 replies; 5+ messages in thread
From: J.D. Schroeder @ 2016-04-28 21:39 UTC (permalink / raw)
  To: David Miller
  Cc: linux-kernel, netdev, Grygorii.Strashko, jay.schroeder, ben.mccauley

On 04/28/2016 02:44 PM, David Miller wrote:
>> --- a/drivers/net/ethernet/ti/davinci_mdio.c
>> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
>> @@ -343,6 +343,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>>  		if (davinci_mdio_probe_dt(&data->pdata, pdev))
>>  			data->pdata = default_pdata;
>>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
>> +		data->bus->dev.of_node = dev->of_node;
>>  	} else {
>>  		data->pdata = pdata ? (*pdata) : default_pdata;
>>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
> 
> You can't do this.
> 
> First of all, of_node objects are reference counted.  So even if this was a
> legal thing to do you would have to drop the reference to the existing of_node
> pointer and gain a reference to dev->of_node.
> 
> But even more importantly, it is the job of the bus driver to set that
> bus->dev.of_node correctly, you should never override it in a driver like
> this.

David, thanks for your review. I understand your point about the reference count.

One thing to note is that it is always null for the davinci mdio bus when
going through this path. I'm not trying to override it. I'm trying to make
sure it has a way to find the davinci mdio bus. Do you see the problem I'm
trying to solve?

Is there another way to be able to make the of_mdio_find_bus() call be able to
find the davinci mdio bus?

Thanks,
JD

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: davinci_mdio: Set of_node in the mdio bus
  2016-04-28 21:39   ` J.D. Schroeder
@ 2016-04-28 21:48     ` David Miller
  2016-04-28 23:19     ` Andrew Lunn
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2016-04-28 21:48 UTC (permalink / raw)
  To: Linux.HWI
  Cc: linux-kernel, netdev, Grygorii.Strashko, jay.schroeder, ben.mccauley

From: "J.D. Schroeder" <Linux.HWI@garmin.com>
Date: Thu, 28 Apr 2016 16:39:36 -0500

> On 04/28/2016 02:44 PM, David Miller wrote:
>>> --- a/drivers/net/ethernet/ti/davinci_mdio.c
>>> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
>>> @@ -343,6 +343,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>>>  		if (davinci_mdio_probe_dt(&data->pdata, pdev))
>>>  			data->pdata = default_pdata;
>>>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name);
>>> +		data->bus->dev.of_node = dev->of_node;
>>>  	} else {
>>>  		data->pdata = pdata ? (*pdata) : default_pdata;
>>>  		snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
>> 
>> You can't do this.
>> 
>> First of all, of_node objects are reference counted.  So even if this was a
>> legal thing to do you would have to drop the reference to the existing of_node
>> pointer and gain a reference to dev->of_node.
>> 
>> But even more importantly, it is the job of the bus driver to set that
>> bus->dev.of_node correctly, you should never override it in a driver like
>> this.
> 
> David, thanks for your review. I understand your point about the reference count.
> 
> One thing to note is that it is always null for the davinci mdio bus when
> going through this path. I'm not trying to override it. I'm trying to make
> sure it has a way to find the davinci mdio bus. Do you see the problem I'm
> trying to solve?
> 
> Is there another way to be able to make the of_mdio_find_bus() call be able to
> find the davinci mdio bus?

You should reference the device which actually has an OF node attached with it,
rather than pretending that the MDIO bus does.

Don't fake this stuff, reference the proper device to get the OF node.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: davinci_mdio: Set of_node in the mdio bus
  2016-04-28 21:39   ` J.D. Schroeder
  2016-04-28 21:48     ` David Miller
@ 2016-04-28 23:19     ` Andrew Lunn
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2016-04-28 23:19 UTC (permalink / raw)
  To: J.D. Schroeder
  Cc: David Miller, linux-kernel, netdev, Grygorii.Strashko,
	jay.schroeder, ben.mccauley

> Is there another way to be able to make the of_mdio_find_bus() call be able to
> find the davinci mdio bus?

I missed the first post, and i cannot find it in the archive. Can you
explain what your problem is please.

So long as you call of_mdiobus_register() passing the correct device
node, it should all work.

      Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-28 23:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 14:46 [PATCH] net: davinci_mdio: Set of_node in the mdio bus J.D. Schroeder
2016-04-28 19:44 ` David Miller
2016-04-28 21:39   ` J.D. Schroeder
2016-04-28 21:48     ` David Miller
2016-04-28 23:19     ` Andrew Lunn

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).