mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe()
@ 2018-01-08 16:10 SF Markus Elfring
  2018-01-08 16:15 ` [PATCH 1/4] misc/ioc4: Return -ENOMEM after a failed kmalloc() in ioc4_probe() SF Markus Elfring
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: SF Markus Elfring @ 2018-01-08 16:10 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Brent Casavant,
	Greg Kroah-Hartman, Jeremy Higdon, Pat Gefre
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jan 2018 17:01:23 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
  Return -ENOMEM after a failed kmalloc()
  Delete an error message for a failed memory allocation
  Improve a size determination
  Adjust one function call together with a variable assignment

 drivers/misc/ioc4.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] misc/ioc4: Return -ENOMEM after a failed kmalloc() in ioc4_probe()
  2018-01-08 16:10 [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe() SF Markus Elfring
@ 2018-01-08 16:15 ` SF Markus Elfring
  2018-01-08 16:16 ` [PATCH 2/4] misc/ioc4: Delete an error message for a failed memory allocation " SF Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2018-01-08 16:15 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Brent Casavant,
	Greg Kroah-Hartman, Jeremy Higdon, Pat Gefre
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jan 2018 16:12:52 +0100

Replace an error code for the indication of a memory allocation failure
in this function.

Fixes: 22329b511a97557b293583194037d1f4c71e1504 ("ioc4: Core driver rewrite")

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/ioc4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index ec0832278170..63a64104d2da 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -300,7 +300,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 		printk(KERN_WARNING
 		       "%s: Failed to allocate IOC4 data for pci_dev %s.\n",
 		       __func__, pci_name(pdev));
-		ret = -ENODEV;
+		ret = -ENOMEM;
 		goto out_idd;
 	}
 	idd->idd_pdev = pdev;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] misc/ioc4: Delete an error message for a failed memory allocation in ioc4_probe()
  2018-01-08 16:10 [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe() SF Markus Elfring
  2018-01-08 16:15 ` [PATCH 1/4] misc/ioc4: Return -ENOMEM after a failed kmalloc() in ioc4_probe() SF Markus Elfring
@ 2018-01-08 16:16 ` SF Markus Elfring
  2018-01-08 16:17 ` [PATCH 3/4] misc/ioc4: Improve a size determination " SF Markus Elfring
  2018-01-08 16:19 ` [PATCH 4/4] misc/ioc4: Adjust one function call together with a variable assignment SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2018-01-08 16:16 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Brent Casavant,
	Greg Kroah-Hartman, Jeremy Higdon, Pat Gefre
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jan 2018 16:14:49 +0100

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>
---
 drivers/misc/ioc4.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 63a64104d2da..5bd422498fff 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -297,9 +297,6 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	/* Set up per-IOC4 data */
 	idd = kmalloc(sizeof(struct ioc4_driver_data), GFP_KERNEL);
 	if (!idd) {
-		printk(KERN_WARNING
-		       "%s: Failed to allocate IOC4 data for pci_dev %s.\n",
-		       __func__, pci_name(pdev));
 		ret = -ENOMEM;
 		goto out_idd;
 	}
-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] misc/ioc4: Improve a size determination in ioc4_probe()
  2018-01-08 16:10 [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe() SF Markus Elfring
  2018-01-08 16:15 ` [PATCH 1/4] misc/ioc4: Return -ENOMEM after a failed kmalloc() in ioc4_probe() SF Markus Elfring
  2018-01-08 16:16 ` [PATCH 2/4] misc/ioc4: Delete an error message for a failed memory allocation " SF Markus Elfring
@ 2018-01-08 16:17 ` SF Markus Elfring
  2018-01-08 16:19 ` [PATCH 4/4] misc/ioc4: Adjust one function call together with a variable assignment SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2018-01-08 16:17 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Brent Casavant,
	Greg Kroah-Hartman, Jeremy Higdon, Pat Gefre
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jan 2018 16:18:52 +0100

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>
---
 drivers/misc/ioc4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 5bd422498fff..704e13382df0 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -295,7 +295,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	pci_set_master(pdev);
 
 	/* Set up per-IOC4 data */
-	idd = kmalloc(sizeof(struct ioc4_driver_data), GFP_KERNEL);
+	idd = kmalloc(sizeof(*idd), GFP_KERNEL);
 	if (!idd) {
 		ret = -ENOMEM;
 		goto out_idd;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] misc/ioc4: Adjust one function call together with a variable assignment
  2018-01-08 16:10 [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe() SF Markus Elfring
                   ` (2 preceding siblings ...)
  2018-01-08 16:17 ` [PATCH 3/4] misc/ioc4: Improve a size determination " SF Markus Elfring
@ 2018-01-08 16:19 ` SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2018-01-08 16:19 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Brent Casavant,
	Greg Kroah-Hartman, Jeremy Higdon, Pat Gefre
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jan 2018 16:43:21 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/ioc4.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 704e13382df0..8381dd9c7dd9 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -283,10 +283,11 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	struct ioc4_driver_data *idd;
 	struct ioc4_submodule *is;
 	uint32_t pcmd;
-	int ret;
 
 	/* Enable IOC4 and take ownership of it */
-	if ((ret = pci_enable_device(pdev))) {
+	int ret = pci_enable_device(pdev);
+
+	if (ret) {
 		printk(KERN_WARNING
 		       "%s: Failed to enable IOC4 device for pci_dev %s.\n",
 		       __func__, pci_name(pdev));
-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-08 16:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-08 16:10 [PATCH 0/4] misc-IOC4: Adjustments for ioc4_probe() SF Markus Elfring
2018-01-08 16:15 ` [PATCH 1/4] misc/ioc4: Return -ENOMEM after a failed kmalloc() in ioc4_probe() SF Markus Elfring
2018-01-08 16:16 ` [PATCH 2/4] misc/ioc4: Delete an error message for a failed memory allocation " SF Markus Elfring
2018-01-08 16:17 ` [PATCH 3/4] misc/ioc4: Improve a size determination " SF Markus Elfring
2018-01-08 16:19 ` [PATCH 4/4] misc/ioc4: Adjust one function call together with a variable assignment SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®