Commit 1415d918 authored by Stefan Richter's avatar Stefan Richter

firewire: optimize fw_core_add_address_handler

Potentially avoids unnecessary loop runs.
Guarantee quadlet-aligned starts of address regions.
Document the return values.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 002a98f1
...@@ -410,7 +410,12 @@ EXPORT_SYMBOL(fw_unit_space_region); ...@@ -410,7 +410,12 @@ EXPORT_SYMBOL(fw_unit_space_region);
* controller. When a request is received that falls within the * controller. When a request is received that falls within the
* specified address range, the specified callback is invoked. The * specified address range, the specified callback is invoked. The
* parameters passed to the callback give the details of the * parameters passed to the callback give the details of the
* particular request * particular request.
*
* Return value: 0 on success, non-zero otherwise.
* The start offset of the handler's address region is determined by
* fw_core_add_address_handler() and is returned in handler->offset.
* The offset is quadlet-aligned.
*/ */
int int
fw_core_add_address_handler(struct fw_address_handler *handler, fw_core_add_address_handler(struct fw_address_handler *handler,
...@@ -422,14 +427,15 @@ fw_core_add_address_handler(struct fw_address_handler *handler, ...@@ -422,14 +427,15 @@ fw_core_add_address_handler(struct fw_address_handler *handler,
spin_lock_irqsave(&address_handler_lock, flags); spin_lock_irqsave(&address_handler_lock, flags);
handler->offset = region->start; handler->offset = roundup(region->start, 4);
while (handler->offset + handler->length <= region->end) { while (handler->offset + handler->length <= region->end) {
other = other =
lookup_overlapping_address_handler(&address_handler_list, lookup_overlapping_address_handler(&address_handler_list,
handler->offset, handler->offset,
handler->length); handler->length);
if (other != NULL) { if (other != NULL) {
handler->offset += other->length; handler->offset =
roundup(other->offset + other->length, 4);
} else { } else {
list_add_tail(&handler->link, &address_handler_list); list_add_tail(&handler->link, &address_handler_list);
ret = 0; ret = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment