mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									2ba08d1bad
								
							
						
					
					
						commit
						379b870c28
					
				
					 5 changed files with 16 additions and 17 deletions
				
			
		| 
						 | 
					@ -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. */
 | 
						/* Use an arbitrary short delay to combine multiple reset requests. */
 | 
				
			||||||
	fw_card_get(card);
 | 
						fw_card_get(card);
 | 
				
			||||||
	if (!queue_delayed_work(fw_workqueue, &card->br_work,
 | 
						if (!queue_delayed_work(fw_workqueue, &card->br_work, delayed ? msecs_to_jiffies(10) : 0))
 | 
				
			||||||
				delayed ? DIV_ROUND_UP(HZ, 100) : 0))
 | 
					 | 
				
			||||||
		fw_card_put(card);
 | 
							fw_card_put(card);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(fw_schedule_bus_reset);
 | 
					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. */
 | 
						/* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */
 | 
				
			||||||
	if (card->reset_jiffies != 0 &&
 | 
						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);
 | 
							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);
 | 
								fw_card_put(card);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -309,8 +308,7 @@ static void bm_work(struct work_struct *work)
 | 
				
			||||||
	irm_id   = card->irm_node->node_id;
 | 
						irm_id   = card->irm_node->node_id;
 | 
				
			||||||
	local_id = card->local_node->node_id;
 | 
						local_id = card->local_node->node_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	grace = time_after64(get_jiffies_64(),
 | 
						grace = time_after64(get_jiffies_64(), card->reset_jiffies + msecs_to_jiffies(125));
 | 
				
			||||||
			     card->reset_jiffies + DIV_ROUND_UP(HZ, 8));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((is_next_generation(generation, card->bm_generation) &&
 | 
						if ((is_next_generation(generation, card->bm_generation) &&
 | 
				
			||||||
	     !card->bm_abdicate) ||
 | 
						     !card->bm_abdicate) ||
 | 
				
			||||||
| 
						 | 
					@ -396,7 +394,7 @@ static void bm_work(struct work_struct *work)
 | 
				
			||||||
			 * that the problem has gone away by then.
 | 
								 * that the problem has gone away by then.
 | 
				
			||||||
			 */
 | 
								 */
 | 
				
			||||||
			spin_unlock_irq(&card->lock);
 | 
								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;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -418,7 +416,7 @@ static void bm_work(struct work_struct *work)
 | 
				
			||||||
		 * bus reset is less than 125ms ago.  Reschedule this job.
 | 
							 * bus reset is less than 125ms ago.  Reschedule this job.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		spin_unlock_irq(&card->lock);
 | 
							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;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -551,8 +549,7 @@ void fw_card_initialize(struct fw_card *card,
 | 
				
			||||||
	card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000;
 | 
						card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000;
 | 
				
			||||||
	card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19;
 | 
						card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19;
 | 
				
			||||||
	card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT;
 | 
						card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT;
 | 
				
			||||||
	card->split_timeout_jiffies =
 | 
						card->split_timeout_jiffies = isoc_cycles_to_jiffies(DEFAULT_SPLIT_TIMEOUT);
 | 
				
			||||||
			DIV_ROUND_UP(DEFAULT_SPLIT_TIMEOUT * HZ, 8000);
 | 
					 | 
				
			||||||
	card->color = 0;
 | 
						card->color = 0;
 | 
				
			||||||
	card->broadcast_channel = BROADCAST_CHANNEL_INITIAL;
 | 
						card->broadcast_channel = BROADCAST_CHANNEL_INITIAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1324,8 +1324,8 @@ static void iso_resource_work(struct work_struct *work)
 | 
				
			||||||
		todo = r->todo;
 | 
							todo = r->todo;
 | 
				
			||||||
		// Allow 1000ms grace period for other reallocations.
 | 
							// Allow 1000ms grace period for other reallocations.
 | 
				
			||||||
		if (todo == ISO_RES_ALLOC &&
 | 
							if (todo == ISO_RES_ALLOC &&
 | 
				
			||||||
		    time_before64(get_jiffies_64(), client->device->card->reset_jiffies + HZ)) {
 | 
							    time_before64(get_jiffies_64(), client->device->card->reset_jiffies + secs_to_jiffies(1))) {
 | 
				
			||||||
			schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3));
 | 
								schedule_iso_resource(r, msecs_to_jiffies(333));
 | 
				
			||||||
			skip = true;
 | 
								skip = true;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			// We could be called twice within the same generation.
 | 
								// We could be called twice within the same generation.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -847,9 +847,9 @@ static void fw_schedule_device_work(struct fw_device *device,
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAX_RETRIES	10
 | 
					#define MAX_RETRIES	10
 | 
				
			||||||
#define RETRY_DELAY	(3 * HZ)
 | 
					#define RETRY_DELAY	secs_to_jiffies(3)
 | 
				
			||||||
#define INITIAL_DELAY	(HZ / 2)
 | 
					#define INITIAL_DELAY	msecs_to_jiffies(500)
 | 
				
			||||||
#define SHUTDOWN_DELAY	(2 * HZ)
 | 
					#define SHUTDOWN_DELAY	secs_to_jiffies(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void fw_device_shutdown(struct work_struct *work)
 | 
					static void fw_device_shutdown(struct work_struct *work)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -458,7 +458,7 @@ static struct fw_packet phy_config_packet = {
 | 
				
			||||||
void fw_send_phy_config(struct fw_card *card,
 | 
					void fw_send_phy_config(struct fw_card *card,
 | 
				
			||||||
			int node_id, int generation, int gap_count)
 | 
								int node_id, int generation, int gap_count)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	long timeout = DIV_ROUND_UP(HZ, 10);
 | 
						long timeout = msecs_to_jiffies(100);
 | 
				
			||||||
	u32 data = 0;
 | 
						u32 data = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	phy_packet_set_packet_identifier(&data, PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG);
 | 
						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);
 | 
						cycles = clamp(cycles, 800u, 3u * 8000u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	card->split_timeout_cycles = cycles;
 | 
						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,
 | 
					static void handle_registers(struct fw_card *card, struct fw_request *request,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,8 @@ struct fw_packet;
 | 
				
			||||||
// This is the arbitrary value we use to indicate a mismatched gap count.
 | 
					// This is the arbitrary value we use to indicate a mismatched gap count.
 | 
				
			||||||
#define GAP_COUNT_MISMATCHED	0
 | 
					#define GAP_COUNT_MISMATCHED	0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define isoc_cycles_to_jiffies(cycles)	usecs_to_jiffies(cycles * USEC_PER_SEC / 8000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern __printf(2, 3)
 | 
					extern __printf(2, 3)
 | 
				
			||||||
void fw_err(const struct fw_card *card, const char *fmt, ...);
 | 
					void fw_err(const struct fw_card *card, const char *fmt, ...);
 | 
				
			||||||
extern __printf(2, 3)
 | 
					extern __printf(2, 3)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue