* [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe()
@ 2017-10-04 18:43 SF Markus Elfring
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:43 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 20:33:20 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an error message for a failed memory allocation
Improve a size determination
Delete a jump target
Delete an unnecessary local variable
Split a condition check
arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 17 ++++----------
arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 31 ++++++++++++--------------
2 files changed, 18 insertions(+), 30 deletions(-)
--
2.14.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
@ 2017-10-04 18:45 ` SF Markus Elfring
2017-10-04 19:44 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Alexander Sverdlin
2017-10-04 20:16 ` Alexander Sverdlin
2017-10-04 18:46 ` [PATCH 2/5] cris: nand: Improve a size determination in crisv32_nand_flash_probe() SF Markus Elfring
` (4 subsequent siblings)
5 siblings, 2 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:45 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 17:54:11 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 --
arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 --
2 files changed, 4 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index 925a98eb6d68..259aa1f46fbe 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -136,8 +136,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Allocate memory for MTD device structure and private data */
wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
if (!wrapper) {
- printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
- "device structure.\n");
err = -ENOMEM;
return NULL;
}
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 53b56a429dde..1baf16ee74e8 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -111,8 +111,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Allocate memory for MTD device structure and private data */
wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
if (!wrapper) {
- printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
- "device structure.\n");
err = -ENOMEM;
return NULL;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/5] cris: nand: Improve a size determination in crisv32_nand_flash_probe()
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
@ 2017-10-04 18:46 ` SF Markus Elfring
2017-10-04 18:47 ` [PATCH 3/5] cris: nand: Delete a jump target " SF Markus Elfring
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:46 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 18:00:33 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 +-
arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index 259aa1f46fbe..3b5be9b984b4 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -134,7 +134,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
REG_WR(pio, regi_pio, rw_oe, oe);
/* Allocate memory for MTD device structure and private data */
- wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
+ wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
if (!wrapper) {
err = -ENOMEM;
return NULL;
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 1baf16ee74e8..5dfd72a89b8a 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -109,7 +109,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
int err = 0;
/* Allocate memory for MTD device structure and private data */
- wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
+ wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
if (!wrapper) {
err = -ENOMEM;
return NULL;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/5] cris: nand: Delete a jump target in crisv32_nand_flash_probe()
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
2017-10-04 18:46 ` [PATCH 2/5] cris: nand: Improve a size determination in crisv32_nand_flash_probe() SF Markus Elfring
@ 2017-10-04 18:47 ` SF Markus Elfring
2017-10-04 18:48 ` [PATCH 4/5] cris: nand: Delete an unnecessary local variable " SF Markus Elfring
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:47 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 18:55:01 +0200
* Move a bit of exception handling code into an if branch
because the code was used only for one case before.
* Delete the jump target "out_mtd" which became unnecessary
with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index 3b5be9b984b4..f30579ec8ad7 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -163,13 +163,10 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Scan to find existence of the device */
if (nand_scan(crisv32_mtd, 1)) {
err = -ENXIO;
- goto out_mtd;
+ kfree(wrapper);
+ return NULL;
}
return crisv32_mtd;
-
-out_mtd:
- kfree(wrapper);
- return NULL;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/5] cris: nand: Delete an unnecessary local variable in crisv32_nand_flash_probe()
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
` (2 preceding siblings ...)
2017-10-04 18:47 ` [PATCH 3/5] cris: nand: Delete a jump target " SF Markus Elfring
@ 2017-10-04 18:48 ` SF Markus Elfring
2017-10-04 20:17 ` Alexander Sverdlin
2017-10-04 18:50 ` [PATCH 5/5] cris: nand: Split a condition check " SF Markus Elfring
2017-10-05 15:31 ` [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() Gregory CLEMENT
5 siblings, 1 reply; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:48 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 19:32:18 +0200
The local variable "err" was never read in this function.
Thus remove it.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 6 +-----
arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 10 ++--------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index f30579ec8ad7..03a01bfa6ad9 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -108,7 +108,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
struct mtd_info_wrapper *wrapper;
struct nand_chip *this;
- int err = 0;
reg_pio_rw_man_ctrl man_ctrl = {
.regf_NCE = regk_pio_yes,
@@ -135,10 +134,8 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Allocate memory for MTD device structure and private data */
wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
- if (!wrapper) {
- err = -ENOMEM;
+ if (!wrapper)
return NULL;
- }
read_cs = write_cs = (void __iomem *)REG_ADDR(pio, regi_pio,
rw_io_access0);
@@ -162,7 +159,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Scan to find existence of the device */
if (nand_scan(crisv32_mtd, 1)) {
- err = -ENXIO;
kfree(wrapper);
return NULL;
}
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 5dfd72a89b8a..2b53f0c615ea 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -106,21 +106,17 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
reg_gio_rw_pa_oe pa_oe = REG_RD(gio, regi_gio, rw_pa_oe);
struct mtd_info_wrapper *wrapper;
struct nand_chip *this;
- int err = 0;
/* Allocate memory for MTD device structure and private data */
wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
- if (!wrapper) {
- err = -ENOMEM;
+ if (!wrapper)
return NULL;
- }
read_cs = ioremap(MEM_CSP0_START | MEM_NON_CACHEABLE, 8192);
write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
if (!read_cs || !write_cs) {
printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
- err = -EIO;
goto out_mtd;
}
@@ -152,10 +148,8 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* this->bbt_options = NAND_BBT_USE_FLASH; */
/* Scan to find existence of the device */
- if (nand_scan(crisv32_mtd, 1)) {
- err = -ENXIO;
+ if (nand_scan(crisv32_mtd, 1))
goto out_ior;
- }
return crisv32_mtd;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/5] cris: nand: Split a condition check in crisv32_nand_flash_probe()
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
` (3 preceding siblings ...)
2017-10-04 18:48 ` [PATCH 4/5] cris: nand: Delete an unnecessary local variable " SF Markus Elfring
@ 2017-10-04 18:50 ` SF Markus Elfring
2017-10-05 15:31 ` [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() Gregory CLEMENT
5 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 18:50 UTC (permalink / raw)
To: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 20:02:12 +0200
* Split a condition check for failed calls of the function "ioremap"
so that the return value in the variable "write_cs" will also be
immediately checked.
* Adjust jump targets according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index 2b53f0c615ea..564218a12213 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -113,13 +113,17 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
return NULL;
read_cs = ioremap(MEM_CSP0_START | MEM_NON_CACHEABLE, 8192);
- write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
-
- if (!read_cs || !write_cs) {
+ if (!read_cs) {
printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
goto out_mtd;
}
+ write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
+ if (!write_cs) {
+ printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
+ goto unmap_read;
+ }
+
/* Get pointer to private data */
this = &wrapper->chip;
crisv32_mtd = nand_to_mtd(this);
@@ -149,13 +153,14 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
/* Scan to find existence of the device */
if (nand_scan(crisv32_mtd, 1))
- goto out_ior;
+ goto unmap_io;
return crisv32_mtd;
-out_ior:
- iounmap((void *)read_cs);
+unmap_io:
iounmap((void *)write_cs);
+unmap_read:
+ iounmap((void *)read_cs);
out_mtd:
kfree(wrapper);
return NULL;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
@ 2017-10-04 19:44 ` Alexander Sverdlin
2017-10-04 19:55 ` cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 20:12 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Julia Lawall
2017-10-04 20:16 ` Alexander Sverdlin
1 sibling, 2 replies; 12+ messages in thread
From: Alexander Sverdlin @ 2017-10-04 19:44 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-cris-kernel, Boris Brezillon, Gregory Clement,
Jesper Nilsson, Krzysztof Halasa, Mikael Starvik, Neil Armstrong,
Shawn Guo, Tony Lindgren, Vladimir Zapolskiy, LKML,
kernel-janitors
Hello Markus,
On Wed, 4 Oct 2017 20:45:14 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
what exactly has the software detected?
I cannot find, how this error is reported otherwise, it seems
to me that the message is not that superflous.
The patches 2..4 look to me as an exercise without any practical meaning.
Indeed, that's not how new code should be posted, but if we start
rewriting all the legacy code, this will produce huge and completely
unnecessary patch traffic.
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 --
> arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> index 925a98eb6d68..259aa1f46fbe 100644
> --- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> @@ -136,8 +136,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> if (!wrapper) {
> - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> - "device structure.\n");
> err = -ENOMEM;
> return NULL;
> }
> diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> index 53b56a429dde..1baf16ee74e8 100644
> --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> @@ -111,8 +111,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> if (!wrapper) {
> - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> - "device structure.\n");
> err = -ENOMEM;
> return NULL;
> }
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash_probe()
2017-10-04 19:44 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Alexander Sverdlin
@ 2017-10-04 19:55 ` SF Markus Elfring
2017-10-04 20:12 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Julia Lawall
1 sibling, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-04 19:55 UTC (permalink / raw)
To: Alexander Sverdlin, linux-cris-kernel
Cc: Boris Brezillon, Gregory Clement, Jesper Nilsson,
Krzysztof Halasa, Mikael Starvik, Neil Armstrong, Shawn Guo,
Tony Lindgren, Vladimir Zapolskiy, LKML, kernel-janitors
>> Omit an extra message for a memory allocation failure in this function.
>>
>> This issue was detected by using the Coccinelle software.
>
> what exactly has the software detected?
Do you prefer the notification “WARNING: Possible unnecessary 'out of memory' message”
by the script “checkpatch.pl” instead?
> I cannot find, how this error is reported otherwise, it seems
> to me that the message is not that superflous.
Would you find the default allocation failure report sufficient?
Regards,
Markus
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f
2017-10-04 19:44 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Alexander Sverdlin
2017-10-04 19:55 ` cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash_probe() SF Markus Elfring
@ 2017-10-04 20:12 ` Julia Lawall
1 sibling, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2017-10-04 20:12 UTC (permalink / raw)
To: Alexander Sverdlin
Cc: SF Markus Elfring, linux-cris-kernel, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy,
LKML, kernel-janitors
On Wed, 4 Oct 2017, Alexander Sverdlin wrote:
> Hello Markus,
>
> On Wed, 4 Oct 2017 20:45:14 +0200
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
>
> > Omit an extra message for a memory allocation failure in this function.
> >
> > This issue was detected by using the Coccinelle software.
>
> what exactly has the software detected?
> I cannot find, how this error is reported otherwise, it seems
> to me that the message is not that superflous.
>
> The patches 2..4 look to me as an exercise without any practical meaning.
> Indeed, that's not how new code should be posted, but if we start
> rewriting all the legacy code, this will produce huge and completely
> unnecessary patch traffic.
kmalloc etc will produce a backtrace on failure that will provide
essentially the same information.
I don't know what was in the other patches, but the useless assignments to
err in these functions are perhaps worth fixing.
julia
>
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> > arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 --
> > arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 --
> > 2 files changed, 4 deletions(-)
> >
> > diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> > index 925a98eb6d68..259aa1f46fbe 100644
> > --- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> > +++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> > @@ -136,8 +136,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> > /* Allocate memory for MTD device structure and private data */
> > wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> > if (!wrapper) {
> > - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> > - "device structure.\n");
> > err = -ENOMEM;
> > return NULL;
> > }
> > diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> > index 53b56a429dde..1baf16ee74e8 100644
> > --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> > +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> > @@ -111,8 +111,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> > /* Allocate memory for MTD device structure and private data */
> > wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> > if (!wrapper) {
> > - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> > - "device structure.\n");
> > err = -ENOMEM;
> > return NULL;
> > }
>
> --
> Alexander Sverdlin.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
2017-10-04 19:44 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Alexander Sverdlin
@ 2017-10-04 20:16 ` Alexander Sverdlin
1 sibling, 0 replies; 12+ messages in thread
From: Alexander Sverdlin @ 2017-10-04 20:16 UTC (permalink / raw)
To: SF Markus Elfring, linux-cris-kernel, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
On 04/10/17 20:45, SF Markus Elfring wrote:
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 2 --
> arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> index 925a98eb6d68..259aa1f46fbe 100644
> --- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> @@ -136,8 +136,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> if (!wrapper) {
> - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> - "device structure.\n");
> err = -ENOMEM;
> return NULL;
> }
> diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> index 53b56a429dde..1baf16ee74e8 100644
> --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> @@ -111,8 +111,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(struct mtd_info_wrapper), GFP_KERNEL);
> if (!wrapper) {
> - printk(KERN_ERR "Unable to allocate CRISv32 NAND MTD "
> - "device structure.\n");
> err = -ENOMEM;
> return NULL;
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/5] cris: nand: Delete an unnecessary local variable in crisv32_nand_flash_probe()
2017-10-04 18:48 ` [PATCH 4/5] cris: nand: Delete an unnecessary local variable " SF Markus Elfring
@ 2017-10-04 20:17 ` Alexander Sverdlin
0 siblings, 0 replies; 12+ messages in thread
From: Alexander Sverdlin @ 2017-10-04 20:17 UTC (permalink / raw)
To: SF Markus Elfring, linux-cris-kernel, Boris Brezillon,
Gregory Clement, Jesper Nilsson, Krzysztof Halasa, Mikael Starvik,
Neil Armstrong, Shawn Guo, Tony Lindgren, Vladimir Zapolskiy
Cc: LKML, kernel-janitors
On 04/10/17 20:48, SF Markus Elfring wrote:
> The local variable "err" was never read in this function.
> Thus remove it.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 6 +-----
> arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 10 ++--------
> 2 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> index f30579ec8ad7..03a01bfa6ad9 100644
> --- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
> @@ -108,7 +108,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
>
> struct mtd_info_wrapper *wrapper;
> struct nand_chip *this;
> - int err = 0;
>
> reg_pio_rw_man_ctrl man_ctrl = {
> .regf_NCE = regk_pio_yes,
> @@ -135,10 +134,8 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
>
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
> - if (!wrapper) {
> - err = -ENOMEM;
> + if (!wrapper)
> return NULL;
> - }
>
> read_cs = write_cs = (void __iomem *)REG_ADDR(pio, regi_pio,
> rw_io_access0);
> @@ -162,7 +159,6 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
>
> /* Scan to find existence of the device */
> if (nand_scan(crisv32_mtd, 1)) {
> - err = -ENXIO;
> kfree(wrapper);
> return NULL;
> }
> diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> index 5dfd72a89b8a..2b53f0c615ea 100644
> --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> @@ -106,21 +106,17 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> reg_gio_rw_pa_oe pa_oe = REG_RD(gio, regi_gio, rw_pa_oe);
> struct mtd_info_wrapper *wrapper;
> struct nand_chip *this;
> - int err = 0;
>
> /* Allocate memory for MTD device structure and private data */
> wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
> - if (!wrapper) {
> - err = -ENOMEM;
> + if (!wrapper)
> return NULL;
> - }
>
> read_cs = ioremap(MEM_CSP0_START | MEM_NON_CACHEABLE, 8192);
> write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
>
> if (!read_cs || !write_cs) {
> printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
> - err = -EIO;
> goto out_mtd;
> }
>
> @@ -152,10 +148,8 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> /* this->bbt_options = NAND_BBT_USE_FLASH; */
>
> /* Scan to find existence of the device */
> - if (nand_scan(crisv32_mtd, 1)) {
> - err = -ENXIO;
> + if (nand_scan(crisv32_mtd, 1))
> goto out_ior;
> - }
>
> return crisv32_mtd;
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe()
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
` (4 preceding siblings ...)
2017-10-04 18:50 ` [PATCH 5/5] cris: nand: Split a condition check " SF Markus Elfring
@ 2017-10-05 15:31 ` Gregory CLEMENT
5 siblings, 0 replies; 12+ messages in thread
From: Gregory CLEMENT @ 2017-10-05 15:31 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-cris-kernel, Alexander Sverdlin, Boris Brezillon,
Jesper Nilsson, Krzysztof Halasa, Mikael Starvik, Neil Armstrong,
Shawn Guo, Tony Lindgren, Vladimir Zapolskiy, LKML,
kernel-janitors
Hi Markus,
On mer., oct. 04 2017, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Oct 2017 20:33:20 +0200
>
> A few update suggestions were taken into account
> from static source code analysis.
If you plan to send a v2 could you remove me from the CC.
I know that ./scripts/get_maintainer.pl added my name but I am not
related at all to this code. I just gave my acked-by for a part of patch
which modified in the same time the file I care and many other files.
Thanks,
Greogry
>
> Markus Elfring (5):
> Delete an error message for a failed memory allocation
> Improve a size determination
> Delete a jump target
> Delete an unnecessary local variable
> Split a condition check
>
> arch/cris/arch-v32/drivers/mach-a3/nandflash.c | 17 ++++----------
> arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 31 ++++++++++++--------------
> 2 files changed, 18 insertions(+), 30 deletions(-)
>
> --
> 2.14.2
>
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-10-05 15:31 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash SF Markus Elfring
2017-10-04 19:44 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Alexander Sverdlin
2017-10-04 19:55 ` cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 20:12 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_f Julia Lawall
2017-10-04 20:16 ` Alexander Sverdlin
2017-10-04 18:46 ` [PATCH 2/5] cris: nand: Improve a size determination in crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 18:47 ` [PATCH 3/5] cris: nand: Delete a jump target " SF Markus Elfring
2017-10-04 18:48 ` [PATCH 4/5] cris: nand: Delete an unnecessary local variable " SF Markus Elfring
2017-10-04 20:17 ` Alexander Sverdlin
2017-10-04 18:50 ` [PATCH 5/5] cris: nand: Split a condition check " SF Markus Elfring
2017-10-05 15:31 ` [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() Gregory CLEMENT
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).