Skip to contentSkip to conversation

staging: gs_fpgaboot: Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

PATCH Superseded Dzmitry Sledneu 3 participants 10 messages Oct 7, 2014 – Oct 9, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging: gs_fpgaboot: Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +1 -1
index 6aa9d7c..6129164 100644
@@ -58,7 +58,7 @@ static void datadump(char *msg, void *m, int n)
 
 	for (i = 0; i < n; i++) {
 		if ((i&0xf) == 0)
-			pr_info(KERN_INFO "\n  0x%4x: ", i);
+			pr_info("\n  0x%4x: ", i);
 
 		pr_info("%02X ", c[i]);
 	}
Signature · 1 line
2.1.2
#1 lore raw

PATCH 2/2 staging: gs_fpgaboot: Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -4
index 6129164..b7ca3a3 100644
@@ -316,10 +316,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL) {
-		pr_err("No memory is available\n");
-		goto err_out;
-	}
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {
Signature · 1 line
2.1.2
#2 lore raw

PATCH v2 1/2 staging: gs_fpgaboot: Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +1 -1
index 6aa9d7c..6129164 100644
@@ -58,7 +58,7 @@ static void datadump(char *msg, void *m, int n)
 
 	for (i = 0; i < n; i++) {
 		if ((i&0xf) == 0)
-			pr_info(KERN_INFO "\n  0x%4x: ", i);
+			pr_info("\n  0x%4x: ", i);
 
 		pr_info("%02X ", c[i]);
 	}
Signature · 1 line
2.1.2
#3 lore raw

PATCH v2 2/2 staging: gs_fpgaboot: Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -5
index 6129164..cc788f1 100644
@@ -316,10 +316,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL) {
-		pr_err("No memory is available\n");
-		goto err_out;
-	}
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {
@@ -361,7 +359,6 @@ err_out2:
 err_out1:
 	kfree(fimage);
 
-err_out:
 	return -1;
 
 }
Signature · 1 line
2.1.2
#4 lore raw
In reply to Dzmitry Sledneu
Quoted 1 line · Dzmitry Sledneu

Fix "Possible unnecessary KERN_INFO" checkpatch.pl warning

[]

drivers/staging/gs_fpgaboot/gs_fpgaboot.c

Quoted 1 line
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +0 -0

[]

drivers/staging/gs_fpgaboot/gs_fpgaboot.c static void datadump(char *msg, void *m, int n) · line 64

Quoted 9 lines
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +1 -1
@@ -58,7 +58,7 @@ static void datadump(char *msg, void *m, int n)
 
 	for (i = 0; i < n; i++) {
 		if ((i&0xf) == 0)
-			pr_info(KERN_INFO "\n  0x%4x: ", i);
+			pr_info("\n  0x%4x: ", i);
 
 		pr_info("%02X ", c[i]);
 	}

Please fix this by using print_hex_dump (and family) instead

Something like:
http://www.spinics.net/lists/linux-driver-devel/msg55075.html

#5 lore raw

PATCH v3 1/2 staging: gs_fpgaboot: Use print_hex_dump_bytes instead of pr_info

From: Joe Perches <[email protected]>

Use print_hex_dump_bytes instead of pr_info

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -23
index 6aa9d7c..9764a9a 100644
@@ -46,27 +46,6 @@ static char	*file = "xlinx_fpga_firmware.bit";
 module_param(file, charp, S_IRUGO);
 MODULE_PARM_DESC(file, "Xilinx FPGA firmware file.");
 
