From: Thadeu Lima de Souza Cascardo Date: Mon, 21 Sep 2009 23:25:18 +0000 (-0300) Subject: Use a directory per project. X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fkernel%2Fsamples%2Fworkqueue%2F.git;a=commitdiff_plain;h=edd59c069a8601dc13303bc34d27d045ffbf5922 Use a directory per project. --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f2266eb --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +ifneq ($(KERNELRELEASE),) + obj-m := wq.o +else + KERNELDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) + +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +clean: + $(MAKE) -C $(KERNELDIR) M=$(PWD) clean +endif diff --git a/workqueue/Makefile b/workqueue/Makefile deleted file mode 100644 index f2266eb..0000000 --- a/workqueue/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -ifneq ($(KERNELRELEASE),) - obj-m := wq.o -else - KERNELDIR ?= /lib/modules/$(shell uname -r)/build - PWD := $(shell pwd) - -default: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules - -clean: - $(MAKE) -C $(KERNELDIR) M=$(PWD) clean -endif diff --git a/workqueue/wq.c b/workqueue/wq.c deleted file mode 100644 index 1d5fe38..0000000 --- a/workqueue/wq.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2009 Thadeu Lima de Souza Cascardo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - -#include -#include -#include - -MODULE_LICENSE("GPL"); - -static void do_mywork(struct work_struct *data) -{ - printk(KERN_INFO "I've been scheduled.\n"); -} - -DECLARE_DELAYED_WORK(mywork, do_mywork); -static struct workqueue_struct *mywq; - -static int mywq_init(void) -{ - mywq = create_workqueue("mywq"); - printk(KERN_INFO "Here I am, this is me.\n"); - queue_delayed_work(mywq, &mywork, 8 * HZ); - return 0; -} - -static void mywq_exit(void) -{ - flush_workqueue(mywq); - destroy_workqueue(mywq); -} - -module_init(mywq_init); -module_exit(mywq_exit); diff --git a/wq.c b/wq.c new file mode 100644 index 0000000..1d5fe38 --- /dev/null +++ b/wq.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Thadeu Lima de Souza Cascardo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static void do_mywork(struct work_struct *data) +{ + printk(KERN_INFO "I've been scheduled.\n"); +} + +DECLARE_DELAYED_WORK(mywork, do_mywork); +static struct workqueue_struct *mywq; + +static int mywq_init(void) +{ + mywq = create_workqueue("mywq"); + printk(KERN_INFO "Here I am, this is me.\n"); + queue_delayed_work(mywq, &mywork, 8 * HZ); + return 0; +} + +static void mywq_exit(void) +{ + flush_workqueue(mywq); + destroy_workqueue(mywq); +} + +module_init(mywq_init); +module_exit(mywq_exit);