Altera TSE: Fix Sparse errors and Cppcheck warnings
Subsystems (3)
PATCH 1/1 Altera TSE: Fix Sparse errors and Cppcheck warnings
This patch addresses sparse errors and warnings and a few cppcheck warnings.
If you find this patch acceptable, please consider this for inclusion into the Altera TSE driver source code.
Thank you
Vince
Vince Bridgers (1):
Altera TSE: Fix sparse errors and warnings
drivers/net/ethernet/altera/Makefile | 1 + drivers/net/ethernet/altera/altera_msgdma.c | 110 ++++++------- drivers/net/ethernet/altera/altera_msgdmahw.h | 13 +- drivers/net/ethernet/altera/altera_sgdma.c | 181 +++++++++++----------- drivers/net/ethernet/altera/altera_sgdmahw.h | 26 ++-- drivers/net/ethernet/altera/altera_tse.h | 47 ++++++ drivers/net/ethernet/altera/altera_tse_ethtool.c | 108 ++++++++----- drivers/net/ethernet/altera/altera_tse_main.c | 133 +++++++++------- drivers/net/ethernet/altera/altera_utils.c | 20 +-- drivers/net/ethernet/altera/altera_utils.h | 8 +- 10 files changed, 372 insertions(+), 275 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/1 Altera TSE: Fix sparse errors and warnings
This patch fixes the many sparse errors and warnings contained in the initial submission of the Altera Triple Speed Ethernet driver, and a few minor cppcheck warnings. Changes are tested on ARM and NIOS2 example designs, and compile tested against multiple architectures. Typical issues addressed were as follows:
altera_tse_ethtool.c:136:19: warning: incorrect type in argument
1 (different address spaces)
altera_tse_ethtool.c:136:19: expected void const volatile
[noderef] <asn:2>*addr
altera_tse_ethtool.c:136:19: got unsigned int *<noident>
...
altera_sgdma.c:129:31: warning: cast removes address space of
expression
--- drivers/net/ethernet/altera/Makefile | 1 + drivers/net/ethernet/altera/altera_msgdma.c | 110 ++++++------- drivers/net/ethernet/altera/altera_msgdmahw.h | 13 +- drivers/net/ethernet/altera/altera_sgdma.c | 181 +++++++++++----------- drivers/net/ethernet/altera/altera_sgdmahw.h | 26 ++-- drivers/net/ethernet/altera/altera_tse.h | 47 ++++++ drivers/net/ethernet/altera/altera_tse_ethtool.c | 108 ++++++++----- drivers/net/ethernet/altera/altera_tse_main.c | 133 +++++++++------- drivers/net/ethernet/altera/altera_utils.c | 20 +-- drivers/net/ethernet/altera/altera_utils.h | 8 +- 10 files changed, 372 insertions(+), 275 deletions(-)
drivers/net/ethernet/altera/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_ALTERA_TSE) += altera_tse.o altera_tse-objs := altera_tse_main.o altera_tse_ethtool.o \ altera_msgdma.o altera_sgdma.o altera_utils.o +ccflags-y += -D__CHECK_ENDIAN__
drivers/net/ethernet/altera/altera_msgdma.c +55 -55
198 lines not on this page · raw message
drivers/net/ethernet/altera/altera_msgdmahw.h +4 -9
@@ -17,15 +17,6 @@#ifndef __ALTERA_MSGDMAHW_H__#define __ALTERA_MSGDMAHW_H__ -/* mSGDMA standard descriptor format -*/ -struct msgdma_desc { -u32 read_addr;/* data buffer source address */ -u32 write_addr;/* data buffer destination address */ -u32 len;/* the number of bytes to transfer per descriptor */ -u32 control;/* characteristics of the transfer */ -}; -/* mSGDMA extended descriptor format */ struct msgdma_extended_desc {
@@ -159,6 +150,10 @@ struct msgdma_response {u32 status; }; +#define msgdma_respoffs (a) (offsetof(struct msgdma_response, a)) +#define msgdma_csroffs (a) (offsetof(struct msgdma_csr, a)) +#define msgdma_descroffs (a) (offsetof(struct msgdma_extended_desc, a)) +/* mSGDMA response register bit definitions */ #define MSGDMA_RESP_EARLY_TERM BIT(8)
drivers/net/ethernet/altera/altera_sgdma.c +90 -91
374 lines not on this page · raw message
drivers/net/ethernet/altera/altera_sgdmahw.h +14 -12
@@ -19,16 +19,16 @@/* SGDMA descriptor structure */ struct sgdma_descrip { -unsigned int raddr;/* address of data to be read */ -unsigned int pad1; -unsigned int waddr; -unsigned int pad2; -unsigned int next; -unsigned int pad3; -unsigned short bytes; -unsigned char rburst; -unsigned char wburst; -unsigned short bytes_xferred;/* 16 bits, bytes xferred */ +u32 raddr;/* address of data to be read */ +u32 pad1; +u32 waddr; +u32 pad2; +u32 next; +u32 pad3; +u16 bytes; +u8 rburst; +u8 wburst; +u16 bytes_xferred;/* 16 bits, bytes xferred */ /* bit 0: error * bit 1: length error
@@ -39,7 +39,7 @@ struct sgdma_descrip {* bit 6: reserved * bit 7: status eop for recv case */ -unsigned char status; +u8 status;/* bit 0: eop * bit 1: read_fixed
@@ -47,7 +47,7 @@ struct sgdma_descrip {* bits 3,4,5,6: Channel (always 0) * bit 7: hardware owned */ -unsigned char control; +u8 control; } __packed;
@@ -101,6 +101,8 @@ struct sgdma_csr {u32 pad3[3 ]; }; +#define sgdma_csroffs (a) (offsetof(struct sgdma_csr, a)) +#define sgdma_descroffs (a) (offsetof(struct sgdma_descrip, a))#define SGDMA_STSREG_ERR BIT(0)/* Error */ #define SGDMA_STSREG_EOP BIT(1)/* EOP */
drivers/net/ethernet/altera/altera_tse.h +47 -0
57 lines not on this page · raw message
drivers/net/ethernet/altera/altera_tse_ethtool.c +71 -37
139 lines not on this page · raw message
drivers/net/ethernet/altera/altera_tse_main.c +76 -57
324 lines not on this page · raw message
drivers/net/ethernet/altera/altera_utils.c +10 -10
@@ -17,28 +17,28 @@#include "altera_tse.h" #include "altera_utils.h" -void tse_set_bit (void __iomem *ioaddr,u32 bit_mask) +void tse_set_bit (void __iomem *ioaddr,size_t offs,u32 bit_mask) { -u32 value =ioread32 (ioaddr); +u32 value =csrrd32 (ioaddr, offs); value |= bit_mask; -iowrite32 (value, ioaddr); +csrwr32 (value, ioaddr, offs); } -void tse_clear_bit (void __iomem *ioaddr,u32 bit_mask) +void tse_clear_bit (void __iomem *ioaddr,size_t offs,u32 bit_mask) { -u32 value =ioread32 (ioaddr); +u32 value =csrrd32 (ioaddr, offs); value &= ~bit_mask; -iowrite32 (value, ioaddr); +csrwr32 (value, ioaddr, offs); } -int tse_bit_is_set (void __iomem *ioaddr,u32 bit_mask) +int tse_bit_is_set (void __iomem *ioaddr,size_t offs,u32 bit_mask) { -u32 value =ioread32 (ioaddr); +u32 value =csrrd32 (ioaddr, offs);return (value & bit_mask) ?1 :0 ; } -int tse_bit_is_clear (void __iomem *ioaddr,u32 bit_mask) +int tse_bit_is_clear (void __iomem *ioaddr,size_t offs,u32 bit_mask) { -u32 value =ioread32 (ioaddr); +u32 value =csrrd32 (ioaddr, offs);return (value & bit_mask) ?0 :1 ; }
drivers/net/ethernet/altera/altera_utils.h +4 -4
@@ -19,9 +19,9 @@#ifndef __ALTERA_UTILS_H__#define __ALTERA_UTILS_H__ -void tse_set_bit (void __iomem *ioaddr,u32 bit_mask); -void tse_clear_bit (void __iomem *ioaddr,u32 bit_mask); -int tse_bit_is_set (void __iomem *ioaddr,u32 bit_mask); -int tse_bit_is_clear (void __iomem *ioaddr,u32 bit_mask); +void tse_set_bit (void __iomem *ioaddr,size_t offs,u32 bit_mask); +void tse_clear_bit (void __iomem *ioaddr,size_t offs,u32 bit_mask); +int tse_bit_is_set (void __iomem *ioaddr,size_t offs,u32 bit_mask); +int tse_bit_is_clear (void __iomem *ioaddr,size_t offs,u32 bit_mask);#endif /* __ALTERA_UTILS_H__*/
Signature · 1 line
1.7.9.5
Re: [PATCH net] Altera TSE: Fix sparse errors and warnings
On 2014-05-08 at 20:15:40 +0200, Vince Bridgers <[email protected]> wrote:
[...]
Quoted 4 lines
drivers/net/ethernet/altera/altera_tse_main.c +0
-0
[...]
drivers/net/ethernet/altera/altera_tse_main.c static int altera_tse_probe(struct platform_device *pdev) · line 1383
Quoted 9 lines
drivers/net/ethernet/altera/altera_tse_main.c +5
-0@@ -1362,6 +1376,11 @@ static int altera_tse_probe(struct platform_device *pdev)of_property_read_bool (pdev->dev.of_node,"altr,has-hash-multicast-filter" ); +/* Set hash filter to not set for now until the +* multicast filter receive issue is debugged +*/ + priv->hash_filter =0 ; +
This doesn't seem to be related to the sparse/cppcheck cleanup. Shouldn't this be an own patch?
drivers/net/ethernet/altera/altera_tse_main.c static int altera_tse_remove(struct platform_device *pdev) · line 1515
Quoted 9 lines
drivers/net/ethernet/altera/altera_tse_main.c +1
-1/* get supplemental address settings for this instance */ priv->added_unicast = of_property_read_bool(pdev->dev.of_node,@@ -1493,7 +1512,7 @@ static int altera_tse_remove(struct platform_device *pdev)return 0 ; } -struct altera_dmaops altera_dtype_sgdma = { +static struct altera_dmaops altera_dtype_sgdma = {
This can probably also be made const.
drivers/net/ethernet/altera/altera_tse_main.c struct altera_dmaops altera_dtype_sgdma = { · line 1534
Quoted 9 lines
drivers/net/ethernet/altera/altera_tse_main.c +1
-1.altera_dtype = ALTERA_DTYPE_SGDMA, .dmamask = 32, .reset_dma = sgdma_reset,@@ -1512,7 +1531,7 @@ struct altera_dmaops altera_dtype_sgdma = { .start_rxdma = sgdma_start_rxdma, }; -struct altera_dmaops altera_dtype_msgdma = { +static struct altera_dmaops altera_dtype_msgdma = {
Ditto.
Cheers
Tobias
Re: [PATCH net] Altera TSE: Fix sparse errors and warnings
Hi Tobias,
Quoted 3 lines · Tobias Klauser
This doesn't seem to be related to the sparse/cppcheck cleanup. Shouldn't this be an own patch?
Thanks for catching this, I'll break this out in the next version.
Quoted 5 lines
drivers/net/ethernet/altera/altera_tse_main.c static int altera_tse_remove(struct platform_device *pdev) · line 1515
Quoted 3 lines
drivers/net/ethernet/altera/altera_tse_main.c +1
-1-struct altera_dmaops altera_dtype_sgdma = { +static struct altera_dmaops altera_dtype_sgdma = {This can probably also be made const.
I'll look at this and include in the next version submission if possible.
Quoted 4 lines
drivers/net/ethernet/altera/altera_tse_main.c struct altera_dmaops altera_dtype_sgdma = { · line 1534
Quoted 2 lines
drivers/net/ethernet/altera/altera_tse_main.c +1
-1-struct altera_dmaops altera_dtype_msgdma = { +static struct altera_dmaops altera_dtype_msgdma = {Ditto.
Same,
Quoted 3 lines
Cheers
Tobias
Thanks for taking a look at this,
All the best,
Vince