mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
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>
This commit is contained in:
parent
3499c0a992
commit
750365ef8c
@ -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,
|
||||
|
@ -1398,7 +1398,7 @@ int usb4_port_margining_caps(struct tb_port *port, enum usb4_sb_target target,
|
||||
u8 index, u32 *caps, size_t ncaps);
|
||||
int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
|
||||
u8 index, const struct usb4_port_margining_params *params,
|
||||
u32 *results);
|
||||
u32 *results, size_t nresults);
|
||||
int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
|
||||
u8 index, const struct usb4_port_margining_params *params,
|
||||
u32 *results);
|
||||
|
@ -1655,14 +1655,15 @@ int usb4_port_margining_caps(struct tb_port *port, enum usb4_sb_target target,
|
||||
* @target: Sideband target
|
||||
* @index: Retimer index if taget is %USB4_SB_TARGET_RETIMER
|
||||
* @params: Parameters for USB4 hardware margining
|
||||
* @results: Array with at least two elements to hold the results
|
||||
* @results: Array to hold the results
|
||||
* @nresults: Number of elements in the results array
|
||||
*
|
||||
* Runs hardware lane margining on USB4 port and returns the result in
|
||||
* @results.
|
||||
*/
|
||||
int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
|
||||
u8 index, const struct usb4_port_margining_params *params,
|
||||
u32 *results)
|
||||
u32 *results, size_t nresults)
|
||||
{
|
||||
u32 val;
|
||||
int ret;
|
||||
@ -1691,7 +1692,7 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
|
||||
return ret;
|
||||
|
||||
return usb4_port_sb_read(port, target, index, USB4_SB_DATA, results,
|
||||
sizeof(*results) * 2);
|
||||
sizeof(*results) * nresults);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user