2 * The PCI Library -- Parameters
4 * Copyright (c) 2008--2023 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL v2+.
8 * SPDX-License-Identifier: GPL-2.0-or-later
18 pci_get_param(struct pci_access *acc, char *param)
22 for (p=acc->params; p; p=p->next)
23 if (!strcmp(p->param, param))
29 pci_define_param(struct pci_access *acc, char *param, char *value, char *help)
31 struct pci_param *p, **pp;
33 for (pp=&acc->params; p = *pp; pp=&p->next)
35 int cmp = strcmp(p->param, param);
38 if (strcmp(p->value, value) || strcmp(p->help, help))
39 acc->error("Parameter %s re-defined differently", param);
46 p = pci_malloc(acc, sizeof(*p));
51 p->value_malloced = 0;
57 pci_set_param_internal(struct pci_access *acc, char *param, char *value, int copy)
61 for (p=acc->params; p; p=p->next)
62 if (!strcmp(p->param, param))
64 if (p->value_malloced)
66 p->value_malloced = copy;
68 p->value = pci_strdup(acc, value);
77 pci_set_param(struct pci_access *acc, char *param, char *value)
79 return pci_set_param_internal(acc, param, value, 1);
83 pci_free_params(struct pci_access *acc)
87 while (p = acc->params)
89 acc->params = p->next;
90 if (p->value_malloced)
97 pci_walk_params(struct pci_access *acc, struct pci_param *prev)
99 /* So far, the params form a simple linked list, but this can change in the future */