Fix whitespace issues in staging/kpc2000
cover Fix whitespace issues in staging/kpc2000
Hi,
These patches fixes minor whitespace issues in staging/kpc2000/core.c as reported by checkpatch.pl.
- Simon
Simon Sandström (4):
staging: kpc2000: add spaces around operators in core.c
staging: kpc2000: remove extra blank line in core.c
staging: kpc2000: add missing spaces in core.c
staging: kpc2000: remove extra spaces in core.c
drivers/staging/kpc2000/kpc2000/core.c | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/4 staging: kpc2000: add spaces around operators in core.c
Fixes checkpatch.pl check "spaces preferred around that <op>".
--- drivers/staging/kpc2000/kpc2000/core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +12 -12
@@ -276,18 +276,18 @@ static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf,if (WARN (NULL == buf,"kp2000_cdev_read: buf is a NULL pointer!\n" ))return -EINVAL ; - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Card ID : 0x%08x\n" , pcard->card_id); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Version : 0x%08x\n" , pcard->build_version); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Date : 0x%08x\n" , pcard->build_datestamp); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Time : 0x%08x\n" , pcard->build_timestamp); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Core Table Offset : 0x%08x\n" , pcard->core_table_offset); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Core Table Length : 0x%08x\n" , pcard->core_table_length); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Hardware Revision : 0x%08x\n" , pcard->hardware_revision); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"SSID : 0x%016llx\n" , pcard->ssid); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"DDNA : 0x%016llx\n" , pcard->ddna); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"IRQ Mask : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK )); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"IRQ Active : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_ACTIVE )); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"CPLD : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Card ID : 0x%08x\n" , pcard->card_id); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Version : 0x%08x\n" , pcard->build_version); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Date : 0x%08x\n" , pcard->build_datestamp); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Time : 0x%08x\n" , pcard->build_timestamp); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Core Table Offset : 0x%08x\n" , pcard->core_table_offset); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Core Table Length : 0x%08x\n" , pcard->core_table_length); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Hardware Revision : 0x%08x\n" , pcard->hardware_revision); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"SSID : 0x%016llx\n" , pcard->ssid); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"DDNA : 0x%016llx\n" , pcard->ddna); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"IRQ Mask : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"IRQ Active : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_ACTIVE )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"CPLD : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG ));if (*f_pos >= cnt)return 0 ;
Signature · 1 line
2.20.1
Greg KH
maintainerRe: [PATCH 1/4] staging: kpc2000: add spaces around operators in core.c
Quoted 32 lines · Simon Sandström
Fixes checkpatch.pl check "spaces preferred around that <op>".
Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/kpc2000/kpc2000/core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/staging/kpc2000/kpc2000/core.c +5
-12@@ -276,18 +276,18 @@ static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf,if (WARN (NULL == buf,"kp2000_cdev_read: buf is a NULL pointer!\n" ))return -EINVAL ; - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Card ID : 0x%08x\n" , pcard->card_id); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Version : 0x%08x\n" , pcard->build_version); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Date : 0x%08x\n" , pcard->build_datestamp); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Build Time : 0x%08x\n" , pcard->build_timestamp); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Core Table Offset : 0x%08x\n" , pcard->core_table_offset); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Core Table Length : 0x%08x\n" , pcard->core_table_length); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"Hardware Revision : 0x%08x\n" , pcard->hardware_revision); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"SSID : 0x%016llx\n" , pcard->ssid); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"DDNA : 0x%016llx\n" , pcard->ddna); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"IRQ Mask : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK )); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"IRQ Active : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_ACTIVE )); - cnt +=scnprintf (buff+cnt,BUFF_CNT -cnt,"CPLD : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Card ID : 0x%08x\n" , pcard->card_id); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Version : 0x%08x\n" , pcard->build_version); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Date : 0x%08x\n" , pcard->build_datestamp); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Build Time : 0x%08x\n" , pcard->build_timestamp); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Core Table Offset : 0x%08x\n" , pcard->core_table_offset);
drivers/staging/kpc2000/kpc2000/core.c static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, · line 293
Quoted 10 lines
drivers/staging/kpc2000/kpc2000/core.c +7
-0+ cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Core Table Length : 0x%08x\n" , pcard->core_table_length); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"Hardware Revision : 0x%08x\n" , pcard->hardware_revision); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"SSID : 0x%016llx\n" , pcard->ssid); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"DDNA : 0x%016llx\n" , pcard->ddna); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"IRQ Mask : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_MASK )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"IRQ Active : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_INTERRUPT_ACTIVE )); + cnt +=scnprintf (buff + cnt,BUFF_CNT - cnt,"CPLD : 0x%016llx\n" ,readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG ));if (*f_pos >= cnt)return 0 ;
This whole function just needs to be deleted, it's a horrible hack.
thanks,
greg k-h
RE: [PATCH 1/4] staging: kpc2000: add spaces around operators in core.c
Quoted 8 lines
From: devel <[email protected]> On Behalf Of Greg KH
drivers/staging/kpc2000/kpc2000/core.c static ssize_t kp2000_cdev_read(struct file *filp,
Quoted 3 lines · Simon Sandström
drivers/staging/kpc2000/kpc2000/core.c +0
-0@@ -276,18 +276,18 @@ static ssize_t kp2000_cdev_read(struct file *filp,This whole function just needs to be deleted, it's a horrible hack.
From the outside, I would definitely agree with you. On the inside though, we rely on this function to quickly identify what kind and version is running on a given piece of hardware. Since that same information is provided by an ioctl, I could be convinced to remove this API and write a userspace application that uses the ioctl to get the information and pretty prints it.
I'd be more inclined to agree with the deletion if it means the whole char dev interface can be removed from the kpc2000 driver. That won't be straightforward as the ioctl is exposed through this interface. We could remove the ioctl, but we'd need to ensure that all the same information is exposed via sysfs. Our userspace side is all funneled through a single class, so changing it to use sysfs wouldn't be too difficult. I'd support that change if someone wants to make it.
Greg KH
maintainerRe: [PATCH 1/4] staging: kpc2000: add spaces around operators in core.c
Quoted 9 lines · Matt Sickler
Quoted 8 lines
From: devel <[email protected]> On Behalf Of Greg KH
drivers/staging/kpc2000/kpc2000/core.c static ssize_t kp2000_cdev_read(struct file *filp,
Quoted 3 lines · Simon Sandström
drivers/staging/kpc2000/kpc2000/core.c +0
-0@@ -276,18 +276,18 @@ static ssize_t kp2000_cdev_read(struct file *filp,This whole function just needs to be deleted, it's a horrible hack.
Quoted 5 lines
Quoted 1 line
From the outside, I would definitely agree with you. On the inside though, we
rely on this function to quickly identify what kind and version is running on a given piece of hardware. Since that same information is provided by an ioctl, I could be convinced to remove this API and write a userspace application that uses the ioctl to get the information and pretty prints it.
The ioctl needs to die as well, just use the sysfs entries instead, as you already have them :)
Quoted 4 lines
I'd be more inclined to agree with the deletion if it means the whole char dev interface can be removed from the kpc2000 driver. That won't be straightforward as the ioctl is exposed through this interface. We could remove the ioctl, but we'd need to ensure that all the same information is exposed via sysfs.
I think you are there already, what is missing?
Quoted 3 lines
Our userspace side is all funneled through a single class, so changing it to use sysfs wouldn't be too difficult. I'd support that change if someone wants to make it.
I will be glad to do that, it's always nice to delete code :)
thanks,
greg k-h
PATCH 2/4 staging: kpc2000: remove extra blank line in core.c
In reply to Simon SandströmFixes checkpatch.pl check "Please don't use multiple blank lines".
--- drivers/staging/kpc2000/kpc2000/core.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/kpc2000/kpc2000/core.c +0 -1
@@ -262,7 +262,6 @@ static int kp2000_cdev_close(struct inode *inode, struct file *filp)return 0 ; } -static ssize_t kp2000_cdev_read (struct file *filp,char __user *buf,size_t count,loff_t *f_pos) {
Signature · 1 line
2.20.1
PATCH 3/4 staging: kpc2000: add missing spaces in core.c
In reply to Simon SandströmFixes checkpatch.pl errors "space required before the open brace '{'" and "(foo*)" should be "(foo *)".
--- drivers/staging/kpc2000/kpc2000/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +2 -2
@@ -308,7 +308,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num,dev_dbg (&pcard->pdev->dev,"kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n" , filp, ioctl_num, ioctl_param, pcard); -switch (ioctl_num){ +switch (ioctl_num) {case KP2000_IOCTL_GET_CPLD_REG :return readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG );case KP2000_IOCTL_GET_PCIE_ERROR_REG :return readq (pcard->sysinfo_regs_base +REG_PCIE_ERROR_COUNT );
@@ -326,7 +326,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, temp.ddna = pcard->ddna; temp.cpld_reg =readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG ); - ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp)); + ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp));if (ret)return -EFAULT ;
Signature · 1 line
2.20.1
Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c
Quoted 22 lines · Simon Sandström
Fixes checkpatch.pl errors "space required before the open brace '{'" and "(foo*)" should be "(foo *)".
Signed-off-by Simon Sandström <[email protected]>--- drivers/staging/kpc2000/kpc2000/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/kpc2000/kpc2000/core.c +1
-1@@ -308,7 +308,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num,dev_dbg (&pcard->pdev->dev,"kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n" , filp, ioctl_num, ioctl_param, pcard); -switch (ioctl_num){ +switch (ioctl_num) {case KP2000_IOCTL_GET_CPLD_REG :return readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG );case KP2000_IOCTL_GET_PCIE_ERROR_REG :return readq (pcard->sysinfo_regs_base +REG_PCIE_ERROR_COUNT );
drivers/staging/kpc2000/kpc2000/core.c static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, · line 331
Quoted 7 lines
drivers/staging/kpc2000/kpc2000/core.c +1
-1@@ -326,7 +326,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, temp.ddna = pcard->ddna; temp.cpld_reg =readq (pcard->sysinfo_regs_base +REG_CPLD_CONFIG ); - ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp)); + ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp));if (ret)return -EFAULT ;
This should really be written like so:
if (copy_to_user((void __user *)ioctl_param, &temp, sizeof(temp))) return -EFAULT;
temp is really the wrong name. "temp" is for temperatures. "tmp" means temporary. But also "tmp" is wrong here because it's not a temporary variable. It's better to call it "regs" here.
regards,
dan carpenter
Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c
Quoted 13 lines · Dan Carpenter
drivers/staging/kpc2000/kpc2000/core.c static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, · line 331
Quoted 5 lines · Simon Sandström
[..]
drivers/staging/kpc2000/kpc2000/core.c +1
-1- ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp)); + ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp));if (ret)return -EFAULT ;This should really be written like so:
if (copy_to_user((void __user *)ioctl_param, &temp, sizeof(temp))) return -EFAULT;
Quoted 7 lines
temp is really the wrong name. "temp" is for temperatures. "tmp" means temporary. But also "tmp" is wrong here because it's not a temporary variable. It's better to call it "regs" here.
regards,
dan carpenter
I agree, but I don't think it fits within this patch. I can send a separate patch with this change.
Thanks
- Simon
Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c
Quoted 18 lines · Simon Sandström
Quoted 17 lines · Dan Carpenter
drivers/staging/kpc2000/kpc2000/core.c static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, · line 331
Quoted 5 lines · Simon Sandström
[..]
drivers/staging/kpc2000/kpc2000/core.c +1
-1- ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp)); + ret =copy_to_user ((void *)ioctl_param, (void *)&temp,sizeof (temp));if (ret)return -EFAULT ;This should really be written like so:
if (copy_to_user((void __user *)ioctl_param, &temp, sizeof(temp))) return -EFAULT;temp is really the wrong name. "temp" is for temperatures. "tmp" means temporary. But also "tmp" is wrong here because it's not a temporary variable. It's better to call it "regs" here.
Quoted 6 lines
Quoted 3 lines
regards,
dan carpenterI agree, but I don't think it fits within this patch. I can send a separate patch with this change.
You could send the other chunk as a separate patch, but I don't think it makes sense to apply this chunk when really it just needs to be re-written.
I normally don't complain too much about mechanical no-thought patches, but in this case the function is very sub-par and should be re-written.
regards,
dan carpenter
PATCH 4/4 staging: kpc2000: remove extra spaces in core.c
In reply to Simon SandströmFixes checkpatch.pl error "foo __init bar" should be "foo __init bar" and "foo __exit bar" should be "foo __exit bar".
--- drivers/staging/kpc2000/kpc2000/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +2 -2
@@ -655,7 +655,7 @@ static struct pci_driver kp2000_driver_inst = { .remove = kp2000_pcie_remove, }; -static int __init kp2000_pcie_init (void ) +static int __init kp2000_pcie_init (void ) { kpc_uio_class =class_create (THIS_MODULE ,"kpc_uio" );if (IS_ERR (kpc_uio_class))
@@ -666,7 +666,7 @@ static int __init kp2000_pcie_init(void) }module_init (kp2000_pcie_init); -static void __exit kp2000_pcie_exit(void) +static void __exit kp2000_pcie_exit(void) {pci_unregister_driver (&kp2000_driver_inst);class_destroy (kpc_uio_class);
Signature · 1 line
2.20.1