driver core: Expose device link details in sysfs
authorSaravana Kannan <saravanak@google.com>
Thu, 21 May 2020 19:17:58 +0000 (12:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jul 2020 13:24:56 +0000 (15:24 +0200)
commit287905e68dd29873bcb7986a8290cd1e4cfde600
tree2aea5d81358554da1110abeb3dfb34a1b25531aa
parentfe940d7362e6d7a5e5086581d0462e00ba766992
driver core: Expose device link details in sysfs

It's helpful to be able to look at device link details from sysfs. So,
expose it in sysfs.

Say device-A is supplier of device-B. These are the additional files
this patch would create:

/sys/class/devlink/device-A:device-B/
auto_remove_on
consumer/ -> .../device-B/
runtime_pm
status
supplier/ -> .../device-A/
sync_state_only

/sys/devices/.../device-A/
consumer:device-B/ -> /sys/class/devlink/device-A:device-B/

/sys/devices/.../device-B/
supplier:device-A/ -> /sys/class/devlink/device-A:device-B/

That way:
To get a list of all the device link in the system:
ls /sys/class/devlink/

To get the consumer names and links of a device:
ls -d /sys/devices/.../device-X/consumer:*

To get the supplier names and links of a device:
ls -d /sys/devices/.../device-X/supplier:*

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20200521191800.136035-2-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-class-devlink [new file with mode: 0644]
Documentation/ABI/testing/sysfs-devices-consumer [new file with mode: 0644]
Documentation/ABI/testing/sysfs-devices-supplier [new file with mode: 0644]
drivers/base/core.c
include/linux/device.h