Fix more coding style issues in staging/kpc2000
v2 cover Fix more coding style issues in staging/kpc2000
Hi,
These patches fixes a few more minor coding style issues found in staging/kpc2000/cell_probe.c. There are only two more types of checkpatch.pl warnings left in this file with these patches applied:
"line over 80 characters" and "Macro argument reuse".
Changed in v2: don't bother fixing the __func__ usage in the out of
memory debug message, instead add a patch that removes it completely.
- Simon
Simon Sandström (9):
staging: kpc2000: add blank line after declarations
staging: kpc2000: use __func__ in debug messages
staging: kpc2000: add missing asterisk in comment
staging: kpc2000: fix alignment issues in cell_probe.c
staging: kpc2000: remove extra blank lines in cell_probe.c
staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c
staging: kpc2000: remove unnecessary braces in cell_probe.c
staging: kpc2000: remove unnecessary include in cell_probe.c
staging: kpc2000: remove unnecessary oom message
drivers/staging/kpc2000/kpc2000/cell_probe.c | 81 +++++++++----------- 1 file changed, 38 insertions(+), 43 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/9 staging: kpc2000: add blank line after declarations
Fixes checkpatch.pl warning "Missing a blank line after declarations".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/kpc2000/kpc2000/cell_probe.c +4 -0
@@ -245,6 +245,7 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num)u64 interrupt_active =readq (pcard->sysinfo_regs_base +REG_INTERRUPT_ACTIVE );u64 interrupt_mask_inv = ~readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK );u64 irq_check_mask = (1 << irq_num); +if (interrupt_active & irq_check_mask) {// if it's active (interrupt pending) if (interrupt_mask_inv & irq_check_mask) {// and if it's not masked off return 1 ;
@@ -257,6 +258,7 @@ staticirqreturn_t kuio_handler (int irq,struct uio_info *uioinfo) {struct kpc_uio_device *kudev = uioinfo->priv; +if (irq != kudev->pcard->pdev->irq)return IRQ_NONE ;
@@ -506,8 +508,10 @@ void kp2000_remove_cores(struct kp2000_device *pcard) {struct list_head *ptr;struct list_head *next; +list_for_each_safe (ptr, next, &pcard->uio_devices_list) { struct kpc_uio_device *kudev = list_entry(ptr, struct kpc_uio_device, list); +uio_unregister_device (&kudev->uioinfo);device_unregister (kudev->dev);list_del (&kudev->list);
Signature · 1 line
2.20.1
PATCH v2 2/9 staging: kpc2000: use __func__ in debug messages
In reply to Simon SandströmFixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using '<function name>', this function's name, in a string".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +12 -7
@@ -327,7 +327,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->dev =device_create (kpc_uio_class, &pcard->pdev->dev,MKDEV (0 ,0 ), kudev,"%s.%d.%d.%d" , kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num);if (IS_ERR (kudev->dev)) { -dev_err (&pcard->pdev->dev,"probe_core_uio device_create failed!\n" ); +dev_err (&pcard->pdev->dev,"%s: device_create failed!\n" , + __func__);kfree (kudev);return -ENODEV ; }
@@ -335,7 +336,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, rv =uio_register_device (kudev->dev, &kudev->uioinfo);if (rv) { -dev_err (&pcard->pdev->dev,"probe_core_uio failed uio_register_device: %d\n" , rv); +dev_err (&pcard->pdev->dev,"%s: failed uio_register_device: %d\n" , + __func__, rv);put_device (kudev->dev);kfree (kudev);return rv;
@@ -410,7 +412,8 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard)return 0 ; err_out: -dev_err (&pcard->pdev->dev,"kp2000_setup_dma_controller: failed to add a DMA Engine: %d\n" , err); +dev_err (&pcard->pdev->dev,"%s: failed to add a DMA Engine: %d\n" , + __func__, err);return err; }
@@ -423,7 +426,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard)unsigned int highest_core_id =0 ;struct core_table_entry cte; -dev_dbg (&pcard->pdev->dev,"kp2000_probe_cores(pcard = %p / %d)\n" , pcard, pcard->card_num); +dev_dbg (&pcard->pdev->dev,"%s(pcard = %p / %d)\n" , __func__, pcard, + pcard->card_num); err =kp2000_setup_dma_controller (pcard);if (err)
@@ -472,8 +476,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) }if (err) {dev_err (&pcard->pdev->dev, -"kp2000_probe_cores: failed to add core %d: %d\n" , - i, err); +"%s: failed to add core %d: %d\n" , + __func__, i, err); goto error; } core_num++;
@@ -492,7 +496,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) cte.irq_base_num =0 ; err =probe_core_uio (0 , pcard,"kpc_uio" , cte);if (err) { -dev_err (&pcard->pdev->dev,"kp2000_probe_cores: failed to add board_info core: %d\n" , err); +dev_err (&pcard->pdev->dev,"%s: failed to add board_info core: %d\n" , + __func__, err); goto error; }
Signature · 1 line
2.20.1
PATCH v2 3/9 staging: kpc2000: add missing asterisk in comment
In reply to Simon SandströmFixes checkpatch.pl error "code indent should use tabs where possible".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +1 -1
@@ -25,7 +25,7 @@* D C2S DMA Present * DDD C2S DMA Channel Number [up to 8 channels] * II IRQ Count [0 to 3 IRQs per core] -1111111000 +* 1111111000 * IIIIIII IRQ Base Number [up to 128 IRQs per card] * ___ Spare *
Signature · 1 line
2.20.1
PATCH v2 4/9 staging: kpc2000: fix alignment issues in cell_probe.c
In reply to Simon SandströmFixes checkpatch.pl warnings "Alignment should match open parenthesis" and "Lines should not end with a '('".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 34 +++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +15 -19
@@ -128,15 +128,13 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, cell.resources = resources; -return mfd_add_devices ( -PCARD_TO_DEV (pcard),// parent - pcard->card_num *100 ,// id - &cell,// struct mfd_cell * -1 ,// ndevs - &pcard->regs_base_resource, -0 ,// irq_base -NULL // struct irq_domain * - ); +return mfd_add_devices (PCARD_TO_DEV (pcard),// parent + pcard->card_num *100 ,// id + &cell,// struct mfd_cell * +1 ,// ndevs + &pcard->regs_base_resource, +0 ,// irq_base +NULL );// struct irq_domain * }
@@ -373,15 +371,13 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re cell.resources = resources; -return mfd_add_devices ( -PCARD_TO_DEV (pcard),// parent - pcard->card_num *100 ,// id - &cell,// struct mfd_cell * -1 ,// ndevs - &pcard->dma_base_resource, -0 ,// irq_base -NULL // struct irq_domain * - ); +return mfd_add_devices (PCARD_TO_DEV (pcard),// parent + pcard->card_num *100 ,// id + &cell,// struct mfd_cell * +1 ,// ndevs + &pcard->dma_base_resource, +0 ,// irq_base +NULL );// struct irq_domain * }static int kp2000_setup_dma_controller (struct kp2000_device *pcard)
@@ -462,7 +458,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard)switch (cte.type) {case KP_CORE_ID_I2C : err =probe_core_basic (core_num, pcard, -KP_DRIVER_NAME_I2C , cte); +KP_DRIVER_NAME_I2C , cte);break ;case KP_CORE_ID_SPI :
Signature · 1 line
2.20.1
PATCH v2 5/9 staging: kpc2000: remove extra blank lines in cell_probe.c
In reply to Simon SandströmFixes checkpatch.pl warnings "Please don't use multiple blank lines".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +0 -4
@@ -94,7 +94,6 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co } } -static int probe_core_basic (unsigned int core_num,struct kp2000_device *pcard,char *name,const struct core_table_entry cte) {
@@ -111,7 +110,6 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard,dev_dbg (&pcard->pdev->dev,"Found Basic core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n" , cte.type,KPC_OLD_S2C_DMA_CH_NUM (cte),KPC_OLD_C2S_DMA_CH_NUM (cte), cte.offset, cte.length, cte.length /8 ); - cell.platform_data = &core_pdata; cell.pdata_size =sizeof (struct kpc_core_device_platdata ); cell.num_resources =2 ;
@@ -137,7 +135,6 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, NULL); // struct irq_domain * } -struct kpc_uio_device {struct list_head list;struct kp2000_device *pcard;
@@ -346,7 +343,6 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard,return 0 ; } -static int create_dma_engine_core (struct kp2000_device *pcard,size_t engine_regs_offset,int engine_num,int irq_num) {struct mfd_cell cell = { .id = engine_num };
Signature · 1 line
2.20.1
PATCH v2 6/9 staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c
In reply to Simon SandströmFixes checkpatch.pl warning "Prefer kzalloc(sizeof(*kudev)...) over kzalloc(sizeof(struct kpc_uio_device)...)"
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +1 -1
@@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard,dev_dbg (&pcard->pdev->dev,"Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n" , cte.type,KPC_OLD_S2C_DMA_CH_NUM (cte),KPC_OLD_C2S_DMA_CH_NUM (cte), cte.offset, cte.length, cte.length /8 ); - kudev =kzalloc (sizeof (struct kpc_uio_device ),GFP_KERNEL ); + kudev =kzalloc (sizeof (*kudev),GFP_KERNEL );if (!kudev) {dev_err (&pcard->pdev->dev,"probe_core_uio: failed to kzalloc kpc_uio_device\n" );return -ENOMEM ;
Signature · 1 line
2.20.1
PATCH v2 7/9 staging: kpc2000: remove unnecessary braces in cell_probe.c
In reply to Simon SandströmFixes checkpatch.pl warnings "braces {} are not necessary for single statement blocks".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +4 -7
@@ -273,11 +273,10 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)mutex_lock (&pcard->sem); mask =readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK ); -if (irq_on) { +if (irq_on) mask &= ~(1 << (kudev->cte.irq_base_num)); - }else { +else mask |= (1 << (kudev->cte.irq_base_num)); - }writeq (mask, pcard->sysinfo_regs_base +REG_INTERRUPT_MASK );mutex_unlock (&pcard->sem);
@@ -432,12 +431,10 @@ int kp2000_probe_cores(struct kp2000_device *pcard) read_val =readq (pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) *8 ));parse_core_table_entry (&cte, read_val, pcard->core_table_rev);dbg_cte (pcard, &cte); -if (cte.type > highest_core_id) { +if (cte.type > highest_core_id) highest_core_id = cte.type; - } -if (cte.type ==KP_CORE_ID_INVALID ) { +if (cte.type ==KP_CORE_ID_INVALID )dev_info (&pcard->pdev->dev,"Found Invalid core: %016llx\n" , read_val); - } }// Then, iterate over the possible core types. for (current_type_id =1 ; current_type_id <= highest_core_id ; current_type_id++) {
Signature · 1 line
2.20.1
PATCH v2 8/9 staging: kpc2000: remove unnecessary include in cell_probe.c
In reply to Simon SandströmFixes checkpatch.pl warning "Use #include <linux/io.h> instead of <asm/io.h>".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +0 -1
@@ -4,7 +4,6 @@#include <linux/types.h> #include <linux/export.h> #include <linux/slab.h> -#include <asm/io.h> #include <linux/io.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/mfd/core.h>
Signature · 1 line
2.20.1
PATCH v2 9/9 staging: kpc2000: remove unnecessary oom message
In reply to Simon SandströmFixes checkpatch.pl warning "Possible unnecessary 'out of memory' message".
--- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/kpc2000/kpc2000/cell_probe.c +1 -3
@@ -291,10 +291,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard,dev_dbg (&pcard->pdev->dev,"Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n" , cte.type,KPC_OLD_S2C_DMA_CH_NUM (cte),KPC_OLD_C2S_DMA_CH_NUM (cte), cte.offset, cte.length, cte.length /8 ); kudev =kzalloc (sizeof (*kudev),GFP_KERNEL ); -if (!kudev) { -dev_err (&pcard->pdev->dev,"probe_core_uio: failed to kzalloc kpc_uio_device\n" ); +if (!kudev)return -ENOMEM ; - }INIT_LIST_HEAD (&kudev->list); kudev->pcard = pcard;
Signature · 1 line
2.20.1