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:*
Showing the changes to include/linux (1 of 5 files). Show all
Unified · Split
| @@ -386,34 +386,6 @@ enum device_link_state { · 385 unmodified lines | ||
| 386 | 386 | #define DL_FLAG_MANAGED BIT(6) |
| 387 | 387 | #define DL_FLAG_SYNC_STATE_ONLY BIT(7) |
| 388 | 388 | |
| 389 | −/** | |
| 390 | − * struct device_link - Device link representation. | |
| 391 | − * @supplier: The device on the supplier end of the link. | |
| 392 | − * @s_node: Hook to the supplier device's list of links to consumers. | |
| 393 | − * @consumer: The device on the consumer end of the link. | |
| 394 | − * @c_node: Hook to the consumer device's list of links to suppliers. | |
| 395 | − * @status: The state of the link (with respect to the presence of drivers). | |
| 396 | − * @flags: Link flags. | |
| 397 | − * @rpm_active: Whether or not the consumer device is runtime-PM-active. | |
| 398 | − * @kref: Count repeated addition of the same link. | |
| 399 | − * @rcu_head: An RCU head to use for deferred execution of SRCU callbacks. | |
| 400 | − * @supplier_preactivated: Supplier has been made active before consumer probe. | |
| 401 | − */ | |
| 402 | −struct device_link { | |
| 403 | − struct device *supplier; | |
| 404 | − struct list_head s_node; | |
| 405 | − struct device *consumer; | |
| 406 | − struct list_head c_node; | |
| 407 | − enum device_link_state status; | |
| 408 | − u32 flags; | |
| 409 | − refcount_t rpm_active; | |
| 410 | − struct kref kref; | |
| 411 | −#ifdef CONFIG_SRCU | |
| 412 | − struct rcu_head rcu_head; | |
| 413 | −#endif | |
| 414 | − bool supplier_preactivated; /* Owned by consumer probe. */ | |
| 415 | −}; | |
| 416 | − | |
| 417 | 389 | /** |
| 418 | 390 | * enum dl_dev_state - Device driver presence tracking information. |
| 419 | 391 | * @DL_DEV_NO_DRIVER: There is no driver attached to the device. |
| @@ -624,6 +596,36 @@ struct device { · 204 unmodified lines | ||
| 624 | 596 | #endif |
| 625 | 597 | }; |
| 626 | 598 | |
| 599 | +/** | |
| 600 | + * struct device_link - Device link representation. | |
| 601 | + * @supplier: The device on the supplier end of the link. | |
| 602 | + * @s_node: Hook to the supplier device's list of links to consumers. | |
| 603 | + * @consumer: The device on the consumer end of the link. | |
| 604 | + * @c_node: Hook to the consumer device's list of links to suppliers. | |
| 605 | + * @link_dev: device used to expose link details in sysfs | |
| 606 | + * @status: The state of the link (with respect to the presence of drivers). | |
| 607 | + * @flags: Link flags. | |
| 608 | + * @rpm_active: Whether or not the consumer device is runtime-PM-active. | |
| 609 | + * @kref: Count repeated addition of the same link. | |
| 610 | + * @rcu_head: An RCU head to use for deferred execution of SRCU callbacks. | |
| 611 | + * @supplier_preactivated: Supplier has been made active before consumer probe. | |
| 612 | + */ | |
| 613 | +struct device_link { | |
| 614 | + struct device *supplier; | |
| 615 | + struct list_head s_node; | |
| 616 | + struct device *consumer; | |
| 617 | + struct list_head c_node; | |
| 618 | + struct device link_dev; | |
| 619 | + enum device_link_state status; | |
| 620 | + u32 flags; | |
| 621 | + refcount_t rpm_active; | |
| 622 | + struct kref kref; | |
| 623 | +#ifdef CONFIG_SRCU | |
| 624 | + struct rcu_head rcu_head; | |
| 625 | +#endif | |
| 626 | + bool supplier_preactivated; /* Owned by consumer probe. */ | |
| 627 | +}; | |
| 628 | + | |
| 627 | 629 | static inline struct device *kobj_to_dev(struct kobject *kobj) |
| 628 | 630 | { |
| 629 | 631 | return container_of(kobj, struct device, kobj); |