forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 144
soundwire: debugfs: add root-level peripherals table #5738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bardliao
wants to merge
1
commit into
thesofproject:topic/sof-dev
Choose a base branch
from
bardliao:sdw-debugfs
base: topic/sof-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,82 @@ | |
| #include <linux/pm_runtime.h> | ||
| #include <linux/slab.h> | ||
| #include <linux/soundwire/sdw.h> | ||
| #include <linux/soundwire/sdw_type.h> | ||
| #include <linux/soundwire/sdw_registers.h> | ||
| #include <linux/string_choices.h> | ||
| #include "bus.h" | ||
|
|
||
| static struct dentry *sdw_debugfs_root; | ||
|
|
||
| #define SDW_PERIPH_HEADER_FMT "%-28s %-7s %-16s %-6s %-7s %-8s %-9s %-11s\n" | ||
| #define SDW_PERIPH_ENTRY_FMT "%-28s %-7u %#016llx %-6.4x %-7.4x %-8.2x %-9.2x %-11.1x\n" | ||
|
|
||
| static u64 sdw_slave_addr_from_id(struct sdw_bus *bus, | ||
| const struct sdw_slave_id *id) | ||
| { | ||
| u64 addr = 0; | ||
| u8 unique_id = id->unique_id; | ||
|
|
||
| if (unique_id == SDW_IGNORED_UNIQUE_ID) | ||
| unique_id = 0; | ||
|
|
||
| addr |= FIELD_PREP(SDW_DISCO_LINK_ID_MASK, bus->link_id); | ||
| addr |= FIELD_PREP(SDW_VERSION_MASK, id->sdw_version); | ||
| addr |= FIELD_PREP(SDW_UNIQUE_ID_MASK, unique_id); | ||
| addr |= FIELD_PREP(SDW_MFG_ID_MASK, id->mfg_id); | ||
| addr |= FIELD_PREP(SDW_PART_ID_MASK, id->part_id); | ||
| addr |= FIELD_PREP(SDW_CLASS_ID_MASK, id->class_id); | ||
|
|
||
| return addr; | ||
| } | ||
|
|
||
| static void sdw_dump_bus_peripherals(struct seq_file *s_file, struct sdw_bus *bus) | ||
| { | ||
| struct sdw_slave *slave; | ||
| u64 addr; | ||
|
|
||
| seq_printf(s_file, "master-%d-%d\n", | ||
| bus->controller_id, bus->link_id); | ||
| seq_printf(s_file, SDW_PERIPH_HEADER_FMT, | ||
| "name", "dev_num", "addr", "mfg_id", "part_id", | ||
| "class_id", "unique_id", "sdw_version"); | ||
|
|
||
|
Comment on lines
+46
to
+51
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ATTACHED status is unreliable. And the "get the detected status by the dev_num." description in the commit message is to let the user know that we can know if the peripheral is detected or not according to its dev_num. |
||
| mutex_lock(&bus->bus_lock); | ||
| list_for_each_entry(slave, &bus->slaves, node) { | ||
| addr = sdw_slave_addr_from_id(bus, &slave->id); | ||
| seq_printf(s_file, SDW_PERIPH_ENTRY_FMT, | ||
| dev_name(&slave->dev), slave->dev_num, | ||
| addr, | ||
| slave->id.mfg_id, slave->id.part_id, | ||
| slave->id.class_id, slave->id.unique_id, | ||
| slave->id.sdw_version); | ||
|
Comment on lines
+54
to
+60
|
||
| } | ||
| mutex_unlock(&bus->bus_lock); | ||
|
|
||
| seq_putc(s_file, '\n'); | ||
| } | ||
|
|
||
| static int sdw_root_peripherals_dump(struct device *dev, void *data) | ||
| { | ||
| struct sdw_master_device *md; | ||
| struct seq_file *s_file = data; | ||
|
|
||
| if (dev->type != &sdw_master_type) | ||
| return 0; | ||
|
|
||
| md = dev_to_sdw_master_device(dev); | ||
| sdw_dump_bus_peripherals(s_file, md->bus); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int sdw_root_peripherals_show(struct seq_file *s_file, void *data) | ||
| { | ||
| return bus_for_each_dev(&sdw_bus_type, NULL, s_file, | ||
| sdw_root_peripherals_dump); | ||
| } | ||
| DEFINE_SHOW_ATTRIBUTE(sdw_root_peripherals); | ||
|
|
||
| void sdw_bus_debugfs_init(struct sdw_bus *bus) | ||
| { | ||
| char name[16]; | ||
|
|
@@ -372,6 +442,8 @@ void sdw_slave_debugfs_exit(struct sdw_slave *slave) | |
| void sdw_debugfs_init(void) | ||
| { | ||
| sdw_debugfs_root = debugfs_create_dir("soundwire", NULL); | ||
| debugfs_create_file("peripherals", 0400, sdw_debugfs_root, NULL, | ||
| &sdw_root_peripherals_fops); | ||
| } | ||
|
|
||
| void sdw_debugfs_exit(void) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output looks like
So, it should be fine.