* [PATCH] net: macb: initialize is_gem before usage
@ 2013-03-13 10:58 Steffen Trumtrar
2013-03-13 15:39 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 2+ messages in thread
From: Steffen Trumtrar @ 2013-03-13 10:58 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
The variable macb->is_gem is evaluated before it is initialized.
That leads to a wrong rx_buffer setup in the gem case. Also, the
function gem_recv will never be used.
Set the variable first and then use it.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
drivers/net/macb.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0cfad05..30e8476 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -619,11 +619,6 @@ static int macb_probe(struct device_d *dev)
macb->phy_flags = pdata->phy_flags;
- macb_init_rx_buffer_size(macb, PKTSIZE);
- macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size);
- macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
- macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
-
macb->regs = dev_request_mem_region(dev, 0);
/*
@@ -638,11 +633,17 @@ static int macb_probe(struct device_d *dev)
clk_enable(macb->pclk);
+ macb->is_gem = read_is_gem(macb);
+
+ macb_init_rx_buffer_size(macb, PKTSIZE);
+ macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size);
+ macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
+ macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
+
if (macb_is_gem(macb))
edev->recv = gem_recv;
else
edev->recv = macb_recv;
- macb->is_gem = read_is_gem(macb);
macb_reset_hw(macb);
ncfgr = macb_mdc_clk_div(macb);
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: macb: initialize is_gem before usage
2013-03-13 10:58 [PATCH] net: macb: initialize is_gem before usage Steffen Trumtrar
@ 2013-03-13 15:39 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-03-13 15:39 UTC (permalink / raw)
To: Steffen Trumtrar; +Cc: barebox
On 11:58 Wed 13 Mar , Steffen Trumtrar wrote:
> The variable macb->is_gem is evaluated before it is initialized.
> That leads to a wrong rx_buffer setup in the gem case. Also, the
> function gem_recv will never be used.
>
> Set the variable first and then use it.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> drivers/net/macb.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 0cfad05..30e8476 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -619,11 +619,6 @@ static int macb_probe(struct device_d *dev)
>
> macb->phy_flags = pdata->phy_flags;
>
> - macb_init_rx_buffer_size(macb, PKTSIZE);
> - macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size);
> - macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> - macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
> -
> macb->regs = dev_request_mem_region(dev, 0);
>
> /*
> @@ -638,11 +633,17 @@ static int macb_probe(struct device_d *dev)
>
> clk_enable(macb->pclk);
>
> + macb->is_gem = read_is_gem(macb);
> +
> + macb_init_rx_buffer_size(macb, PKTSIZE);
> + macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size);
> + macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb));
> + macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES);
> +
I check you need to update the gem_recv at the same time otherwise this brake
the sama5 support
Best Regards,
J.
> if (macb_is_gem(macb))
> edev->recv = gem_recv;
> else
> edev->recv = macb_recv;
> - macb->is_gem = read_is_gem(macb);
>
> macb_reset_hw(macb);
> ncfgr = macb_mdc_clk_div(macb);
> --
> 1.8.2.rc2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-13 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-13 10:58 [PATCH] net: macb: initialize is_gem before usage Steffen Trumtrar
2013-03-13 15:39 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox