mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* ldd module param practice
@ 2010-08-22 23:00 runcoderen
  2010-08-23  2:12 ` rdunlap
  2010-08-23  2:19 ` Américo Wang
  0 siblings, 2 replies; 3+ messages in thread
From: runcoderen @ 2010-08-22 23:00 UTC (permalink / raw)
  To: Linux Kernel List

hi all:

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

MODULE_LICENSE("Dual BSD/GPL");

static char *whom = "world";
static char howmany = 1;

module_param(howmany, int, S_IRUGO);
module_param(whom, charp, S_IRUGO);

static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

insmod hellop.ko howmany=10 whom="Mom"

this code I want to printk "hello Mom" 10 times.

but it doesn't work. so I modified static int howmany = 10, it doesn't
work either.
I don't know whether it's my wronging use?

-- 

/****************************************
http://runcoderen.wordpress.com/
****************************************/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ldd module param practice
  2010-08-22 23:00 ldd module param practice runcoderen
@ 2010-08-23  2:12 ` rdunlap
  2010-08-23  2:19 ` Américo Wang
  1 sibling, 0 replies; 3+ messages in thread
From: rdunlap @ 2010-08-23  2:12 UTC (permalink / raw)
  To: runcoderen; +Cc: Linux Kernel List

On Sun, August 22, 2010 4:00 pm, runcoderen wrote:
> hi all:
>
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/moduleparam.h>
>
>
> MODULE_LICENSE("Dual BSD/GPL");
>
>
> static char *whom = "world"; static char howmany = 1;


What happens if you make 'howmany' an int instead of
a char?


> module_param(howmany, int, S_IRUGO); module_param(whom, charp, S_IRUGO);
>
> static int hello_init(void) {
> printk(KERN_ALERT "Hello, world\n"); return 0; }
>
>
> static void hello_exit(void) {
> printk(KERN_ALERT "Goodbye, cruel world\n"); }
>
>
> module_init(hello_init); module_exit(hello_exit);
>
> insmod hellop.ko howmany=10 whom="Mom"
>
> this code I want to printk "hello Mom" 10 times.
>
> but it doesn't work. so I modified static int howmany = 10, it doesn't
> work either. I don't know whether it's my wronging use?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ldd module param practice
  2010-08-22 23:00 ldd module param practice runcoderen
  2010-08-23  2:12 ` rdunlap
@ 2010-08-23  2:19 ` Américo Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Américo Wang @ 2010-08-23  2:19 UTC (permalink / raw)
  To: runcoderen; +Cc: Linux Kernel List

On Mon, Aug 23, 2010 at 07:00:18AM +0800, runcoderen wrote:
>hi all:
>
>#include <linux/init.h>
>#include <linux/module.h>
>#include <linux/moduleparam.h>
>
>MODULE_LICENSE("Dual BSD/GPL");
>
>static char *whom = "world";
>static char howmany = 1;
>
>module_param(howmany, int, S_IRUGO);
>module_param(whom, charp, S_IRUGO);
>
>static int hello_init(void)
>{
>printk(KERN_ALERT "Hello, world\n");
>return 0;
>}
>
>static void hello_exit(void)
>{
>printk(KERN_ALERT "Goodbye, cruel world\n");
>}
>
>module_init(hello_init);
>module_exit(hello_exit);
>
>insmod hellop.ko howmany=10 whom="Mom"
>
>this code I want to printk "hello Mom" 10 times.


How can it work? You neither have a loop nor use 'whom'
in your hello_init()...

You need:

statick int hello_init(void)
{
   int i;
   for (i=0; i<howmany; i++)
      printk(KERN_WARNING "Hello, %s\n", whom);
   return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-23  2:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-22 23:00 ldd module param practice runcoderen
2010-08-23  2:12 ` rdunlap
2010-08-23  2:19 ` Américo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®