[PATCH 3/5] firewire: ohci: refactor multiple calls to fw_fill_response()
From: Takashi Sakamoto
Date: Sun Sep 13 2026 - 06:16:30 EST
The handle_local_rom() function calls fw_fill_response() in each
conditional branch. Using local variables for the function parameters
allows the function to be called from a single place.
Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/ohci.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 290bac5112b7..ec069657ea8b 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -1459,7 +1459,8 @@ static void handle_local_rom(struct fw_ohci *ohci,
struct fw_packet *packet, u32 csr)
{
struct fw_packet response;
- int tcode, length, i;
+ int tcode, rcode, length, i;
+ void *payload = NULL;
tcode = async_header_get_tcode(packet->header);
if (tcode_is_block_packet(tcode))
@@ -1469,16 +1470,18 @@ static void handle_local_rom(struct fw_ohci *ohci,
i = csr - CSR_CONFIG_ROM;
if (i + length > CONFIG_ROM_SIZE) {
- fw_fill_response(&response, packet->header,
- RCODE_ADDRESS_ERROR, NULL, 0);
+ rcode = RCODE_ADDRESS_ERROR;
+ length = 0;
} else if (!tcode_is_read_request(tcode)) {
- fw_fill_response(&response, packet->header,
- RCODE_TYPE_ERROR, NULL, 0);
+ rcode = RCODE_TYPE_ERROR;
+ length = 0;
} else {
- fw_fill_response(&response, packet->header, RCODE_COMPLETE,
- (void *) ohci->config_rom + i, length);
+ rcode = RCODE_COMPLETE;
+ payload = (u8 *)ohci->config_rom + i;
}
+ fw_fill_response(&response, packet->header, rcode, payload, length);
+
// Timestamping on behalf of the hardware.
response.timestamp = cycle_time_to_ohci_tstamp(get_cycle_time(ohci));
fw_core_handle_response(&ohci->card, &response);
--
2.53.0