linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] net: mediatek: use dma_addr_t correctly
@ 2016-03-14 14:07 Arnd Bergmann
  2016-03-14 14:07 ` [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-03-14 14:07 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Felix Fietkau, John Crispin, Matthias Brugger,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel

dma_alloc_coherent() expects a dma_addr_t pointer as its argument,
not an 'unsigned int', and gcc correctly warns about broken
code in the mtk_init_fq_dma function:

drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_init_fq_dma':
drivers/net/ethernet/mediatek/mtk_eth_soc.c:463:13: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types]

This changes the type of the local variable to dma_addr_t.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index ba3afa5d4640..3e42204adfe5 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -453,7 +453,7 @@ static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd,
 /* the qdma core needs scratch memory to be setup */
 static int mtk_init_fq_dma(struct mtk_eth *eth)
 {
-	unsigned int phy_ring_head, phy_ring_tail;
+	dma_addr_t phy_ring_head, phy_ring_tail;
 	int cnt = MTK_DMA_SIZE;
 	dma_addr_t dma_addr;
 	int i;
-- 
2.7.0

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

* [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment
  2016-03-14 14:07 [PATCH 1/3] net: mediatek: use dma_addr_t correctly Arnd Bergmann
@ 2016-03-14 14:07 ` Arnd Bergmann
  2016-03-14 17:06   ` David Miller
  2016-03-14 14:07 ` [PATCH 3/3] net: mediatek: check device_reset return code Arnd Bergmann
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2016-03-14 14:07 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Felix Fietkau, John Crispin, Matthias Brugger,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel

Device drivers should not mess with the DMA mask directly,
but instead call dma_set_mask() etc if needed.

In case of the mtk_eth_soc driver, the mask already gets set
correctly when the device is created, and setting it again
is against the documented API.

This removes the incorrect setting.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 3e42204adfe5..87f417712da0 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1676,9 +1676,6 @@ static int mtk_probe(struct platform_device *pdev)
 	struct mtk_eth *eth;
 	int err;
 
-	pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
-	pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
-
 	device_reset(&pdev->dev);
 
 	match = of_match_device(of_mtk_match, &pdev->dev);
-- 
2.7.0

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

* [PATCH 3/3] net: mediatek: check device_reset return code
  2016-03-14 14:07 [PATCH 1/3] net: mediatek: use dma_addr_t correctly Arnd Bergmann
  2016-03-14 14:07 ` [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment Arnd Bergmann
@ 2016-03-14 14:07 ` Arnd Bergmann
  2016-03-14 17:06   ` David Miller
  2016-03-14 17:06 ` [PATCH 1/3] net: mediatek: use dma_addr_t correctly David Miller
  2016-03-14 18:01 ` John Crispin
  3 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2016-03-14 14:07 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Felix Fietkau, John Crispin, Matthias Brugger,
	netdev, linux-arm-kernel, linux-mediatek, linux-kernel

The device_reset() function may fail, so we have to check
its return value, e.g. to make deferred probing work correctly.
gcc warns about it because of the warn_unused_result attribute:

drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_probe':
drivers/net/ethernet/mediatek/mtk_eth_soc.c:1679:2: error: ignoring return value of 'device_reset', declared with attribute warn_unused_result [-Werror=unused-result]

This adds the trivial error check to propagate the return value
to the generic platform device probe code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 87f417712da0..1e6c5498bba9 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1676,7 +1676,9 @@ static int mtk_probe(struct platform_device *pdev)
 	struct mtk_eth *eth;
 	int err;
 
-	device_reset(&pdev->dev);
+	err = device_reset(&pdev->dev);
+	if (err)
+		return err;
 
 	match = of_match_device(of_mtk_match, &pdev->dev);
 	soc = (struct mtk_soc_data *)match->data;
-- 
2.7.0

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

* Re: [PATCH 1/3] net: mediatek: use dma_addr_t correctly
  2016-03-14 14:07 [PATCH 1/3] net: mediatek: use dma_addr_t correctly Arnd Bergmann
  2016-03-14 14:07 ` [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment Arnd Bergmann
  2016-03-14 14:07 ` [PATCH 3/3] net: mediatek: check device_reset return code Arnd Bergmann
@ 2016-03-14 17:06 ` David Miller
  2016-03-14 18:01 ` John Crispin
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-03-14 17:06 UTC (permalink / raw)
  To: arnd
  Cc: nbd, blogic, matthias.bgg, netdev, linux-arm-kernel,
	linux-mediatek, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 14 Mar 2016 15:07:10 +0100

> dma_alloc_coherent() expects a dma_addr_t pointer as its argument,
> not an 'unsigned int', and gcc correctly warns about broken
> code in the mtk_init_fq_dma function:
> 
> drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_init_fq_dma':
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:463:13: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types]
> 
> This changes the type of the local variable to dma_addr_t.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

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

* Re: [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment
  2016-03-14 14:07 ` [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment Arnd Bergmann
@ 2016-03-14 17:06   ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-03-14 17:06 UTC (permalink / raw)
  To: arnd
  Cc: nbd, blogic, matthias.bgg, netdev, linux-arm-kernel,
	linux-mediatek, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 14 Mar 2016 15:07:11 +0100

> Device drivers should not mess with the DMA mask directly,
> but instead call dma_set_mask() etc if needed.
> 
> In case of the mtk_eth_soc driver, the mask already gets set
> correctly when the device is created, and setting it again
> is against the documented API.
> 
> This removes the incorrect setting.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

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

* Re: [PATCH 3/3] net: mediatek: check device_reset return code
  2016-03-14 14:07 ` [PATCH 3/3] net: mediatek: check device_reset return code Arnd Bergmann
@ 2016-03-14 17:06   ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-03-14 17:06 UTC (permalink / raw)
  To: arnd
  Cc: nbd, blogic, matthias.bgg, netdev, linux-arm-kernel,
	linux-mediatek, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 14 Mar 2016 15:07:12 +0100

> The device_reset() function may fail, so we have to check
> its return value, e.g. to make deferred probing work correctly.
> gcc warns about it because of the warn_unused_result attribute:
> 
> drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_probe':
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:1679:2: error: ignoring return value of 'device_reset', declared with attribute warn_unused_result [-Werror=unused-result]
> 
> This adds the trivial error check to propagate the return value
> to the generic platform device probe code.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

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

* Re: [PATCH 1/3] net: mediatek: use dma_addr_t correctly
  2016-03-14 14:07 [PATCH 1/3] net: mediatek: use dma_addr_t correctly Arnd Bergmann
                   ` (2 preceding siblings ...)
  2016-03-14 17:06 ` [PATCH 1/3] net: mediatek: use dma_addr_t correctly David Miller
@ 2016-03-14 18:01 ` John Crispin
  3 siblings, 0 replies; 7+ messages in thread
From: John Crispin @ 2016-03-14 18:01 UTC (permalink / raw)
  To: Arnd Bergmann, David S. Miller
  Cc: Felix Fietkau, netdev, linux-kernel, linux-mediatek,
	Matthias Brugger, linux-arm-kernel



On 14/03/2016 15:07, Arnd Bergmann wrote:
> dma_alloc_coherent() expects a dma_addr_t pointer as its argument,
> not an 'unsigned int', and gcc correctly warns about broken
> code in the mtk_init_fq_dma function:
> 
> drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_init_fq_dma':
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:463:13: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types]
> 
> This changes the type of the local variable to dma_addr_t.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

thanks for the fixes



> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index ba3afa5d4640..3e42204adfe5 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -453,7 +453,7 @@ static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd,
>  /* the qdma core needs scratch memory to be setup */
>  static int mtk_init_fq_dma(struct mtk_eth *eth)
>  {
> -	unsigned int phy_ring_head, phy_ring_tail;
> +	dma_addr_t phy_ring_head, phy_ring_tail;
>  	int cnt = MTK_DMA_SIZE;
>  	dma_addr_t dma_addr;
>  	int i;
> 

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

end of thread, other threads:[~2016-03-14 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-14 14:07 [PATCH 1/3] net: mediatek: use dma_addr_t correctly Arnd Bergmann
2016-03-14 14:07 ` [PATCH 2/3] net: mediatek: remove incorrect dma_mask assignment Arnd Bergmann
2016-03-14 17:06   ` David Miller
2016-03-14 14:07 ` [PATCH 3/3] net: mediatek: check device_reset return code Arnd Bergmann
2016-03-14 17:06   ` David Miller
2016-03-14 17:06 ` [PATCH 1/3] net: mediatek: use dma_addr_t correctly David Miller
2016-03-14 18:01 ` John Crispin

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