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.
16 pci_get_param(struct pci_access *acc, char *param)
20 for (p=acc->params; p; p=p->next)
21 if (!strcmp(p->param, param))
27 pci_define_param(struct pci_access *acc, char *param, char *value, char *help)
29 struct pci_param *p, **pp;
31 for (pp=&acc->params; p = *pp; pp=&p->next)
33 int cmp = strcmp(p->param, param);
36 if (strcmp(p->value, value) || strcmp(p->help, help))
37 acc->error("Parameter %s re-defined differently", param);
44 p = pci_malloc(acc, sizeof(*p));
49 p->value_malloced = 0;
54 pci_set_param_internal(struct pci_access *acc, char *param, char *value, int copy)
58 for (p=acc->params; p; p=p->next)
59 if (!strcmp(p->param, param))
61 if (p->value_malloced)
63 p->value_malloced = copy;
65 p->value = pci_strdup(acc, value);
74 pci_set_param(struct pci_access *acc, char *param, char *value)
76 return pci_set_param_internal(acc, param, value, 1);
80 pci_free_params(struct pci_access *acc)
84 while (p = acc->params)
86 acc->params = p->next;
87 if (p->value_malloced)
94 pci_walk_params(struct pci_access *acc, struct pci_param *prev)
96 /* So far, the params form a simple linked list, but this can change in the future */