Skip to contentSkip to conversation

drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

PATCH Applied Gustavo A. R. Silva 3 participants 7 messages Jan 19, 2018 – Feb 15, 2018

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

PATCH 1/1 drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index c6a7609..7783250 100644
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
 	}
 
 	/* All hardware blocks have the same number of attributes. */
-	num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+	num_attrs = ARRAY_SIZE(perf_attr_iommu);
 	list_for_each_entry(perf, &dev->perf_props, list) {
 		perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
 			* num_attrs + sizeof(struct attribute_group),
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Looks good. This change is Reviewed-by: Felix Kuehling <[email protected]>

Regards,
  Felix

Quoted 14 lines · Gustavo A. R. Silva

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -0
index c6a7609..7783250 100644

drivers/gpu/drm/amd/amdkfd/kfd_topology.c static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev, · line 683

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
 	}
 
 	/* All hardware blocks have the same number of attributes. */
-	num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+	num_attrs = ARRAY_SIZE(perf_attr_iommu);
 	list_for_each_entry(perf, &dev->perf_props, list) {
 		perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
 			* num_attrs + sizeof(struct attribute_group),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#3 lore raw
Quoted 11 lines · Gustavo A. R. Silva

Quoting Felix Kuehling <[email protected]>:

Quoted 3 lines

Looks good. This change is Reviewed-by: Felix Kuehling <[email protected]>

Thanks Felix.
--
Gustavo

Applied to -next
Oded

Quoted 4 lines
#4 lore raw
In reply to Felix Kuehling

Hi all,

I was just wondering about the status of this patch.

Thanks
--
Gustavo

Quoted 31 lines · Felix Kuehling

Looks good. This change is Reviewed-by: Felix Kuehling <[email protected]>

Regards,
  Felix

Quoted 22 lines · Gustavo A. R. Silva

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index c6a7609..7783250 100644
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
  	}
 
  	/* All hardware blocks have the same number of attributes. */
-	num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+	num_attrs = ARRAY_SIZE(perf_attr_iommu);
  	list_for_each_entry(perf, &dev->perf_props, list) {
  		perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
  			* num_attrs + sizeof(struct attribute_group),
#5 lore raw

Hi Gustavo,
The patch is queued for the merge window of kernel 4.17 (opens in about 7 weeks from now).

Oded

Quoted 46 lines · Gustavo A. R. Silva

Hi all,

I was just wondering about the status of this patch.

Thanks
--
Gustavo

Quoted 35 lines · Felix Kuehling

Looks good. This change is Reviewed-by: Felix Kuehling <[email protected]>

Regards,
Felix

Quoted 24 lines · Gustavo A. R. Silva

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index c6a7609..7783250 100644
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct
 kfd_topology_device *dev,
        }
        /* All hardware blocks have the same number of attributes. */
-       num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+       num_attrs = ARRAY_SIZE(perf_attr_iommu);
        list_for_each_entry(perf, &dev->perf_props, list) {
                perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
                        * num_attrs + sizeof(struct attribute_group),

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Hi Oded,

Quoted 4 lines · Oded Gabbay

Hi Gustavo,
The patch is queued for the merge window of kernel 4.17 (opens in about 7 weeks from now).

Awesome.

Thanks for the info.
--
Gustavo

Quoted 50 lines

Oded

Quoted 46 lines · Gustavo A. R. Silva

Hi all,

I was just wondering about the status of this patch.

Thanks
--
Gustavo

Quoted 35 lines · Felix Kuehling

Looks good. This change is Reviewed-by: Felix Kuehling <[email protected]>

Regards,
Felix

Quoted 24 lines · Gustavo A. R. Silva

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

---
   drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index c6a7609..7783250 100644
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct
 kfd_topology_device *dev,
         }
         /* All hardware blocks have the same number of attributes. */
-       num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+       num_attrs = ARRAY_SIZE(perf_attr_iommu);
         list_for_each_entry(perf, &dev->perf_props, list) {
                 perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
                         * num_attrs + sizeof(struct attribute_group),