mfd/sm501: Adjustments for five function implementations
Subsystems (2)
cover mfd/sm501: Adjustments for five function implementations
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 16:11:22 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in two functions Improve a size determination in two functions
Adjust 12 checks for null pointers
drivers/mfd/sm501.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 mfd/sm501: Delete an error message for a failed memory allocation in two functions
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 15:40:46 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/mfd/sm501.c | 2 -- 1 file changed, 2 deletions(-)
drivers/mfd/sm501.c +0 -2
@@ -1385,7 +1385,6 @@ static int sm501_plat_probe(struct platform_device *dev) sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );if (sm =NULL ) { -dev_err (&dev->dev,"no memory for device data\n" ); ret = -ENOMEM ; goto err1; }
@@ -1575,7 +1574,6 @@ static int sm501_pci_probe(struct pci_dev *dev, sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );if (sm =NULL ) { -dev_err (&dev->dev,"no memory for device data\n" ); err = -ENOMEM ; goto err1; }
Signature · 1 line
2.15.1
Lee Jones
AppliedRe: [PATCH 1/3] mfd/sm501: Delete an error message for a failed memory allocation in two functions
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 15:40:46 +0100Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/sm501.c | 2 -- 1 file changed, 2 deletions(-)
Applied, thanks.
Signature · 8 lines
Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/3 mfd/sm501: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 15:47:03 +0100
Replace the specification of data structures by pointer dereferences 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.
--- drivers/mfd/sm501.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mfd/sm501.c +2 -4
@@ -1380,10 +1380,9 @@ static int sm501_init_dev(struct sm501_devdata *sm)static int sm501_plat_probe (struct platform_device *dev) { -struct sm501_devdata *sm;int ret; +struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); - sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );if (sm =NULL ) { ret = -ENOMEM ; goto err1;
@@ -1569,10 +1568,9 @@ static struct sm501_platdata sm501_pci_platdata = {static int sm501_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) { -struct sm501_devdata *sm;int err; +struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); - sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );if (sm =NULL ) { err = -ENOMEM ; goto err1;
Signature · 1 line
2.15.1
Re: [PATCH 2/3] mfd/sm501: Improve a size determination in two functions
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 15:47:03 +0100Replace the specification of data structures by pointer dereferences 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 <[email protected]>--- drivers/mfd/sm501.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/mfd/sm501.c +0
-0
drivers/mfd/sm501.c static int sm501_init_dev(struct sm501_devdata *sm) · line 1386
Quoted 8 lines
drivers/mfd/sm501.c +1
-2@@ -1380,10 +1380,9 @@ static int sm501_init_dev(struct sm501_devdata *sm)static int sm501_plat_probe (struct platform_device *dev) { -struct sm501_devdata *sm;int ret; +struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); - sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );
Leave this here please.
Just s/struct sm501_devdata/*sm/
drivers/mfd/sm501.c static struct sm501_platdata sm501_pci_platdata = { · line 1575
Quoted 12 lines
drivers/mfd/sm501.c +1
-2if (sm =NULL ) { ret = -ENOMEM ; goto err1;@@ -1569,10 +1568,9 @@ static struct sm501_platdata sm501_pci_platdata = {static int sm501_pci_probe (struct pci_dev *dev,const struct pci_device_id *id) { -struct sm501_devdata *sm;int err; +struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); - sm =kzalloc (sizeof (struct sm501_devdata ),GFP_KERNEL );
As above.
Quoted 3 lines
drivers/mfd/sm501.c +0
-0if (sm =NULL ) { err = -ENOMEM ; goto err1;
Signature · 8 lines
Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 mfd/sm501: Adjust 12 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 16:00:22 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Thus fix the affected source code places.
--- drivers/mfd/sm501.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/mfd/sm501.c +11 -15
@@ -1050,13 +1050,13 @@ static int sm501_register_gpio(struct sm501_devdata *sm)spin_lock_init (&gpio->lock); gpio->regs_res =request_mem_region (iobase,0x20 ,"sm501-gpio" ); -if (gpio->regs_res =NULL ) { +if (!gpio->regs_res) {dev_err (sm->dev,"gpio: failed to request region\n" );return -ENXIO ; } gpio->regs =ioremap (iobase,0x20 ); -if (gpio->regs =NULL ) { +if (!gpio->regs) {dev_err (sm->dev,"gpio: failed to remap registers\n" ); ret = -ENXIO ; goto err_claimed;
@@ -1358,7 +1358,7 @@ static int sm501_init_dev(struct sm501_devdata *sm)sm501_register_gpio (sm); } -if (pdata && pdata->gpio_i2c !=NULL && pdata->gpio_i2c_nr >0 ) { +if (pdata && pdata->gpio_i2c && pdata->gpio_i2c_nr >0 ) {if (!sm501_gpio_isregistered (sm))dev_err (sm->dev,"no gpio available for i2c gpio.\n" );else
@@ -1383,7 +1383,7 @@ static int sm501_plat_probe(struct platform_device *dev)int ret;struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); -if (sm =NULL ) { +if (!sm) { ret = -ENOMEM ; goto err1; }
@@ -1401,8 +1401,7 @@ static int sm501_plat_probe(struct platform_device *dev) sm->io_res =platform_get_resource (dev,IORESOURCE_MEM ,1 ); sm->mem_res =platform_get_resource (dev,IORESOURCE_MEM ,0 ); - -if (sm->io_res =NULL || sm->mem_res =NULL ) { +if (!sm->io_res || !sm->mem_res) {dev_err (&dev->dev,"failed to get IO resource\n" ); ret = -ENOENT ; goto err_res;
@@ -1410,8 +1409,7 @@ static int sm501_plat_probe(struct platform_device *dev) sm->regs_claim =request_mem_region (sm->io_res->start,0x100 ,"sm501" ); - -if (sm->regs_claim =NULL ) { +if (!sm->regs_claim) {dev_err (&dev->dev,"cannot claim registers\n" ); ret = -EBUSY ; goto err_res;
@@ -1420,8 +1418,7 @@ static int sm501_plat_probe(struct platform_device *dev)platform_set_drvdata (dev, sm); sm->regs =ioremap (sm->io_res->start,resource_size (sm->io_res)); - -if (sm->regs =NULL ) { +if (!sm->regs) {dev_err (&dev->dev,"cannot remap registers\n" ); ret = -EIO ; goto err_claim;
@@ -1447,7 +1444,7 @@ static void sm501_set_power(struct sm501_devdata *sm, int on) {struct sm501_platdata *pd = sm->platdata; -if (pd =NULL ) +if (!pd)return ;if (pd->get_power) {
@@ -1571,7 +1568,7 @@ static int sm501_pci_probe(struct pci_dev *dev,int err;struct sm501_devdata *sm =kzalloc (sizeof (*sm),GFP_KERNEL ); -if (sm =NULL ) { +if (!sm) { err = -ENOMEM ; goto err1; }
@@ -1622,15 +1619,14 @@ static int sm501_pci_probe(struct pci_dev *dev, sm->regs_claim =request_mem_region (sm->io_res->start,0x100 ,"sm501" ); -if (sm->regs_claim =NULL ) { +if (!sm->regs_claim) {dev_err (&dev->dev,"cannot claim registers\n" ); err= -EBUSY ; goto err3; } sm->regs =pci_ioremap_bar (dev,1 ); - -if (sm->regs =NULL ) { +if (!sm->regs) {dev_err (&dev->dev,"cannot remap registers\n" ); err = -EIO ; goto err4;
Signature · 1 line
2.15.1
Lee Jones
AppliedRe: [PATCH 3/3] mfd/sm501: Adjust 12 checks for null pointers
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 16:00:22 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl” pointed information out like the following.
Quoted 8 lines
Comparison to NULL could be written …
Thus fix the affected source code places.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/sm501.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
Applied, thanks.
Signature · 4 lines
Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 3/3] mfd/sm501: Adjust 12 checks for null pointers
Quoted 12 lines · Lee Jones
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jan 2018 16:00:22 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Quoted 8 lines
Quoted 6 lines
Thus fix the affected source code places.
Signed-off-by Markus Elfring <[email protected]>--- drivers/mfd/sm501.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)Applied, thanks.
This patch does not apply.
Please rebase and resend.
Signature · 4 lines
Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [3/3] mfd/sm501: Adjust 12 checks for null pointers
Quoted 1 line
This patch does not apply.
This change possibility partly depends on the update step “[PATCH 2/3] mfd/sm501: Improve a size determination in two functions” which you did not like yesterday.
https://lkml.org/lkml/2018/1/22/564
Quoted 1 line
Please rebase and resend.
Will the change acceptance grow then really?
Do you find the proposed source code transformation generally acceptable?
Regards,
Markus