/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/property.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-22 13:57:59 UTC
  • Revision ID: csa@suren.me-20151022135759-nqs5wowy38tvbw09
Documentation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
 
19
19
int pcilib_add_registers_from_properties(pcilib_t *ctx, size_t n, pcilib_view_context_t* const *view_ctx, pcilib_view_description_t* const *v) {
 
20
    int err;
 
21
    
20
22
    pcilib_view_t i;
21
23
    pcilib_register_t pos = 0;
22
24
    pcilib_register_description_t regs[n];
23
25
 
 
26
    int access;
 
27
    pcilib_register_bank_t bank;
 
28
 
 
29
    bank = pcilib_find_register_bank_by_addr(ctx, pcilib_property_register_bank.addr);
 
30
    if (bank == PCILIB_REGISTER_BANK_INVALID) {
 
31
        err = pcilib_add_register_banks(ctx, 0, 1, &pcilib_property_register_bank, &bank);
 
32
        if (err) {
 
33
            pcilib_error("Error (%i) adding register bank (%s)", err, pcilib_property_register_bank.name);
 
34
            return err;
 
35
        }
 
36
    }
 
37
    
 
38
    access = ctx->banks[bank].access;
 
39
    
24
40
    for (i = 0; i < n; i++) {
25
41
        if ((v[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) continue;
26
42
 
27
43
        regs[pos++] = (pcilib_register_description_t){
28
 
            .addr = view_ctx[i]->view,
 
44
            .addr = view_ctx[i]->view * access,
29
45
            .bits = 8 * sizeof(pcilib_register_value_t),
30
46
            .mode = v[i]->mode,
31
47
            .type = PCILIB_REGISTER_PROPERTY,
246
262
        return PCILIB_ERROR_NOTFOUND;
247
263
    }
248
264
 
249
 
    if (!view_ctx->xml) return NULL;
 
265
    if (!view_ctx->xml) return PCILIB_ERROR_NOTFOUND;
250
266
 
251
267
    return pcilib_get_xml_attr(ctx, view_ctx->xml, attr, val);
252
268
}