diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-10-22 15:57:59 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-10-22 15:57:59 +0200 |
commit | a0fe5cdea15bca52d3b101a88c11cb160ef08b2f (patch) | |
tree | e40e5d90ed013e33617931b049c5039e37a1f51f /protocols/property.c | |
parent | ee18798c64c6e40433413b73bf07bbe027a9cc6e (diff) | |
download | pcitool-a0fe5cdea15bca52d3b101a88c11cb160ef08b2f.tar.gz pcitool-a0fe5cdea15bca52d3b101a88c11cb160ef08b2f.tar.bz2 pcitool-a0fe5cdea15bca52d3b101a88c11cb160ef08b2f.tar.xz pcitool-a0fe5cdea15bca52d3b101a88c11cb160ef08b2f.zip |
Documentation update
Diffstat (limited to 'protocols/property.c')
-rw-r--r-- | protocols/property.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/protocols/property.c b/protocols/property.c index 0c7cf5d..978f22e 100644 --- a/protocols/property.c +++ b/protocols/property.c @@ -8,13 +8,16 @@ #include "error.h" -int pcilib_property_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t *regval) { +int pcilib_property_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t *bank_ctx, pcilib_register_addr_t addr, pcilib_register_value_t *regval) { int err; - pcilib_view_t view = addr; + const pcilib_register_bank_description_t *b = bank_ctx->bank; + int access = b->access / 8; + + pcilib_view_t view = addr / access; pcilib_value_t val = {0}; - if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)) + if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)||(addr % access)) return PCILIB_ERROR_INVALID_ARGUMENT; err = pcilib_get_property(ctx, ctx->views[view]->name, &val); @@ -26,13 +29,16 @@ int pcilib_property_registers_read(pcilib_t *ctx, pcilib_register_bank_context_t } -int pcilib_property_registers_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank, pcilib_register_addr_t addr, pcilib_register_value_t regval) { +int pcilib_property_registers_write(pcilib_t *ctx, pcilib_register_bank_context_t *bank_ctx, pcilib_register_addr_t addr, pcilib_register_value_t regval) { int err; - pcilib_view_t view = addr; + const pcilib_register_bank_description_t *b = bank_ctx->bank; + int access = b->access / 8; + + pcilib_view_t view = addr / access; pcilib_value_t val = {0}; - if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)) + if ((view == PCILIB_VIEW_INVALID)||(view >= ctx->num_views)||(addr % access)) return PCILIB_ERROR_INVALID_ARGUMENT; err = pcilib_set_value_from_register_value(ctx, &val, regval); |