linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ARM: dmabounce: Adjustments for four function implementations
@ 2017-06-01 15:56 SF Markus Elfring
  2017-06-01 15:59 ` [PATCH 1/3] ARM: dmabounce: Improve a size determination in two functions SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-06-01 15:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Jun 2017 17:34:56 +0200

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

Markus Elfring (3):
  Improve a size determination in two functions
  Delete an error message for a failed memory allocation in two functions
  Combine substrings for two messages

 arch/arm/common/dmabounce.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

-- 
2.13.0

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

* [PATCH 1/3] ARM: dmabounce: Improve a size determination in two functions
  2017-06-01 15:56 [PATCH 0/3] ARM: dmabounce: Adjustments for four function implementations SF Markus Elfring
@ 2017-06-01 15:59 ` SF Markus Elfring
  2017-06-01 16:00 ` [PATCH 2/3] ARM: dmabounce: Delete an error message for a failed memory allocation " SF Markus Elfring
  2017-06-01 16:02 ` [PATCH 3/3] ARM: dmabounce: Combine substrings for two messages SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-06-01 15:59 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Jun 2017 17:00:17 +0200

Replace the specification of two 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/common/dmabounce.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 9b1b7be2ec0e..fcdecb2de242 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -123,5 +123,5 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr,
 		pool = NULL;
 	}
 
-	buf = kmalloc(sizeof(struct safe_buffer), GFP_ATOMIC);
+	buf = kmalloc(sizeof(*buf), GFP_ATOMIC);
 	if (buf == NULL) {
@@ -487,5 +487,5 @@ int dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
 	struct dmabounce_device_info *device_info;
 	int ret;
 
-	device_info = kmalloc(sizeof(struct dmabounce_device_info), GFP_ATOMIC);
+	device_info = kmalloc(sizeof(*device_info), GFP_ATOMIC);
 	if (!device_info) {
-- 
2.13.0

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

* [PATCH 2/3] ARM: dmabounce: Delete an error message for a failed memory allocation in two functions
  2017-06-01 15:56 [PATCH 0/3] ARM: dmabounce: Adjustments for four function implementations SF Markus Elfring
  2017-06-01 15:59 ` [PATCH 1/3] ARM: dmabounce: Improve a size determination in two functions SF Markus Elfring
@ 2017-06-01 16:00 ` SF Markus Elfring
  2017-06-01 16:02 ` [PATCH 3/3] ARM: dmabounce: Combine substrings for two messages SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-06-01 16:00 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Jun 2017 17:10:39 +0200

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/common/dmabounce.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index fcdecb2de242..9ef7ab64b3d8 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -127,7 +127,5 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr,
-	if (buf == NULL) {
-		dev_warn(dev, "%s: kmalloc failed\n", __func__);
+	if (!buf)
 		return NULL;
-	}
 
 	buf->ptr = ptr;
 	buf->size = size;
@@ -491,8 +489,5 @@ int dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
-	if (!device_info) {
-		dev_err(dev,
-			"Could not allocated dmabounce_device_info\n");
+	if (!device_info)
 		return -ENOMEM;
-	}
 
 	ret = dmabounce_init_pool(&device_info->small, dev,
 				  "small_dmabounce_pool", small_buffer_size);
-- 
2.13.0

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

* [PATCH 3/3] ARM: dmabounce: Combine substrings for two messages
  2017-06-01 15:56 [PATCH 0/3] ARM: dmabounce: Adjustments for four function implementations SF Markus Elfring
  2017-06-01 15:59 ` [PATCH 1/3] ARM: dmabounce: Improve a size determination in two functions SF Markus Elfring
  2017-06-01 16:00 ` [PATCH 2/3] ARM: dmabounce: Delete an error message for a failed memory allocation " SF Markus Elfring
@ 2017-06-01 16:02 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-06-01 16:02 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Jun 2017 17:23:52 +0200

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

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm/common/dmabounce.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 9ef7ab64b3d8..e2fbdab41810 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -227,8 +227,9 @@ static int needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
 
 		limit = (mask + 1) & ~mask;
 		if (limit && size > limit) {
-			dev_err(dev, "DMA mapping too big (requested %#x "
-				"mask %#Lx)\n", size, *dev->dma_mask);
+			dev_err(dev,
+				"DMA mapping too big (requested %#x mask %#Lx)\n",
+				size, *dev->dma_mask);
 			return -E2BIG;
 		}
 
@@ -546,8 +547,7 @@ void dmabounce_unregister_dev(struct device *dev)
 
 	if (!device_info) {
 		dev_warn(dev,
-			 "Never registered with dmabounce but attempting"
-			 "to unregister!\n");
+			 "Never registered with dmabounce but attempting to unregister!\n");
 		return;
 	}
 
-- 
2.13.0

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

end of thread, other threads:[~2017-06-01 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-01 15:56 [PATCH 0/3] ARM: dmabounce: Adjustments for four function implementations SF Markus Elfring
2017-06-01 15:59 ` [PATCH 1/3] ARM: dmabounce: Improve a size determination in two functions SF Markus Elfring
2017-06-01 16:00 ` [PATCH 2/3] ARM: dmabounce: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-06-01 16:02 ` [PATCH 3/3] ARM: dmabounce: Combine substrings for two messages 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;
as well as URLs for NNTP newsgroup(s).