/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/register.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-10-22 15:08:11 UTC
  • Revision ID: csa@suren.me-20151022150811-1l4cqcygra1phx0k
Fix access to the property-based registers

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
        return PCILIB_ERROR_OUTOFRANGE;
186
186
    }
187
187
 
188
 
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) {
189
 
        for (i = 0; i < (bits?(n+1):n); i++) {
190
 
            if ((ctx->views[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) {
191
 
                pcilib_error("Accessing invalid register %u (associated view does not provide register functionality)", addr + i);
192
 
                return PCILIB_ERROR_INVALID_REQUEST;
193
 
            }
194
 
 
195
 
            if ((ctx->views[i]->mode&PCILIB_ACCESS_R) == 0) {
196
 
                pcilib_error("Read access is not allowed to register %u", addr + i);
197
 
                return PCILIB_ERROR_NOTPERMITED;
198
 
            }
199
 
        }
200
 
    } 
201
 
 
202
 
    //err = pcilib_init_register_banks(ctx);
203
 
    //if (err) return err;
204
 
    
205
 
    //n += bits / b->access;
206
 
    //bits %= b->access; 
207
 
    
208
188
    for (i = 0; i < n; i++) {
209
189
        err = bapi->read(ctx, bctx, addr + i * access, buf + i);
210
190
        if (err) break;
315
295
        return PCILIB_ERROR_OUTOFRANGE;
316
296
    }
317
297
 
318
 
    if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) {
319
 
        for (i = 0; i < (bits?(n+1):n); i++) {
320
 
            if ((ctx->views[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) {
321
 
                pcilib_error("Accessing invalid register %u (associated view does not provide register functionality)", addr + i);
322
 
                return PCILIB_ERROR_INVALID_REQUEST;
323
 
            }
324
 
 
325
 
            if ((ctx->views[i]->mode&PCILIB_ACCESS_W) == 0) {
326
 
                pcilib_error("Write access is not allowed to register %u", addr + i);
327
 
                return PCILIB_ERROR_NOTPERMITED;
328
 
            }
329
 
        }
330
 
    } 
331
 
 
332
 
    //err = pcilib_init_register_banks(ctx);
333
 
    //if (err) return err;
334
 
    
335
 
    //n += bits / b->access;
336
 
    //bits %= b->access; 
337
 
    
338
298
    for (i = 0; i < n; i++) {
339
299
        err = bapi->write(ctx, bctx, addr + i * access, buf[i]);
340
300
        if (err) break;