i2c.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* I2C message transfer tracepoints
  2. *
  3. * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #undef TRACE_SYSTEM
  12. #define TRACE_SYSTEM i2c
  13. #if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ)
  14. #define _TRACE_I2C_H
  15. #include <linux/i2c.h>
  16. #include <linux/tracepoint.h>
  17. /*
  18. * drivers/i2c/i2c-core-base.c
  19. */
  20. extern int i2c_transfer_trace_reg(void);
  21. extern void i2c_transfer_trace_unreg(void);
  22. /*
  23. * __i2c_transfer() write request
  24. */
  25. TRACE_EVENT_FN(i2c_write,
  26. TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
  27. int num),
  28. TP_ARGS(adap, msg, num),
  29. TP_STRUCT__entry(
  30. __field(int, adapter_nr )
  31. __field(__u16, msg_nr )
  32. __field(__u16, addr )
  33. __field(__u16, flags )
  34. __field(__u16, len )
  35. __dynamic_array(__u8, buf, msg->len) ),
  36. TP_fast_assign(
  37. __entry->adapter_nr = adap->nr;
  38. __entry->msg_nr = num;
  39. __entry->addr = msg->addr;
  40. __entry->flags = msg->flags;
  41. __entry->len = msg->len;
  42. memcpy(__get_dynamic_array(buf), msg->buf, msg->len);
  43. ),
  44. TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
  45. __entry->adapter_nr,
  46. __entry->msg_nr,
  47. __entry->addr,
  48. __entry->flags,
  49. __entry->len,
  50. __entry->len, __get_dynamic_array(buf)
  51. ),
  52. i2c_transfer_trace_reg,
  53. i2c_transfer_trace_unreg);
  54. /*
  55. * __i2c_transfer() read request
  56. */
  57. TRACE_EVENT_FN(i2c_read,
  58. TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
  59. int num),
  60. TP_ARGS(adap, msg, num),
  61. TP_STRUCT__entry(
  62. __field(int, adapter_nr )
  63. __field(__u16, msg_nr )
  64. __field(__u16, addr )
  65. __field(__u16, flags )
  66. __field(__u16, len )
  67. ),
  68. TP_fast_assign(
  69. __entry->adapter_nr = adap->nr;
  70. __entry->msg_nr = num;
  71. __entry->addr = msg->addr;
  72. __entry->flags = msg->flags;
  73. __entry->len = msg->len;
  74. ),
  75. TP_printk("i2c-%d #%u a=%03x f=%04x l=%u",
  76. __entry->adapter_nr,
  77. __entry->msg_nr,
  78. __entry->addr,
  79. __entry->flags,
  80. __entry->len
  81. ),
  82. i2c_transfer_trace_reg,
  83. i2c_transfer_trace_unreg);
  84. /*
  85. * __i2c_transfer() read reply
  86. */
  87. TRACE_EVENT_FN(i2c_reply,
  88. TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
  89. int num),
  90. TP_ARGS(adap, msg, num),
  91. TP_STRUCT__entry(
  92. __field(int, adapter_nr )
  93. __field(__u16, msg_nr )
  94. __field(__u16, addr )
  95. __field(__u16, flags )
  96. __field(__u16, len )
  97. __dynamic_array(__u8, buf, msg->len) ),
  98. TP_fast_assign(
  99. __entry->adapter_nr = adap->nr;
  100. __entry->msg_nr = num;
  101. __entry->addr = msg->addr;
  102. __entry->flags = msg->flags;
  103. __entry->len = msg->len;
  104. memcpy(__get_dynamic_array(buf), msg->buf, msg->len);
  105. ),
  106. TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
  107. __entry->adapter_nr,
  108. __entry->msg_nr,
  109. __entry->addr,
  110. __entry->flags,
  111. __entry->len,
  112. __entry->len, __get_dynamic_array(buf)
  113. ),
  114. i2c_transfer_trace_reg,
  115. i2c_transfer_trace_unreg);
  116. /*
  117. * __i2c_transfer() result
  118. */
  119. TRACE_EVENT_FN(i2c_result,
  120. TP_PROTO(const struct i2c_adapter *adap, int num, int ret),
  121. TP_ARGS(adap, num, ret),
  122. TP_STRUCT__entry(
  123. __field(int, adapter_nr )
  124. __field(__u16, nr_msgs )
  125. __field(__s16, ret )
  126. ),
  127. TP_fast_assign(
  128. __entry->adapter_nr = adap->nr;
  129. __entry->nr_msgs = num;
  130. __entry->ret = ret;
  131. ),
  132. TP_printk("i2c-%d n=%u ret=%d",
  133. __entry->adapter_nr,
  134. __entry->nr_msgs,
  135. __entry->ret
  136. ),
  137. i2c_transfer_trace_reg,
  138. i2c_transfer_trace_unreg);
  139. #endif /* _TRACE_I2C_H */
  140. /* This part must be outside protection */
  141. #include <trace/define_trace.h>