drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / tools / net / ynl / samples / devlink.c
blobd2611d7ebab45cb7a81bfbe8e75b393184483b3d
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <string.h>
5 #include <ynl.h>
7 #include "devlink-user.h"
9 int main(int argc, char **argv)
11 struct devlink_get_list *devs;
12 struct ynl_sock *ys;
14 ys = ynl_sock_create(&ynl_devlink_family, NULL);
15 if (!ys)
16 return 1;
18 devs = devlink_get_dump(ys);
19 if (!devs)
20 goto err_close;
22 ynl_dump_foreach(devs, d) {
23 struct devlink_info_get_req *info_req;
24 struct devlink_info_get_rsp *info_rsp;
26 printf("%s/%s:\n", d->bus_name, d->dev_name);
28 info_req = devlink_info_get_req_alloc();
29 devlink_info_get_req_set_bus_name(info_req, d->bus_name);
30 devlink_info_get_req_set_dev_name(info_req, d->dev_name);
32 info_rsp = devlink_info_get(ys, info_req);
33 devlink_info_get_req_free(info_req);
34 if (!info_rsp)
35 goto err_free_devs;
37 if (info_rsp->_present.info_driver_name_len)
38 printf(" driver: %s\n", info_rsp->info_driver_name);
39 if (info_rsp->n_info_version_running)
40 printf(" running fw:\n");
41 for (unsigned i = 0; i < info_rsp->n_info_version_running; i++)
42 printf(" %s: %s\n",
43 info_rsp->info_version_running[i].info_version_name,
44 info_rsp->info_version_running[i].info_version_value);
45 printf(" ...\n");
46 devlink_info_get_rsp_free(info_rsp);
48 devlink_get_list_free(devs);
50 ynl_sock_destroy(ys);
52 return 0;
54 err_free_devs:
55 devlink_get_list_free(devs);
56 err_close:
57 fprintf(stderr, "YNL: %s\n", ys->err.msg);
58 ynl_sock_destroy(ys);
59 return 2;