module_param

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
   I am trying to get the module parameters from command line.
I want to get the integer array.I am doing ot with the following code


#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("COMMAND LINE PARAMETERS");

static int __init module_init2(void);
static void __exit module_exit2(void);

static int __init module_init2()
{
   static int num;
   printk("Hello World!\n");
   module_param(num,int,0);
   int array[2];
   int i;
   module_param_array(array,int,num,0);
   for(i=0;i<2;i++)
   printk("Values Are : %d %d\n",array[0],array[1]);
   return 0;
}

static void __exit module_exit2()
{
   printk("Cruel World!Bye\n");
}

module_init(module_init2);
module_exit(module_exit2);



but when i am trying to compile it is giving the error as


/home/raja/Backup-Progs/ModuleProg/Mod2/mod2.c:30: error: initializer element is not constant /home/raja/Backup-Progs/ModuleProg/Mod2/mod2.c:30: error: (near initialization for `__param_arr_array.elem')


would you please help me.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux