Skip to contentSkip to conversation

dma-debug: use named initializers for dir2name

PATCH In review Christoph Hellwig 2 participants 3 messages Jul 16, 2020 – Jul 20, 2020 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-debug: use named initializers for dir2name

Make dir2name a little more readable and maintainable by using named initializers.

---
 kernel/dma/debug.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/dma/debug.c +6 -2
index 36c962a86bf25d..41e720c3ab20c5 100644
@@ -144,8 +144,12 @@ static const char *type2name[] = {
 	[dma_debug_resource] = "resource",
 };
 
-static const char *dir2name[4] = { "DMA_BIDIRECTIONAL", "DMA_TO_DEVICE",
-				   "DMA_FROM_DEVICE", "DMA_NONE" };
+static const char *dir2name[4] = {
+	[DMA_BIDIRECTIONAL]	= "DMA_BIDIRECTIONAL",
+	[DMA_TO_DEVICE]		= "DMA_TO_DEVICE",
+	[DMA_FROM_DEVICE]	= "DMA_FROM_DEVICE",
+	[DMA_NONE]		= "DMA_NONE",
+};
 
 /*
  * The access to some variables in this macro is racy. We can't use atomic_t
Signature · 6 lines
2.27.0

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Christoph Hellwig

Make dir2name a little more readable and maintainable by using named initializers.

---
  kernel/dma/debug.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
kernel/dma/debug.c +0 -0
index 36c962a86bf25d..41e720c3ab20c5 100644

kernel/dma/debug.c static const char *type2name[] = { · line 147

Quoted 6 lines
kernel/dma/debug.c +1 -2
@@ -144,8 +144,12 @@ static const char *type2name[] = {
  	[dma_debug_resource] = "resource",
  };
 
-static const char *dir2name[4] = { "DMA_BIDIRECTIONAL", "DMA_TO_DEVICE",
-				   "DMA_FROM_DEVICE", "DMA_NONE" };
+static const char *dir2name[4] = {

Nit: I think you can probably drop the explicit array size here.

Otherwise, very welcome clarity!

kernel/dma/debug.c static const char *type2name[] = { · line 155

Quoted 9 lines
kernel/dma/debug.c +5 -0
+	[DMA_BIDIRECTIONAL]	= "DMA_BIDIRECTIONAL",
+	[DMA_TO_DEVICE]		= "DMA_TO_DEVICE",
+	[DMA_FROM_DEVICE]	= "DMA_FROM_DEVICE",
+	[DMA_NONE]		= "DMA_NONE",
+};
 
  /*
   * The access to some variables in this macro is racy. We can't use atomic_t

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu