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;
56 pci_set_param_internal(struct pci_access *acc, char *param, char *value, int copy)
60 for (p=acc->params; p; p=p->next)
61 if (!strcmp(p->param, param))
63 if (p->value_malloced)
65 p->value_malloced = copy;
67 p->value = pci_strdup(acc, value);
76 pci_set_param(struct pci_access *acc, char *param, char *value)
78 return pci_set_param_internal(acc, param, value, 1);
82 pci_free_params(struct pci_access *acc)
86 while (p = acc->params)
88 acc->params = p->next;
89 if (p->value_malloced)
96 pci_walk_params(struct pci_access *acc, struct pci_param *prev)
98 /* So far, the params form a simple linked list, but this can change in the future */