From ad838ab9f70ff9712c256f072e260e03a8d7a7da Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 22 Oct 2015 17:08:11 +0200 Subject: Fix access to the property-based registers --- pcilib/property.c | 6 +++--- pcilib/register.c | 40 ---------------------------------------- 2 files changed, 3 insertions(+), 43 deletions(-) (limited to 'pcilib') diff --git a/pcilib/property.c b/pcilib/property.c index a39594c..7239601 100644 --- a/pcilib/property.c +++ b/pcilib/property.c @@ -34,9 +34,9 @@ int pcilib_add_registers_from_properties(pcilib_t *ctx, size_t n, pcilib_view_co return err; } } - - access = ctx->banks[bank].access; - + + access = ctx->banks[bank].access / 8; + for (i = 0; i < n; i++) { if ((v[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) continue; diff --git a/pcilib/register.c b/pcilib/register.c index 1f1cf9e..a11bdac 100644 --- a/pcilib/register.c +++ b/pcilib/register.c @@ -185,26 +185,6 @@ static int pcilib_read_register_space_internal(pcilib_t *ctx, pcilib_register_ba return PCILIB_ERROR_OUTOFRANGE; } - if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) { - for (i = 0; i < (bits?(n+1):n); i++) { - if ((ctx->views[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) { - pcilib_error("Accessing invalid register %u (associated view does not provide register functionality)", addr + i); - return PCILIB_ERROR_INVALID_REQUEST; - } - - if ((ctx->views[i]->mode&PCILIB_ACCESS_R) == 0) { - pcilib_error("Read access is not allowed to register %u", addr + i); - return PCILIB_ERROR_NOTPERMITED; - } - } - } - - //err = pcilib_init_register_banks(ctx); - //if (err) return err; - - //n += bits / b->access; - //bits %= b->access; - for (i = 0; i < n; i++) { err = bapi->read(ctx, bctx, addr + i * access, buf + i); if (err) break; @@ -315,26 +295,6 @@ static int pcilib_write_register_space_internal(pcilib_t *ctx, pcilib_register_b return PCILIB_ERROR_OUTOFRANGE; } - if (b->protocol == PCILIB_REGISTER_PROTOCOL_PROPERTY) { - for (i = 0; i < (bits?(n+1):n); i++) { - if ((ctx->views[i]->flags&PCILIB_VIEW_FLAG_REGISTER) == 0) { - pcilib_error("Accessing invalid register %u (associated view does not provide register functionality)", addr + i); - return PCILIB_ERROR_INVALID_REQUEST; - } - - if ((ctx->views[i]->mode&PCILIB_ACCESS_W) == 0) { - pcilib_error("Write access is not allowed to register %u", addr + i); - return PCILIB_ERROR_NOTPERMITED; - } - } - } - - //err = pcilib_init_register_banks(ctx); - //if (err) return err; - - //n += bits / b->access; - //bits %= b->access; - for (i = 0; i < n; i++) { err = bapi->write(ctx, bctx, addr + i * access, buf[i]); if (err) break; -- cgit v1.2.3