|
12 | 12 | #include <kunit/test-bug.h>
|
13 | 13 | #include <kunit/visibility.h>
|
14 | 14 |
|
| 15 | +static void xe_ip_kunit_desc(const struct xe_ip *param, char *desc) |
| 16 | +{ |
| 17 | + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%u.%02u %s", |
| 18 | + param->verx100 / 100, param->verx100 % 100, param->name); |
| 19 | +} |
| 20 | + |
| 21 | +KUNIT_ARRAY_PARAM(graphics_ip, graphics_ips, xe_ip_kunit_desc); |
| 22 | +KUNIT_ARRAY_PARAM(media_ip, media_ips, xe_ip_kunit_desc); |
| 23 | + |
15 | 24 | /**
|
16 |
| - * xe_call_for_each_graphics_ip - Iterate over all recognized graphics IPs |
17 |
| - * @xe_fn: Function to call for each device. |
| 25 | + * xe_pci_graphics_ip_gen_param - Generate graphics struct xe_ip parameters |
| 26 | + * @prev: the pointer to the previous parameter to iterate from or NULL |
| 27 | + * @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE |
18 | 28 | *
|
19 |
| - * This function iterates over the descriptors for all graphics IPs recognized |
20 |
| - * by the driver and calls @xe_fn: for each one of them. |
| 29 | + * This function prepares struct xe_ip parameter. |
| 30 | + * |
| 31 | + * To be used only as a parameter generator function in &KUNIT_CASE_PARAM. |
| 32 | + * |
| 33 | + * Return: pointer to the next parameter or NULL if no more parameters |
21 | 34 | */
|
22 |
| -void xe_call_for_each_graphics_ip(xe_graphics_fn xe_fn) |
| 35 | +const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc) |
23 | 36 | {
|
24 |
| - const struct xe_graphics_desc *desc, *last = NULL; |
25 |
| - |
26 |
| - for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++) { |
27 |
| - desc = graphics_ips[i].desc; |
28 |
| - if (desc == last) |
29 |
| - continue; |
30 |
| - |
31 |
| - xe_fn(desc); |
32 |
| - last = desc; |
33 |
| - } |
| 37 | + return graphics_ip_gen_params(prev, desc); |
34 | 38 | }
|
35 |
| -EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_graphics_ip); |
| 39 | +EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param); |
36 | 40 |
|
37 | 41 | /**
|
38 |
| - * xe_call_for_each_media_ip - Iterate over all recognized media IPs |
39 |
| - * @xe_fn: Function to call for each device. |
| 42 | + * xe_pci_media_ip_gen_param - Generate media struct xe_ip parameters |
| 43 | + * @prev: the pointer to the previous parameter to iterate from or NULL |
| 44 | + * @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE |
| 45 | + * |
| 46 | + * This function prepares struct xe_ip parameter. |
| 47 | + * |
| 48 | + * To be used only as a parameter generator function in &KUNIT_CASE_PARAM. |
40 | 49 | *
|
41 |
| - * This function iterates over the descriptors for all media IPs recognized |
42 |
| - * by the driver and calls @xe_fn: for each one of them. |
| 50 | + * Return: pointer to the next parameter or NULL if no more parameters |
43 | 51 | */
|
44 |
| -void xe_call_for_each_media_ip(xe_media_fn xe_fn) |
| 52 | +const void *xe_pci_media_ip_gen_param(const void *prev, char *desc) |
45 | 53 | {
|
46 |
| - const struct xe_media_desc *desc, *last = NULL; |
47 |
| - |
48 |
| - for (int i = 0; i < ARRAY_SIZE(media_ips); i++) { |
49 |
| - desc = media_ips[i].desc; |
50 |
| - if (desc == last) |
51 |
| - continue; |
52 |
| - |
53 |
| - xe_fn(desc); |
54 |
| - last = desc; |
55 |
| - } |
| 54 | + return media_ip_gen_params(prev, desc); |
56 | 55 | }
|
57 |
| -EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_media_ip); |
| 56 | +EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param); |
58 | 57 |
|
59 | 58 | static void fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
|
60 | 59 | u32 *ver, u32 *revid)
|
|
0 commit comments