mbox series

[RFC,v5,0/1] i2c: core: Adapter and client stats as sysfs attributes

Message ID 20220517100505.2569874-1-suichen@google.com
Headers show
Series i2c: core: Adapter and client stats as sysfs attributes | expand


Sui Chen May 17, 2022, 10:05 a.m. UTC
This change adds statistics to the i2c_adapter structure as Wolfram
previously suggested
It also adds relevant statistics to the per-address i2c_clients where

The list of statistics are:

- bus_errors
- nacks
- recovery_successes / recovery_failures (only applicable to
- timeouts
- messages (only applicable to i2c_client)
- transfers (only applicable to i2c_adapter)

The statistics are located in /sys/class/i2c-adapter/i2c-x/stats and
/sys/class/i2c-adapter/i2c-x/x-xxxx/stats respectively.

Since the counting is done in __i2c_transfer, where the number of
messages transferred is not known upon error, the error counters are
attributed to all unique addresses that appear in the message list
passed into __i2c_transfer.

Currently an rbtree is used to find the i2c_client located at a certain
address. Would be happy to know if there is a better way of doing this.


Sui Chen (1):
  i2c debug counters as sysfs attributes

 drivers/i2c/i2c-core-base.c | 240 +++++++++++++++++++++++++++++++++++-
 drivers/i2c/i2c-dev.c       |  94 ++++++++++++++
 include/linux/i2c.h         |  41 ++++++
 3 files changed, 374 insertions(+), 1 deletion(-)