hotfix: move msg_count argument
Move msg_count handling to hello2 to comply with lab5 requirements
This commit is contained in:
		
							parent
							
								
									a64d55a819
								
							
						
					
					
						commit
						331a1ecb0b
					
				
							
								
								
									
										15
									
								
								hello1.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								hello1.c
									
									
									
									
									
								
							@ -44,7 +44,6 @@ struct TimingList {
 | 
			
		||||
	ktime_t t_after;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static unsigned int msg_count = 1;
 | 
			
		||||
static struct TimingList *tl_head;
 | 
			
		||||
 | 
			
		||||
static struct TimingList* write_first_node(void)
 | 
			
		||||
@ -97,19 +96,10 @@ void destroy_list(void)
 | 
			
		||||
 | 
			
		||||
static int __init hello_init(void)
 | 
			
		||||
{
 | 
			
		||||
	if (msg_count > 10) {
 | 
			
		||||
		pr_err("Error: msg_count too large (%d > 10)\n", msg_count);
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (msg_count == 0 || msg_count >= 5) {
 | 
			
		||||
		pr_warn("Warning: msg_count = %d (msg_count == 0 or 5 <= msg_count <= 10)\n", msg_count);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print_hello(void)
 | 
			
		||||
void print_hello(int msg_count)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	struct TimingList *current_tail = tl_head;
 | 
			
		||||
@ -128,9 +118,6 @@ static void __exit hello_exit(void)
 | 
			
		||||
	destroy_list();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module_param(msg_count, uint, 0444);
 | 
			
		||||
MODULE_PARM_DESC(msg_count, "Amount of hello world outputs on load");
 | 
			
		||||
 | 
			
		||||
EXPORT_SYMBOL(print_hello);
 | 
			
		||||
EXPORT_SYMBOL(destroy_list);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								hello2.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								hello2.c
									
									
									
									
									
								
							@ -40,9 +40,20 @@ MODULE_AUTHOR("Serhii Popovych <serhii.popovych@globallogic.com>");
 | 
			
		||||
MODULE_DESCRIPTION("Hello, world in Linux Kernel Training");
 | 
			
		||||
MODULE_LICENSE("Dual BSD/GPL");
 | 
			
		||||
 | 
			
		||||
static unsigned int msg_count = 1;
 | 
			
		||||
 | 
			
		||||
static int __init hello_init(void)
 | 
			
		||||
{
 | 
			
		||||
	print_hello();
 | 
			
		||||
	if (msg_count > 10) {
 | 
			
		||||
		pr_err("Error: msg_count too large (%d > 10)\n", msg_count);
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (msg_count == 0 || msg_count >= 5) {
 | 
			
		||||
		pr_warn("Warning: msg_count = %d (msg_count == 0 or 5 <= msg_count <= 10)\n", msg_count);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	print_hello(msg_count);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -51,5 +62,8 @@ static void __exit hello_exit(void)
 | 
			
		||||
	destroy_list();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module_param(msg_count, uint, 0444);
 | 
			
		||||
MODULE_PARM_DESC(msg_count, "Amount of hello world outputs on load");
 | 
			
		||||
 | 
			
		||||
module_init(hello_init);
 | 
			
		||||
module_exit(hello_exit);
 | 
			
		||||
 | 
			
		||||
@ -1,2 +1,2 @@
 | 
			
		||||
void print_hello(void);
 | 
			
		||||
void print_hello(int);
 | 
			
		||||
void destroy_list(void);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user