summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2026-09-13 19:13:54 +0900
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>2026-09-15 06:45:57 +0900
commit3388caa2dbf04251ff7d1b4fd94a7d7fd09da074 (patch)
tree63ac9382f50ab00986f002ceed2ee4d465807730
parenta51a44216f7f03dab66e438f29a632ec211ece94 (diff)
downloadlinux-next-3388caa2dbf04251ff7d1b4fd94a7d7fd09da074.tar.gz
linux-next-3388caa2dbf04251ff7d1b4fd94a7d7fd09da074.zip
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 <o-takashi@sakamocchi.jp>
-rw-r--r--drivers/firewire/ohci.c17
1 files 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);