Skip to contentSkip to conversation

Fix whitespace issues in staging/kpc2000

PATCH In review Simon Sandström 4 participants 11 messages May 24, 2019 – May 31, 2019 Staging

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 4110032d0cbb..b464973d12ad 100644
@@ -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
maintainer
#2 lore raw

Re: [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>".

---
 drivers/staging/kpc2000/kpc2000/core.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +5 -12
index 4110032d0cbb..b464973d12ad 100644
@@ -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

#3 lore raw

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.

maintainer
#4 lore raw

Re: [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

#5 lore raw

PATCH 2/4 staging: kpc2000: remove extra blank line in core.c

In reply to Simon Sandström

Fixes 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
index b464973d12ad..40f65f96986b 100644
@@ -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
#6 lore raw

PATCH 3/4 staging: kpc2000: add missing spaces in core.c

In reply to Simon Sandström

Fixes 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
index 40f65f96986b..bb3b427a72b1 100644
@@ -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
#7 lore raw

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

---
 drivers/staging/kpc2000/kpc2000/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/kpc2000/kpc2000/core.c +1 -1
index 40f65f96986b..bb3b427a72b1 100644
@@ -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

#8 lore raw

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

#9 lore raw

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 carpenter

I 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

#10 lore raw

PATCH 4/4 staging: kpc2000: remove extra spaces in core.c

In reply to Simon Sandström

Fixes 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
index bb3b427a72b1..3b240eff62b7 100644
@@ -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