Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firewire: core: use helper macros instead of direct access to HZ

There are some macros available to convert usecs, msecs, and secs into
jiffies count.

Link: https://lore.kernel.org/r/20250915024232.851955-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+16 -17
+7 -10
drivers/firewire/core-card.c
··· 229 229 230 230 /* Use an arbitrary short delay to combine multiple reset requests. */ 231 231 fw_card_get(card); 232 - if (!queue_delayed_work(fw_workqueue, &card->br_work, 233 - delayed ? DIV_ROUND_UP(HZ, 100) : 0)) 232 + if (!queue_delayed_work(fw_workqueue, &card->br_work, delayed ? msecs_to_jiffies(10) : 0)) 234 233 fw_card_put(card); 235 234 } 236 235 EXPORT_SYMBOL(fw_schedule_bus_reset); ··· 240 241 241 242 /* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */ 242 243 if (card->reset_jiffies != 0 && 243 - time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) { 244 + time_before64(get_jiffies_64(), card->reset_jiffies + secs_to_jiffies(2))) { 244 245 trace_bus_reset_postpone(card->index, card->generation, card->br_short); 245 246 246 - if (!queue_delayed_work(fw_workqueue, &card->br_work, 2 * HZ)) 247 + if (!queue_delayed_work(fw_workqueue, &card->br_work, secs_to_jiffies(2))) 247 248 fw_card_put(card); 248 249 return; 249 250 } ··· 308 309 irm_id = card->irm_node->node_id; 309 310 local_id = card->local_node->node_id; 310 311 311 - grace = time_after64(get_jiffies_64(), 312 - card->reset_jiffies + DIV_ROUND_UP(HZ, 8)); 312 + grace = time_after64(get_jiffies_64(), card->reset_jiffies + msecs_to_jiffies(125)); 313 313 314 314 if ((is_next_generation(generation, card->bm_generation) && 315 315 !card->bm_abdicate) || ··· 394 396 * that the problem has gone away by then. 395 397 */ 396 398 spin_unlock_irq(&card->lock); 397 - fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); 399 + fw_schedule_bm_work(card, msecs_to_jiffies(125)); 398 400 return; 399 401 } 400 402 ··· 416 418 * bus reset is less than 125ms ago. Reschedule this job. 417 419 */ 418 420 spin_unlock_irq(&card->lock); 419 - fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); 421 + fw_schedule_bm_work(card, msecs_to_jiffies(125)); 420 422 return; 421 423 } 422 424 ··· 549 551 card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000; 550 552 card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; 551 553 card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT; 552 - card->split_timeout_jiffies = 553 - DIV_ROUND_UP(DEFAULT_SPLIT_TIMEOUT * HZ, 8000); 554 + card->split_timeout_jiffies = isoc_cycles_to_jiffies(DEFAULT_SPLIT_TIMEOUT); 554 555 card->color = 0; 555 556 card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; 556 557
+2 -2
drivers/firewire/core-cdev.c
··· 1324 1324 todo = r->todo; 1325 1325 // Allow 1000ms grace period for other reallocations. 1326 1326 if (todo == ISO_RES_ALLOC && 1327 - time_before64(get_jiffies_64(), client->device->card->reset_jiffies + HZ)) { 1328 - schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3)); 1327 + time_before64(get_jiffies_64(), client->device->card->reset_jiffies + secs_to_jiffies(1))) { 1328 + schedule_iso_resource(r, msecs_to_jiffies(333)); 1329 1329 skip = true; 1330 1330 } else { 1331 1331 // We could be called twice within the same generation.
+3 -3
drivers/firewire/core-device.c
··· 847 847 */ 848 848 849 849 #define MAX_RETRIES 10 850 - #define RETRY_DELAY (3 * HZ) 851 - #define INITIAL_DELAY (HZ / 2) 852 - #define SHUTDOWN_DELAY (2 * HZ) 850 + #define RETRY_DELAY secs_to_jiffies(3) 851 + #define INITIAL_DELAY msecs_to_jiffies(500) 852 + #define SHUTDOWN_DELAY secs_to_jiffies(2) 853 853 854 854 static void fw_device_shutdown(struct work_struct *work) 855 855 {
+2 -2
drivers/firewire/core-transaction.c
··· 458 458 void fw_send_phy_config(struct fw_card *card, 459 459 int node_id, int generation, int gap_count) 460 460 { 461 - long timeout = DIV_ROUND_UP(HZ, 10); 461 + long timeout = msecs_to_jiffies(100); 462 462 u32 data = 0; 463 463 464 464 phy_packet_set_packet_identifier(&data, PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG); ··· 1220 1220 cycles = clamp(cycles, 800u, 3u * 8000u); 1221 1221 1222 1222 card->split_timeout_cycles = cycles; 1223 - card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); 1223 + card->split_timeout_jiffies = isoc_cycles_to_jiffies(cycles); 1224 1224 } 1225 1225 1226 1226 static void handle_registers(struct fw_card *card, struct fw_request *request,
+2
drivers/firewire/core.h
··· 30 30 // This is the arbitrary value we use to indicate a mismatched gap count. 31 31 #define GAP_COUNT_MISMATCHED 0 32 32 33 + #define isoc_cycles_to_jiffies(cycles) usecs_to_jiffies(cycles * USEC_PER_SEC / 8000) 34 + 33 35 extern __printf(2, 3) 34 36 void fw_err(const struct fw_card *card, const char *fmt, ...); 35 37 extern __printf(2, 3)