Commit 379b870c authored by Takashi Sakamoto's avatar Takashi Sakamoto
Browse files

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: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 2ba08d1b
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -229,8 +229,7 @@ void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset)

	/* Use an arbitrary short delay to combine multiple reset requests. */
	fw_card_get(card);
	if (!queue_delayed_work(fw_workqueue, &card->br_work,
				delayed ? DIV_ROUND_UP(HZ, 100) : 0))
	if (!queue_delayed_work(fw_workqueue, &card->br_work, delayed ? msecs_to_jiffies(10) : 0))
		fw_card_put(card);
}
EXPORT_SYMBOL(fw_schedule_bus_reset);
@@ -241,10 +240,10 @@ static void br_work(struct work_struct *work)

	/* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */
	if (card->reset_jiffies != 0 &&
	    time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) {
	    time_before64(get_jiffies_64(), card->reset_jiffies + secs_to_jiffies(2))) {
		trace_bus_reset_postpone(card->index, card->generation, card->br_short);

		if (!queue_delayed_work(fw_workqueue, &card->br_work, 2 * HZ))
		if (!queue_delayed_work(fw_workqueue, &card->br_work, secs_to_jiffies(2)))
			fw_card_put(card);
		return;
	}
@@ -309,8 +308,7 @@ static void bm_work(struct work_struct *work)
	irm_id   = card->irm_node->node_id;
	local_id = card->local_node->node_id;

	grace = time_after64(get_jiffies_64(),
			     card->reset_jiffies + DIV_ROUND_UP(HZ, 8));
	grace = time_after64(get_jiffies_64(), card->reset_jiffies + msecs_to_jiffies(125));

	if ((is_next_generation(generation, card->bm_generation) &&
	     !card->bm_abdicate) ||
@@ -396,7 +394,7 @@ static void bm_work(struct work_struct *work)
			 * that the problem has gone away by then.
			 */
			spin_unlock_irq(&card->lock);
			fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8));
			fw_schedule_bm_work(card, msecs_to_jiffies(125));
			return;
		}

@@ -418,7 +416,7 @@ static void bm_work(struct work_struct *work)
		 * bus reset is less than 125ms ago.  Reschedule this job.
		 */
		spin_unlock_irq(&card->lock);
		fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8));
		fw_schedule_bm_work(card, msecs_to_jiffies(125));
		return;
	}

@@ -551,8 +549,7 @@ void fw_card_initialize(struct fw_card *card,
	card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000;
	card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19;
	card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT;
	card->split_timeout_jiffies =
			DIV_ROUND_UP(DEFAULT_SPLIT_TIMEOUT * HZ, 8000);
	card->split_timeout_jiffies = isoc_cycles_to_jiffies(DEFAULT_SPLIT_TIMEOUT);
	card->color = 0;
	card->broadcast_channel = BROADCAST_CHANNEL_INITIAL;

+2 −2
Original line number Diff line number Diff line
@@ -1324,8 +1324,8 @@ static void iso_resource_work(struct work_struct *work)
		todo = r->todo;
		// Allow 1000ms grace period for other reallocations.
		if (todo == ISO_RES_ALLOC &&
		    time_before64(get_jiffies_64(), client->device->card->reset_jiffies + HZ)) {
			schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3));
		    time_before64(get_jiffies_64(), client->device->card->reset_jiffies + secs_to_jiffies(1))) {
			schedule_iso_resource(r, msecs_to_jiffies(333));
			skip = true;
		} else {
			// We could be called twice within the same generation.
+3 −3
Original line number Diff line number Diff line
@@ -847,9 +847,9 @@ static void fw_schedule_device_work(struct fw_device *device,
 */

#define MAX_RETRIES	10
#define RETRY_DELAY	(3 * HZ)
#define INITIAL_DELAY	(HZ / 2)
#define SHUTDOWN_DELAY	(2 * HZ)
#define RETRY_DELAY	secs_to_jiffies(3)
#define INITIAL_DELAY	msecs_to_jiffies(500)
#define SHUTDOWN_DELAY	secs_to_jiffies(2)

static void fw_device_shutdown(struct work_struct *work)
{
+2 −2
Original line number Diff line number Diff line
@@ -458,7 +458,7 @@ static struct fw_packet phy_config_packet = {
void fw_send_phy_config(struct fw_card *card,
			int node_id, int generation, int gap_count)
{
	long timeout = DIV_ROUND_UP(HZ, 10);
	long timeout = msecs_to_jiffies(100);
	u32 data = 0;

	phy_packet_set_packet_identifier(&data, PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG);
@@ -1220,7 +1220,7 @@ static void update_split_timeout(struct fw_card *card)
	cycles = clamp(cycles, 800u, 3u * 8000u);

	card->split_timeout_cycles = cycles;
	card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000);
	card->split_timeout_jiffies = isoc_cycles_to_jiffies(cycles);
}

static void handle_registers(struct fw_card *card, struct fw_request *request,
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ struct fw_packet;
// This is the arbitrary value we use to indicate a mismatched gap count.
#define GAP_COUNT_MISMATCHED	0

#define isoc_cycles_to_jiffies(cycles)	usecs_to_jiffies(cycles * USEC_PER_SEC / 8000)

extern __printf(2, 3)
void fw_err(const struct fw_card *card, const char *fmt, ...);
extern __printf(2, 3)