ieee1394: adjust code formatting in highlevel.c
Replace spaces by tabulators, wrap lines at 80 columns, delete some blank lines and superfluous braces. Collapse some if()-within-if() constructs. Replace a literal CSR address by its preprocessor constant. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Ben Collins <bcollins@ubuntu.com>
This commit is contained in:
parent
445151932e
commit
2c4b69bd7b
|
@ -68,24 +68,18 @@ static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
read_unlock(&hl->host_info_lock);
|
read_unlock(&hl->host_info_lock);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Returns a per host/driver data structure that was previously stored by
|
/* Returns a per host/driver data structure that was previously stored by
|
||||||
* hpsb_create_hostinfo. */
|
* hpsb_create_hostinfo. */
|
||||||
void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
|
void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
|
||||||
{
|
{
|
||||||
struct hl_host_info *hi = hl_get_hostinfo(hl, host);
|
struct hl_host_info *hi = hl_get_hostinfo(hl, host);
|
||||||
|
|
||||||
if (hi)
|
return hi ? hi->data : NULL;
|
||||||
return hi->data;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* If size is zero, then the return here is only valid for error checking */
|
/* If size is zero, then the return here is only valid for error checking */
|
||||||
void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
size_t data_size)
|
size_t data_size)
|
||||||
|
@ -96,8 +90,8 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
|
|
||||||
hi = hl_get_hostinfo(hl, host);
|
hi = hl_get_hostinfo(hl, host);
|
||||||
if (hi) {
|
if (hi) {
|
||||||
HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already exists",
|
HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already"
|
||||||
hl->name);
|
" exists", hl->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +114,6 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
@ -132,16 +125,14 @@ int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
hi->data = data;
|
hi->data = data;
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo already has data",
|
HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo "
|
||||||
hl->name);
|
"already has data", hl->name);
|
||||||
} else
|
} else
|
||||||
HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
|
HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
|
||||||
hl->name);
|
hl->name);
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
|
void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
|
||||||
{
|
{
|
||||||
struct hl_host_info *hi;
|
struct hl_host_info *hi;
|
||||||
|
@ -154,23 +145,20 @@ void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
|
||||||
write_unlock_irqrestore(&hl->host_info_lock, flags);
|
write_unlock_irqrestore(&hl->host_info_lock, flags);
|
||||||
kfree(hi);
|
kfree(hi);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, unsigned long key)
|
unsigned long key)
|
||||||
{
|
{
|
||||||
struct hl_host_info *hi;
|
struct hl_host_info *hi;
|
||||||
|
|
||||||
hi = hl_get_hostinfo(hl, host);
|
hi = hl_get_hostinfo(hl, host);
|
||||||
if (hi)
|
if (hi)
|
||||||
hi->key = key;
|
hi->key = key;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
|
void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
|
||||||
{
|
{
|
||||||
struct hl_host_info *hi;
|
struct hl_host_info *hi;
|
||||||
|
@ -187,24 +175,18 @@ void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
read_unlock(&hl->host_info_lock);
|
read_unlock(&hl->host_info_lock);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int highlevel_for_each_host_reg(struct hpsb_host *host, void *__data)
|
static int highlevel_for_each_host_reg(struct hpsb_host *host, void *__data)
|
||||||
{
|
{
|
||||||
struct hpsb_highlevel *hl = __data;
|
struct hpsb_highlevel *hl = __data;
|
||||||
|
|
||||||
hl->add_host(host);
|
hl->add_host(host);
|
||||||
|
|
||||||
if (host->update_config_rom) {
|
if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
|
||||||
if (hpsb_update_config_rom_image(host) < 0) {
|
|
||||||
HPSB_ERR("Failed to generate Configuration ROM image for host "
|
HPSB_ERR("Failed to generate Configuration ROM image for host "
|
||||||
"%s-%d", hl->name, host->id);
|
"%s-%d", hl->name, host->id);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +209,6 @@ void hpsb_register_highlevel(struct hpsb_highlevel *hl)
|
||||||
|
|
||||||
if (hl->add_host)
|
if (hl->add_host)
|
||||||
nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
|
nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +219,8 @@ static void __delete_addr(struct hpsb_address_serve *as)
|
||||||
kfree(as);
|
kfree(as);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host, int update_cr)
|
static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
|
int update_cr)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct list_head *lh, *next;
|
struct list_head *lh, *next;
|
||||||
|
@ -253,7 +235,6 @@ static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
write_lock_irqsave(&addr_space_lock, flags);
|
write_lock_irqsave(&addr_space_lock, flags);
|
||||||
list_for_each_safe (lh, next, &hl->addr_list) {
|
list_for_each_safe (lh, next, &hl->addr_list) {
|
||||||
as = list_entry(lh, struct hpsb_address_serve, hl_list);
|
as = list_entry(lh, struct hpsb_address_serve, hl_list);
|
||||||
|
|
||||||
if (as->host == host)
|
if (as->host == host)
|
||||||
__delete_addr(as);
|
__delete_addr(as);
|
||||||
}
|
}
|
||||||
|
@ -261,15 +242,12 @@ static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
|
|
||||||
/* Now update the config-rom to reflect anything removed by the
|
/* Now update the config-rom to reflect anything removed by the
|
||||||
* highlevel driver. */
|
* highlevel driver. */
|
||||||
if (update_cr && host->update_config_rom) {
|
if (update_cr && host->update_config_rom &&
|
||||||
if (hpsb_update_config_rom_image(host) < 0) {
|
hpsb_update_config_rom_image(host) < 0)
|
||||||
HPSB_ERR("Failed to generate Configuration ROM image for host "
|
HPSB_ERR("Failed to generate Configuration ROM image for host "
|
||||||
"%s-%d", hl->name, host->id);
|
"%s-%d", hl->name, host->id);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* And finally, remove all the host info associated between these
|
/* Finally remove all the host info associated between these two. */
|
||||||
* two. */
|
|
||||||
hpsb_destroy_hostinfo(hl, host);
|
hpsb_destroy_hostinfo(hl, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +256,6 @@ static int highlevel_for_each_host_unreg(struct hpsb_host *host, void *__data)
|
||||||
struct hpsb_highlevel *hl = __data;
|
struct hpsb_highlevel *hl = __data;
|
||||||
|
|
||||||
__unregister_host(hl, host, 1);
|
__unregister_host(hl, host, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,9 +301,11 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
|
||||||
end = CSR1212_ALL_SPACE_END;
|
end = CSR1212_ALL_SPACE_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((start|end) & ~align_mask) || (start >= end) || (end > 0x1000000000000ULL)) {
|
if (((start|end) & ~align_mask) || (start >= end) ||
|
||||||
HPSB_ERR("%s called with invalid addresses (start = %012Lx end = %012Lx)",
|
(end > CSR1212_ALL_SPACE_END)) {
|
||||||
__FUNCTION__, (unsigned long long)start, (unsigned long long)end);
|
HPSB_ERR("%s called with invalid addresses "
|
||||||
|
"(start = %012Lx end = %012Lx)", __FUNCTION__,
|
||||||
|
(unsigned long long)start,(unsigned long long)end);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,20 +319,21 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
|
||||||
as->host = host;
|
as->host = host;
|
||||||
|
|
||||||
write_lock_irqsave(&addr_space_lock, flags);
|
write_lock_irqsave(&addr_space_lock, flags);
|
||||||
|
|
||||||
list_for_each(entry, &host->addr_space) {
|
list_for_each(entry, &host->addr_space) {
|
||||||
u64 a1sa, a1ea;
|
u64 a1sa, a1ea;
|
||||||
u64 a2sa, a2ea;
|
u64 a2sa, a2ea;
|
||||||
|
|
||||||
a1 = list_entry(entry, struct hpsb_address_serve, host_list);
|
a1 = list_entry(entry, struct hpsb_address_serve, host_list);
|
||||||
a2 = list_entry(entry->next, struct hpsb_address_serve, host_list);
|
a2 = list_entry(entry->next, struct hpsb_address_serve,
|
||||||
|
host_list);
|
||||||
|
|
||||||
a1sa = a1->start & align_mask;
|
a1sa = a1->start & align_mask;
|
||||||
a1ea = (a1->end + alignment -1) & align_mask;
|
a1ea = (a1->end + alignment -1) & align_mask;
|
||||||
a2sa = a2->start & align_mask;
|
a2sa = a2->start & align_mask;
|
||||||
a2ea = (a2->end + alignment -1) & align_mask;
|
a2ea = (a2->end + alignment -1) & align_mask;
|
||||||
|
|
||||||
if ((a2sa - a1ea >= size) && (a2sa - start >= size) && (a2sa > start)) {
|
if ((a2sa - a1ea >= size) && (a2sa - start >= size) &&
|
||||||
|
(a2sa > start)) {
|
||||||
as->start = max(start, a1ea);
|
as->start = max(start, a1ea);
|
||||||
as->end = as->start + size;
|
as->end = as->start + size;
|
||||||
list_add(&as->host_list, entry);
|
list_add(&as->host_list, entry);
|
||||||
|
@ -362,13 +342,10 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write_unlock_irqrestore(&addr_space_lock, flags);
|
write_unlock_irqrestore(&addr_space_lock, flags);
|
||||||
|
|
||||||
if (retval == CSR1212_INVALID_ADDR_SPACE) {
|
if (retval == CSR1212_INVALID_ADDR_SPACE)
|
||||||
kfree(as);
|
kfree(as);
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +357,8 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (((start|end) & 3) || (start >= end) || (end > 0x1000000000000ULL)) {
|
if (((start|end) & 3) || (start >= end) ||
|
||||||
|
(end > CSR1212_ALL_SPACE_END)) {
|
||||||
HPSB_ERR("%s called with invalid addresses", __FUNCTION__);
|
HPSB_ERR("%s called with invalid addresses", __FUNCTION__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -397,12 +375,12 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
as->host = host;
|
as->host = host;
|
||||||
|
|
||||||
write_lock_irqsave(&addr_space_lock, flags);
|
write_lock_irqsave(&addr_space_lock, flags);
|
||||||
|
|
||||||
list_for_each(lh, &host->addr_space) {
|
list_for_each(lh, &host->addr_space) {
|
||||||
struct hpsb_address_serve *as_this =
|
struct hpsb_address_serve *as_this =
|
||||||
list_entry(lh, struct hpsb_address_serve, host_list);
|
list_entry(lh, struct hpsb_address_serve, host_list);
|
||||||
struct hpsb_address_serve *as_next =
|
struct hpsb_address_serve *as_next =
|
||||||
list_entry(lh->next, struct hpsb_address_serve, host_list);
|
list_entry(lh->next, struct hpsb_address_serve,
|
||||||
|
host_list);
|
||||||
|
|
||||||
if (as_this->end > as->start)
|
if (as_this->end > as->start)
|
||||||
break;
|
break;
|
||||||
|
@ -418,7 +396,6 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
|
|
||||||
if (retval == 0)
|
if (retval == 0)
|
||||||
kfree(as);
|
kfree(as);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +408,6 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
write_lock_irqsave(&addr_space_lock, flags);
|
write_lock_irqsave(&addr_space_lock, flags);
|
||||||
|
|
||||||
list_for_each_safe (lh, next, &hl->addr_list) {
|
list_for_each_safe (lh, next, &hl->addr_list) {
|
||||||
as = list_entry(lh, struct hpsb_address_serve, hl_list);
|
as = list_entry(lh, struct hpsb_address_serve, hl_list);
|
||||||
if (as->start == start && as->host == host) {
|
if (as->start == start && as->host == host) {
|
||||||
|
@ -440,9 +416,7 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write_unlock_irqrestore(&addr_space_lock, flags);
|
write_unlock_irqrestore(&addr_space_lock, flags);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,11 +427,8 @@ int hpsb_listen_channel(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
HPSB_ERR("%s called with invalid channel", __FUNCTION__);
|
HPSB_ERR("%s called with invalid channel", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
if (host->iso_listen_count[channel]++ == 0)
|
||||||
if (host->iso_listen_count[channel]++ == 0) {
|
|
||||||
return host->driver->devctl(host, ISO_LISTEN_CHANNEL, channel);
|
return host->driver->devctl(host, ISO_LISTEN_CHANNEL, channel);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,11 +439,9 @@ void hpsb_unlisten_channel(struct hpsb_highlevel *hl, struct hpsb_host *host,
|
||||||
HPSB_ERR("%s called with invalid channel", __FUNCTION__);
|
HPSB_ERR("%s called with invalid channel", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (--host->iso_listen_count[channel] == 0)
|
||||||
if (--host->iso_listen_count[channel] == 0) {
|
|
||||||
host->driver->devctl(host, ISO_UNLISTEN_CHANNEL, channel);
|
host->driver->devctl(host, ISO_UNLISTEN_CHANNEL, channel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void init_hpsb_highlevel(struct hpsb_host *host)
|
static void init_hpsb_highlevel(struct hpsb_host *host)
|
||||||
{
|
{
|
||||||
|
@ -502,11 +471,9 @@ void highlevel_add_host(struct hpsb_host *host)
|
||||||
hl->add_host(host);
|
hl->add_host(host);
|
||||||
}
|
}
|
||||||
up_read(&hl_drivers_sem);
|
up_read(&hl_drivers_sem);
|
||||||
if (host->update_config_rom) {
|
if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
|
||||||
if (hpsb_update_config_rom_image(host) < 0)
|
HPSB_ERR("Failed to generate Configuration ROM image for host "
|
||||||
HPSB_ERR("Failed to generate Configuration ROM image for "
|
"%s-%d", hl->name, host->id);
|
||||||
"host %s-%d", hl->name, host->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void highlevel_remove_host(struct hpsb_host *host)
|
void highlevel_remove_host(struct hpsb_host *host)
|
||||||
|
@ -562,7 +529,43 @@ void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
|
||||||
read_unlock_irqrestore(&hl_irqs_lock, flags);
|
read_unlock_irqrestore(&hl_irqs_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
|
int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr,
|
||||||
|
unsigned int length, u16 flags)
|
||||||
|
{
|
||||||
|
struct hpsb_address_serve *as;
|
||||||
|
unsigned int partlength;
|
||||||
|
int rcode = RCODE_ADDRESS_ERROR;
|
||||||
|
|
||||||
|
read_lock(&addr_space_lock);
|
||||||
|
list_for_each_entry(as, &host->addr_space, host_list) {
|
||||||
|
if (as->start > addr)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (as->end > addr) {
|
||||||
|
partlength = min(as->end - addr, (u64) length);
|
||||||
|
|
||||||
|
if (as->op->read)
|
||||||
|
rcode = as->op->read(host, nodeid, data,
|
||||||
|
addr, partlength, flags);
|
||||||
|
else
|
||||||
|
rcode = RCODE_TYPE_ERROR;
|
||||||
|
|
||||||
|
data += partlength;
|
||||||
|
length -= partlength;
|
||||||
|
addr += partlength;
|
||||||
|
|
||||||
|
if ((rcode != RCODE_COMPLETE) || !length)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read_unlock(&addr_space_lock);
|
||||||
|
|
||||||
|
if (length && (rcode == RCODE_COMPLETE))
|
||||||
|
rcode = RCODE_ADDRESS_ERROR;
|
||||||
|
return rcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data,
|
||||||
u64 addr, unsigned int length, u16 flags)
|
u64 addr, unsigned int length, u16 flags)
|
||||||
{
|
{
|
||||||
struct hpsb_address_serve *as;
|
struct hpsb_address_serve *as;
|
||||||
|
@ -570,7 +573,6 @@ int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
|
||||||
int rcode = RCODE_ADDRESS_ERROR;
|
int rcode = RCODE_ADDRESS_ERROR;
|
||||||
|
|
||||||
read_lock(&addr_space_lock);
|
read_lock(&addr_space_lock);
|
||||||
|
|
||||||
list_for_each_entry(as, &host->addr_space, host_list) {
|
list_for_each_entry(as, &host->addr_space, host_list) {
|
||||||
if (as->start > addr)
|
if (as->start > addr)
|
||||||
break;
|
break;
|
||||||
|
@ -578,106 +580,57 @@ int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
|
||||||
if (as->end > addr) {
|
if (as->end > addr) {
|
||||||
partlength = min(as->end - addr, (u64) length);
|
partlength = min(as->end - addr, (u64) length);
|
||||||
|
|
||||||
if (as->op->read) {
|
if (as->op->write)
|
||||||
rcode = as->op->read(host, nodeid, data,
|
|
||||||
addr, partlength, flags);
|
|
||||||
} else {
|
|
||||||
rcode = RCODE_TYPE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
data += partlength;
|
|
||||||
length -= partlength;
|
|
||||||
addr += partlength;
|
|
||||||
|
|
||||||
if ((rcode != RCODE_COMPLETE) || !length) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
read_unlock(&addr_space_lock);
|
|
||||||
|
|
||||||
if (length && (rcode == RCODE_COMPLETE)) {
|
|
||||||
rcode = RCODE_ADDRESS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
int highlevel_write(struct hpsb_host *host, int nodeid, int destid,
|
|
||||||
void *data, u64 addr, unsigned int length, u16 flags)
|
|
||||||
{
|
|
||||||
struct hpsb_address_serve *as;
|
|
||||||
unsigned int partlength;
|
|
||||||
int rcode = RCODE_ADDRESS_ERROR;
|
|
||||||
|
|
||||||
read_lock(&addr_space_lock);
|
|
||||||
|
|
||||||
list_for_each_entry(as, &host->addr_space, host_list) {
|
|
||||||
if (as->start > addr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (as->end > addr) {
|
|
||||||
partlength = min(as->end - addr, (u64) length);
|
|
||||||
|
|
||||||
if (as->op->write) {
|
|
||||||
rcode = as->op->write(host, nodeid, destid,
|
rcode = as->op->write(host, nodeid, destid,
|
||||||
data, addr, partlength, flags);
|
data, addr, partlength,
|
||||||
} else {
|
flags);
|
||||||
|
else
|
||||||
rcode = RCODE_TYPE_ERROR;
|
rcode = RCODE_TYPE_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
data += partlength;
|
data += partlength;
|
||||||
length -= partlength;
|
length -= partlength;
|
||||||
addr += partlength;
|
addr += partlength;
|
||||||
|
|
||||||
if ((rcode != RCODE_COMPLETE) || !length) {
|
if ((rcode != RCODE_COMPLETE) || !length)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
read_unlock(&addr_space_lock);
|
read_unlock(&addr_space_lock);
|
||||||
|
|
||||||
if (length && (rcode == RCODE_COMPLETE)) {
|
if (length && (rcode == RCODE_COMPLETE))
|
||||||
rcode = RCODE_ADDRESS_ERROR;
|
rcode = RCODE_ADDRESS_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
|
int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
|
||||||
u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, u16 flags)
|
u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
|
||||||
|
u16 flags)
|
||||||
{
|
{
|
||||||
struct hpsb_address_serve *as;
|
struct hpsb_address_serve *as;
|
||||||
int rcode = RCODE_ADDRESS_ERROR;
|
int rcode = RCODE_ADDRESS_ERROR;
|
||||||
|
|
||||||
read_lock(&addr_space_lock);
|
read_lock(&addr_space_lock);
|
||||||
|
|
||||||
list_for_each_entry(as, &host->addr_space, host_list) {
|
list_for_each_entry(as, &host->addr_space, host_list) {
|
||||||
if (as->start > addr)
|
if (as->start > addr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (as->end > addr) {
|
if (as->end > addr) {
|
||||||
if (as->op->lock) {
|
if (as->op->lock)
|
||||||
rcode = as->op->lock(host, nodeid, store, addr,
|
rcode = as->op->lock(host, nodeid, store, addr,
|
||||||
data, arg, ext_tcode, flags);
|
data, arg, ext_tcode,
|
||||||
} else {
|
flags);
|
||||||
|
else
|
||||||
rcode = RCODE_TYPE_ERROR;
|
rcode = RCODE_TYPE_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read_unlock(&addr_space_lock);
|
read_unlock(&addr_space_lock);
|
||||||
|
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
|
int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
|
||||||
u64 addr, octlet_t data, octlet_t arg, int ext_tcode, u16 flags)
|
u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
|
||||||
|
u16 flags)
|
||||||
{
|
{
|
||||||
struct hpsb_address_serve *as;
|
struct hpsb_address_serve *as;
|
||||||
int rcode = RCODE_ADDRESS_ERROR;
|
int rcode = RCODE_ADDRESS_ERROR;
|
||||||
|
@ -689,19 +642,15 @@ int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (as->end > addr) {
|
if (as->end > addr) {
|
||||||
if (as->op->lock64) {
|
if (as->op->lock64)
|
||||||
rcode = as->op->lock64(host, nodeid, store,
|
rcode = as->op->lock64(host, nodeid, store,
|
||||||
addr, data, arg,
|
addr, data, arg,
|
||||||
ext_tcode, flags);
|
ext_tcode, flags);
|
||||||
} else {
|
else
|
||||||
rcode = RCODE_TYPE_ERROR;
|
rcode = RCODE_TYPE_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read_unlock(&addr_space_lock);
|
read_unlock(&addr_space_lock);
|
||||||
|
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue