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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
fe940d7362
commit
287905e68d
@@ -386,34 +386,6 @@ enum device_link_state {
|
||||
#define DL_FLAG_MANAGED BIT(6)
|
||||
#define DL_FLAG_SYNC_STATE_ONLY BIT(7)
|
||||
|
||||
/**
|
||||
* struct device_link - Device link representation.
|
||||
* @supplier: The device on the supplier end of the link.
|
||||
* @s_node: Hook to the supplier device's list of links to consumers.
|
||||
* @consumer: The device on the consumer end of the link.
|
||||
* @c_node: Hook to the consumer device's list of links to suppliers.
|
||||
* @status: The state of the link (with respect to the presence of drivers).
|
||||
* @flags: Link flags.
|
||||
* @rpm_active: Whether or not the consumer device is runtime-PM-active.
|
||||
* @kref: Count repeated addition of the same link.
|
||||
* @rcu_head: An RCU head to use for deferred execution of SRCU callbacks.
|
||||
* @supplier_preactivated: Supplier has been made active before consumer probe.
|
||||
*/
|
||||
struct device_link {
|
||||
struct device *supplier;
|
||||
struct list_head s_node;
|
||||
struct device *consumer;
|
||||
struct list_head c_node;
|
||||
enum device_link_state status;
|
||||
u32 flags;
|
||||
refcount_t rpm_active;
|
||||
struct kref kref;
|
||||
#ifdef CONFIG_SRCU
|
||||
struct rcu_head rcu_head;
|
||||
#endif
|
||||
bool supplier_preactivated; /* Owned by consumer probe. */
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dl_dev_state - Device driver presence tracking information.
|
||||
* @DL_DEV_NO_DRIVER: There is no driver attached to the device.
|
||||
@@ -624,6 +596,36 @@ struct device {
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* struct device_link - Device link representation.
|
||||
* @supplier: The device on the supplier end of the link.
|
||||
* @s_node: Hook to the supplier device's list of links to consumers.
|
||||
* @consumer: The device on the consumer end of the link.
|
||||
* @c_node: Hook to the consumer device's list of links to suppliers.
|
||||
* @link_dev: device used to expose link details in sysfs
|
||||
* @status: The state of the link (with respect to the presence of drivers).
|
||||
* @flags: Link flags.
|
||||
* @rpm_active: Whether or not the consumer device is runtime-PM-active.
|
||||
* @kref: Count repeated addition of the same link.
|
||||
* @rcu_head: An RCU head to use for deferred execution of SRCU callbacks.
|
||||
* @supplier_preactivated: Supplier has been made active before consumer probe.
|
||||
*/
|
||||
struct device_link {
|
||||
struct device *supplier;
|
||||
struct list_head s_node;
|
||||
struct device *consumer;
|
||||
struct list_head c_node;
|
||||
struct device link_dev;
|
||||
enum device_link_state status;
|
||||
u32 flags;
|
||||
refcount_t rpm_active;
|
||||
struct kref kref;
|
||||
#ifdef CONFIG_SRCU
|
||||
struct rcu_head rcu_head;
|
||||
#endif
|
||||
bool supplier_preactivated; /* Owned by consumer probe. */
|
||||
};
|
||||
|
||||
static inline struct device *kobj_to_dev(struct kobject *kobj)
|
||||
{
|
||||
return container_of(kobj, struct device, kobj);
|
||||
|
Reference in New Issue
Block a user