aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-transaction.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-07-16 20:10:16 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-10-16 18:00:00 -0400
commit1415d9189e8c59aa9c77a3bba419dcea062c145f (patch)
tree9253dc4ea24ab55194babeba52f830485c05da2c /drivers/firewire/fw-transaction.c
parent002a98f14720f90b107e8c44b7733f9bd5dff728 (diff)
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: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/fw-transaction.c')
-rw-r--r--drivers/firewire/fw-transaction.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 3e1cb12e43cd..9959b799dbe2 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -410,7 +410,12 @@ EXPORT_SYMBOL(fw_unit_space_region);
410 * controller. When a request is received that falls within the 410 * controller. When a request is received that falls within the
411 * specified address range, the specified callback is invoked. The 411 * specified address range, the specified callback is invoked. The
412 * parameters passed to the callback give the details of the 412 * parameters passed to the callback give the details of the
413 * particular request 413 * particular request.
414 *
415 * Return value: 0 on success, non-zero otherwise.
416 * The start offset of the handler's address region is determined by
417 * fw_core_add_address_handler() and is returned in handler->offset.
418 * The offset is quadlet-aligned.
414 */ 419 */
415int 420int
416fw_core_add_address_handler(struct fw_address_handler *handler, 421fw_core_add_address_handler(struct fw_address_handler *handler,
@@ -422,14 +427,15 @@ fw_core_add_address_handler(struct fw_address_handler *handler,
422 427
423 spin_lock_irqsave(&address_handler_lock, flags); 428 spin_lock_irqsave(&address_handler_lock, flags);
424 429
425 handler->offset = region->start; 430 handler->offset = roundup(region->start, 4);
426 while (handler->offset + handler->length <= region->end) { 431 while (handler->offset + handler->length <= region->end) {
427 other = 432 other =
428 lookup_overlapping_address_handler(&address_handler_list, 433 lookup_overlapping_address_handler(&address_handler_list,
429 handler->offset, 434 handler->offset,
430 handler->length); 435 handler->length);
431 if (other != NULL) { 436 if (other != NULL) {
432 handler->offset += other->length; 437 handler->offset =
438 roundup(other->offset + other->length, 4);
433 } else { 439 } else {
434 list_add_tail(&handler->link, &address_handler_list); 440 list_add_tail(&handler->link, &address_handler_list);
435 ret = 0; 441 ret = 0;