diff mbox series

[v2,1/4] dma-mapping: Use macros to define events in a class

Message ID 20241018150036.2878190-2-sean.anderson@linux.dev (mailing list archive)
State Handled Elsewhere
Headers show
Series dma-mapping: Trace more error paths | expand

Commit Message

Sean Anderson Oct. 18, 2024, 3 p.m. UTC
Use a macro to avoid repeating the parameters and arguments for each event
in a class.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---

Changes in v2:
- New

 include/trace/events/dma.h | 60 ++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 32 deletions(-)
diff mbox series

Patch

diff --git a/include/trace/events/dma.h b/include/trace/events/dma.h
index b0f41265191c..3d348cea4d7c 100644
--- a/include/trace/events/dma.h
+++ b/include/trace/events/dma.h
@@ -65,15 +65,14 @@  DECLARE_EVENT_CLASS(dma_map,
 		decode_dma_attrs(__entry->attrs))
 );
 
-DEFINE_EVENT(dma_map, dma_map_page,
-	TP_PROTO(struct device *dev, phys_addr_t phys_addr, dma_addr_t dma_addr,
-		 size_t size, enum dma_data_direction dir, unsigned long attrs),
-	TP_ARGS(dev, phys_addr, dma_addr, size, dir, attrs));
+#define DEFINE_MAP_EVENT(name) \
+DEFINE_EVENT(dma_map, name, \
+	TP_PROTO(struct device *dev, phys_addr_t phys_addr, dma_addr_t dma_addr, \
+		 size_t size, enum dma_data_direction dir, unsigned long attrs), \
+	TP_ARGS(dev, phys_addr, dma_addr, size, dir, attrs))
 
-DEFINE_EVENT(dma_map, dma_map_resource,
-	TP_PROTO(struct device *dev, phys_addr_t phys_addr, dma_addr_t dma_addr,
-		 size_t size, enum dma_data_direction dir, unsigned long attrs),
-	TP_ARGS(dev, phys_addr, dma_addr, size, dir, attrs));
+DEFINE_MAP_EVENT(dma_map_page);
+DEFINE_MAP_EVENT(dma_map_resource);
 
 DECLARE_EVENT_CLASS(dma_unmap,
 	TP_PROTO(struct device *dev, dma_addr_t addr, size_t size,
@@ -104,15 +103,14 @@  DECLARE_EVENT_CLASS(dma_unmap,
 		decode_dma_attrs(__entry->attrs))
 );
 
-DEFINE_EVENT(dma_unmap, dma_unmap_page,
-	TP_PROTO(struct device *dev, dma_addr_t addr, size_t size,
-		 enum dma_data_direction dir, unsigned long attrs),
-	TP_ARGS(dev, addr, size, dir, attrs));
+#define DEFINE_UNMAP_EVENT(name) \
+DEFINE_EVENT(dma_unmap, name, \
+	TP_PROTO(struct device *dev, dma_addr_t addr, size_t size, \
+		 enum dma_data_direction dir, unsigned long attrs), \
+	TP_ARGS(dev, addr, size, dir, attrs))
 
-DEFINE_EVENT(dma_unmap, dma_unmap_resource,
-	TP_PROTO(struct device *dev, dma_addr_t addr, size_t size,
-		 enum dma_data_direction dir, unsigned long attrs),
-	TP_ARGS(dev, addr, size, dir, attrs));
+DEFINE_UNMAP_EVENT(dma_unmap_page);
+DEFINE_UNMAP_EVENT(dma_unmap_resource);
 
 TRACE_EVENT(dma_alloc,
 	TP_PROTO(struct device *dev, void *virt_addr, dma_addr_t dma_addr,
@@ -279,15 +277,14 @@  DECLARE_EVENT_CLASS(dma_sync_single,
 		__entry->size)
 );
 
-DEFINE_EVENT(dma_sync_single, dma_sync_single_for_cpu,
-	TP_PROTO(struct device *dev, dma_addr_t dma_addr, size_t size,
-		 enum dma_data_direction dir),
-	TP_ARGS(dev, dma_addr, size, dir));
+#define DEFINE_SYNC_SINGLE_EVENT(name) \
+DEFINE_EVENT(dma_sync_single, name, \
+	TP_PROTO(struct device *dev, dma_addr_t dma_addr, size_t size, \
+		 enum dma_data_direction dir), \
+	TP_ARGS(dev, dma_addr, size, dir))
 
-DEFINE_EVENT(dma_sync_single, dma_sync_single_for_device,
-	TP_PROTO(struct device *dev, dma_addr_t dma_addr, size_t size,
-		 enum dma_data_direction dir),
-	TP_ARGS(dev, dma_addr, size, dir));
+DEFINE_SYNC_SINGLE_EVENT(dma_sync_single_for_cpu);
+DEFINE_SYNC_SINGLE_EVENT(dma_sync_single_for_device);
 
 DECLARE_EVENT_CLASS(dma_sync_sg,
 	TP_PROTO(struct device *dev, struct scatterlist *sgl, int nents,
@@ -326,15 +323,14 @@  DECLARE_EVENT_CLASS(dma_sync_sg,
 				sizeof(unsigned int), sizeof(unsigned int)))
 );
 
-DEFINE_EVENT(dma_sync_sg, dma_sync_sg_for_cpu,
-	TP_PROTO(struct device *dev, struct scatterlist *sg, int nents,
-		 enum dma_data_direction dir),
-	TP_ARGS(dev, sg, nents, dir));
+#define DEFINE_SYNC_SG_EVENT(name) \
+DEFINE_EVENT(dma_sync_sg, name, \
+	TP_PROTO(struct device *dev, struct scatterlist *sg, int nents, \
+		 enum dma_data_direction dir), \
+	TP_ARGS(dev, sg, nents, dir))
 
-DEFINE_EVENT(dma_sync_sg, dma_sync_sg_for_device,
-	TP_PROTO(struct device *dev, struct scatterlist *sg, int nents,
-		 enum dma_data_direction dir),
-	TP_ARGS(dev, sg, nents, dir));
+DEFINE_SYNC_SG_EVENT(dma_sync_sg_for_cpu);
+DEFINE_SYNC_SG_EVENT(dma_sync_sg_for_device);
 
 #endif /*  _TRACE_DMA_H */