From 3388caa2dbf04251ff7d1b4fd94a7d7fd09da074 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 13 Sep 2026 19:13:54 +0900 Subject: firewire: ohci: refactor multiple calls to fw_fill_response() 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. Link: https://lore.kernel.org/r/20260913101356.156420-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto --- 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); -- cgit v1.2.3