diff options
author | Aapo Vienamo <aapo.vienamo@iki.fi> | 2024-08-15 21:45:19 +0300 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2024-11-01 07:55:38 +0200 |
commit | 750365ef8c1718de9a7b25799d69ac0ee13be275 (patch) | |
tree | 64a9471f675ce736668cd085221065665e782552 /drivers/thunderbolt/debugfs.c | |
parent | 3499c0a992e432cb8a85616ff4a9019a8924c89a (diff) | |
download | lwn-750365ef8c1718de9a7b25799d69ac0ee13be275.tar.gz lwn-750365ef8c1718de9a7b25799d69ac0ee13be275.zip |
thunderbolt: debugfs: Don't hardcode margining results size
Use ARRAY_SIZE() when available or pass in the array size derived from
it. This is in preparation for adding another result data word for
supporting Gen 4 asymmetric links with an additional lane.
Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/debugfs.c')
-rw-r--r-- | drivers/thunderbolt/debugfs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c index 2f9756c201b6..9899d88b7371 100644 --- a/drivers/thunderbolt/debugfs.c +++ b/drivers/thunderbolt/debugfs.c @@ -1191,7 +1191,7 @@ static int margining_run_write(void *data, u64 val) margining->lanes); ret = usb4_port_hw_margin(port, margining->target, margining->index, ¶ms, - margining->results); + margining->results, ARRAY_SIZE(margining->results)); } if (down_sw) @@ -1219,8 +1219,7 @@ static ssize_t margining_results_write(struct file *file, return -ERESTARTSYS; /* Just clear the results */ - margining->results[0] = 0; - margining->results[1] = 0; + memset(margining->results, 0, sizeof(margining->results)); if (margining->software) { /* Clear the error counters */ @@ -1312,7 +1311,8 @@ static int margining_results_show(struct seq_file *s, void *not_used) seq_printf(s, "0x%08x\n", margining->results[0]); /* Only the hardware margining has two result dwords */ if (!margining->software) { - seq_printf(s, "0x%08x\n", margining->results[1]); + for (int i = 1; i < ARRAY_SIZE(margining->results); i++) + seq_printf(s, "0x%08x\n", margining->results[i]); if (margining->lanes == USB4_MARGINING_LANE_ALL) { margining_hw_result_format(s, margining, |