Skip to contentSkip to conversation

CoreSight-ETB10: Adjustments for three function implementations

PATCH In review SF Markus Elfring 2 participants 8 messages May 12, 2017 – May 15, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover CoreSight-ETB10: Adjustments for three function implementations

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:46:54 +0200

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

Markus Elfring (3):
Delete an error message for a failed memory allocation in etb_probe() Fix a typo in a comment line
Improve a size determination in etb_alloc_buffer()

 drivers/hwtracing/coresight/coresight-etb10.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.12.3
#1 lore raw

PATCH 1/3 coresight: etb10: Delete an error message for a failed memory allocation in etb_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:23:43 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -4
index 979ea6ec7902..837aebf22c45 100644
@@ -675,11 +675,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 
 	drvdata->buf = devm_kzalloc(dev,
 				    drvdata->buffer_depth * 4, GFP_KERNEL);
-	if (!drvdata->buf) {
-		dev_err(dev, "Failed to allocate %u bytes for buffer data\n",
-			drvdata->buffer_depth * 4);
+	if (!drvdata->buf)
 		return -ENOMEM;
-	}
 
 	desc.type = CORESIGHT_DEV_TYPE_SINK;
 	desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
Signature · 1 line
2.12.3
#3 lore raw

PATCH 2/3 coresight: etb10: Fix a typo in a comment line

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:30:42 +0200

Delete a character in this description for a condition check.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -1
index 837aebf22c45..d5b96423e1a5 100644
@@ -375,7 +375,7 @@ static void etb_update_buffer(struct coresight_device *csdev,
 
 	/*
 	 * Entries should be aligned to the frame size.  If they are not
-	 * go back to the last alignement point to give decoding tools a
+	 * go back to the last alignment point to give decoding tools a
 	 * chance to fix things.
 	 */
 	if (write_ptr % ETB_FRAME_SIZE_WORDS) {
Signature · 1 line
2.12.3
#5 lore raw

PATCH 3/3 coresight: etb10: Improve a size determination in etb_alloc_buffer()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:36:03 +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.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +1 -2
index d5b96423e1a5..7096c4562e15 100644
@@ -278,8 +278,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
 	if (cpu = -1)
 		cpu = smp_processor_id();
 	node = cpu_to_node(cpu);
-
-	buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
+	buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, node);
 	if (!buf)
 		return NULL;
 
Signature · 1 line
2.12.3
#2 lore raw

Re: [PATCH 1/3] coresight: etb10: Delete an error message for a failed memory allocation in etb_probe()

In reply to SF Markus Elfring
Quoted 20 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:23:43 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +0 -0
index 979ea6ec7902..837aebf22c45 100644
@@ -675,11 +675,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
 
        drvdata->buf = devm_kzalloc(dev,

drivers/hwtracing/coresight/coresight-etb10.c static int etb_probe(struct amba_device *adev, const struct amba_id *id) · line 682

Quoted 10 lines
drivers/hwtracing/coresight/coresight-etb10.c +1 -4
                                    drvdata->buffer_depth * 4, GFP_KERNEL);
-       if (!drvdata->buf) {
-               dev_err(dev, "Failed to allocate %u bytes for buffer data\n",
-                       drvdata->buffer_depth * 4);
+       if (!drvdata->buf)
                return -ENOMEM;
-       }
 
        desc.type = CORESIGHT_DEV_TYPE_SINK;
        desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;

Applied - thanks.

Quoted 3 lines

--
2.12.3

#4 lore raw

Re: [PATCH 2/3] coresight: etb10: Fix a typo in a comment line

In reply to SF Markus Elfring
Quoted 15 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:30:42 +0200

Delete a character in this description for a condition check.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etb10.c +0 -0
index 837aebf22c45..d5b96423e1a5 100644

drivers/hwtracing/coresight/coresight-etb10.c static void etb_update_buffer(struct coresight_device *csdev, · line 381

Quoted 8 lines
drivers/hwtracing/coresight/coresight-etb10.c +1 -1
@@ -375,7 +375,7 @@ static void etb_update_buffer(struct coresight_device *csdev,
 
        /*
         * Entries should be aligned to the frame size.  If they are not
-        * go back to the last alignement point to give decoding tools a
+        * go back to the last alignment point to give decoding tools a
         * chance to fix things.
         */
        if (write_ptr % ETB_FRAME_SIZE_WORDS) {

Applied - thanks.

Quoted 3 lines

--
2.12.3

#6 lore raw

Re: [PATCH 3/3] coresight: etb10: Improve a size determination in etb_alloc_buffer()

In reply to SF Markus Elfring
Quoted 17 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 May 2017 20:36:03 +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.

---
 drivers/hwtracing/coresight/coresight-etb10.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-etb10.c +0 -0
index d5b96423e1a5..7096c4562e15 100644

drivers/hwtracing/coresight/coresight-etb10.c static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, · line 281

Quoted 6 lines
drivers/hwtracing/coresight/coresight-etb10.c +1 -2
@@ -278,8 +278,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
        if (cpu = -1)
                cpu = smp_processor_id();
        node = cpu_to_node(cpu);
-
-       buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
+       buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, node);

I'm fine with this change but if it's going to happen, it has to be in all the coresight drivers and not just this one - please respin with all instances fixed. One patch per driver would be much appreciated.

Thanks,
Mathieu

Quoted 11 lines
drivers/hwtracing/coresight/coresight-etb10.c +0 -1
        if (!buf)
                return NULL;
 
--

2.12.3

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw

Re: [PATCH 3/3] coresight: etb10: Improve a size determination in etb_alloc_buffer()

Quoted 4 lines
Quoted 4 lines

+++ b/drivers/hwtracing/coresight/coresight-etb10.c

drivers/hwtracing/coresight/coresight-etb10.c +0 -0
@@ -278,8 +278,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
        if (cpu = -1)
                cpu = smp_processor_id();
Quoted 8 lines

drivers/hwtracing/coresight/coresight-etb10.c static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, · line 281

Quoted 4 lines
drivers/hwtracing/coresight/coresight-etb10.c +1 -2
        node = cpu_to_node(cpu);
-
-       buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
+       buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, node);

I'm fine with this change but if it's going to happen, it has to be in all the coresight drivers and not just this one - please respin with all instances fixed. One patch per driver would be much appreciated.

Do you imagine that any more modules are affected in a similar way for this software area?

How do you think about other update suggestions from my selection which are waiting for a corresponding review?

Regards,
Markus