Commit eade1e1b authored by Takashi Sakamoto's avatar Takashi Sakamoto

firewire: core: use guard macro to maintain RCU scope for transaction address handler

The core function maintains address handlers by list. RCU is utilized
for efficient read access to any entries in the list.

This commit uses guard macro to maintain RCU locking and releasing.

Link: https://lore.kernel.org/r/20240805085408.251763-6-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 6d72fbc8
...@@ -925,16 +925,14 @@ static void handle_exclusive_region_request(struct fw_card *card, ...@@ -925,16 +925,14 @@ static void handle_exclusive_region_request(struct fw_card *card,
if (tcode == TCODE_LOCK_REQUEST) if (tcode == TCODE_LOCK_REQUEST)
tcode = 0x10 + async_header_get_extended_tcode(p->header); tcode = 0x10 + async_header_get_extended_tcode(p->header);
rcu_read_lock(); scoped_guard(rcu) {
handler = lookup_enclosing_address_handler(&address_handler_list, handler = lookup_enclosing_address_handler(&address_handler_list, offset,
offset, request->length); request->length);
if (handler) if (handler)
handler->address_callback(card, request, handler->address_callback(card, request, tcode, destination, source,
tcode, destination, source, p->generation, offset, request->data,
p->generation, offset, request->length, handler->callback_data);
request->data, request->length, }
handler->callback_data);
rcu_read_unlock();
if (!handler) if (!handler)
fw_send_response(card, request, RCODE_ADDRESS_ERROR); fw_send_response(card, request, RCODE_ADDRESS_ERROR);
...@@ -967,17 +965,14 @@ static void handle_fcp_region_request(struct fw_card *card, ...@@ -967,17 +965,14 @@ static void handle_fcp_region_request(struct fw_card *card,
return; return;
} }
rcu_read_lock(); scoped_guard(rcu) {
list_for_each_entry_rcu(handler, &address_handler_list, link) { list_for_each_entry_rcu(handler, &address_handler_list, link) {
if (is_enclosing_handler(handler, offset, request->length)) if (is_enclosing_handler(handler, offset, request->length))
handler->address_callback(card, request, tcode, handler->address_callback(card, request, tcode, destination, source,
destination, source, p->generation, offset, request->data,
p->generation, offset, request->length, handler->callback_data);
request->data, }
request->length,
handler->callback_data);
} }
rcu_read_unlock();
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
} }
......
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