[PATCH] gianfar: prevent resource conflict
Renaud Barbier
renaud.barbier at ge.com
Mon Jun 3 05:31:50 EDT 2013
>> ---
>> drivers/net/gianfar.c | 19 ++++++++++++++++++-
>> 1 files changed, 18 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
>> index 96055bd..79113a8 100644
>> --- a/drivers/net/gianfar.c
>> +++ b/drivers/net/gianfar.c
>> @@ -28,6 +28,8 @@
>> #define RX_BUF_CNT PKTBUFSRX
>> #define BUF_ALIGN 8
>>
>> +static void __iomem *phyregs;
>> +
>> /*
>> * Initialize required registers to appropriate values, zeroing
>> * those we don't care about (unless zero is bad, in which case,
>> @@ -481,8 +483,23 @@ static int gfar_probe(struct device_d *dev)
>> edev = &priv->edev;
>>
>> priv->regs = dev_request_mem_region(dev, 0);
>> - priv->phyregs = dev_request_mem_region(dev, 1);
>> + if (priv->regs == NULL)
>> + priv->regs = phyregs;
>
> the first resource is for the ethernet registers and no phy registers,
> right?
Indeed
>
>> +
>> + if (phyregs == NULL) {
>> + phyregs = dev_request_mem_region(dev, 1);
>> + if (phyregs == NULL)
>> + phyregs = priv->regs;
>> + }
>> + priv->phyregs = phyregs;
>> +
>> priv->phyregs_sgmii = dev_request_mem_region(dev, 2);
>> + if (priv->phyregs_sgmii == NULL) {
>> + if (IS_ENABLED(CONFIG_TSECV2))
>> + priv->phyregs_sgmii = priv->phyregs;
>> + else
>> + priv->phyregs_sgmii = priv->regs;
>> + }
>
> I think you should really register the mdio buses as separate devices
> since it's the mdio buses that are shared between the different
> instances, not the registers. The following may be a starting point
> (untested)
>
Thanks.
More information about the barebox
mailing list