-#ifdef DEBUG_FPGA
-static void datadump(char *msg, void *m, int n)
-{
-	int i;
-	unsigned char *c;
-
-	pr_info("=== %s ===\n", msg);
-
-	c = m;
-
-	for (i = 0; i < n; i++) {
-		if ((i&0xf) == 0)
-			pr_info(KERN_INFO "\n  0x%4x: ", i);
-
-		pr_info("%02X ", c[i]);
-	}
-
-	pr_info("\n");
-}
-#endif /* DEBUG_FPGA */
-
 static void read_bitstream(char *bitdata, char *buf, int *offset, int rdsize)
 {
 	memcpy(buf, bitdata + *offset, rdsize);
@@ -220,9 +199,9 @@ static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes)
 	size = fimage->lendata;
 
 #ifdef DEBUG_FPGA
-	datadump("bitfile sample", bitdata, 0x100);
+	print_hex_dump_bytes("bitfile sample: ", DUMP_PREFIX_OFFSET,
+			     bitdata, 0x100);
 #endif /* DEBUG_FPGA */
-
 	if (!xl_supported_prog_bus_width(bus_bytes)) {
 		pr_err("unsupported program bus width %d\n",
 				bus_bytes);
Signature · 1 line
2.1.2
#6 lore raw

PATCH v3 2/2 staging: gs_fpgaboot: Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -5
index 9764a9a..0c18c4c 100644
@@ -295,10 +295,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL) {
-		pr_err("No memory is available\n");
-		goto err_out;
-	}
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {
@@ -340,7 +338,6 @@ err_out2:
 err_out1:
 	kfree(fimage);
 
-err_out:
 	return -1;
 
 }
Signature · 1 line
2.1.2
#7 lore raw

Re: [PATCH v3 2/2] staging: gs_fpgaboot: Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

Quoted 26 lines · Dzmitry Sledneu

Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -4
index 9764a9a..0c18c4c 100644
@@ -295,10 +295,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL) {
-		pr_err("No memory is available\n");
-		goto err_out;
-	}
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {

drivers/staging/gs_fpgaboot/gs_fpgaboot.c err_out2: · line 343

Quoted 7 lines
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +0 -1
@@ -340,7 +338,6 @@ err_out2:
 err_out1:
 	kfree(fimage);
 
-err_out:
 	return -1;
 
 }

Doesn't apply to my tree properly :(

#8 lore raw

Re: [PATCH v3 2/2] staging: gs_fpgaboot: Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

Quoted 30 lines · Greg Kroah-Hartman
Quoted 29 lines · Dzmitry Sledneu

Fix "Possible unnecessary 'out of memory' message" checkpatch.pl warning

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -4
index 9764a9a..0c18c4c 100644
@@ -295,10 +295,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL) {
-		pr_err("No memory is available\n");
-		goto err_out;
-	}
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {
@@ -340,7 +338,6 @@ err_out2:
 err_out1:
 	kfree(fimage);
 
Quoted 7 lines

drivers/staging/gs_fpgaboot/gs_fpgaboot.c err_out2: · line 343

Quoted 4 lines
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +0 -1
-err_out:
 	return -1;
 
 }

Doesn't apply to my tree properly :(

I looked at it in your tree and it has already been fixed there.

But the fix is not quite correct, because it returns -ENOPERM (-1) it case kmalloc fails and not -ENOMEM (-12).

I will submit a new patch to fix this.

Dzmitry

#9 lore raw

PATCH v4 1/1 staging: gs_fpgaboot: Fix "out of memory" error handling

Fix "out of memory" error handling

---
 drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/gs_fpgaboot/gs_fpgaboot.c +2 -3
index cbf70ce..0c18c4c 100644
@@ -295,8 +295,8 @@ static int gs_fpgaboot(void)
 	struct fpgaimage	*fimage;
 
 	fimage = kmalloc(sizeof(struct fpgaimage), GFP_KERNEL);
-	if (fimage == NULL)
-		goto err_out;
+	if (!fimage)
+		return -ENOMEM;
 
 	err = gs_load_image(fimage, file);
 	if (err) {
@@ -338,7 +338,6 @@ err_out2:
 err_out1:
 	kfree(fimage);
 
-err_out:
 	return -1;
 
 }
Signature · 1 line
2.1.2