From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D0VWE-0001Sb-KJ for qemu-devel@nongnu.org; Sun, 13 Feb 2005 20:59:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D0VWB-0001RU-MT for qemu-devel@nongnu.org; Sun, 13 Feb 2005 20:59:22 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D0VUS-0000TT-4G for qemu-devel@nongnu.org; Sun, 13 Feb 2005 20:57:32 -0500 Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1D0Uur-0005qO-Hj for qemu-devel@nongnu.org; Sun, 13 Feb 2005 20:20:45 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1D0UsZ-0008OT-Mk for qemu-devel@nongnu.org; Mon, 14 Feb 2005 02:18:23 +0100 Received: from s0106000f66a57c25.cg.shawcable.net ([68.145.130.4]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 14 Feb 2005 02:18:23 +0100 Received: from matt by s0106000f66a57c25.cg.shawcable.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 14 Feb 2005 02:18:23 +0100 From: Matthew Mastracci Date: Sun, 13 Feb 2005 18:24:09 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000403020009000701040607" Sender: news Subject: [Qemu-devel] sysfs patch for kqemu Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------000403020009000701040607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here's a patch for supporting sysfs and udev. There's no conditional logic - it needs the sysfs stuff to be present in the kernel headers. It dynamically allocates a major number and stuffs it into a global variable and uses that to register a device with sysfs. udev will then pick up the new device and automatically create a new "kqemu" device node. Matt. --------------000403020009000701040607 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" --- kqemu/kmod.c 2005-02-10 15:09:09.000000000 -0700 +++ qemu/kqemu/kmod.c 2005-02-13 18:19:14.833684304 -0700 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,9 @@ int page_alloc_count; #endif +struct class_simple *kqemu_class; +int kqemu_major; + /* lock the page at virtual address 'user_addr' and return its page index. Return -1 if error */ unsigned long CDECL kqemu_lock_user_page(unsigned long user_addr) @@ -297,9 +301,12 @@ ret = register_chrdev(KQEMU_MAJOR, "kqemu", &kqemu_fops); if (ret < 0) { - printk("kqemu: could not get major %d\n", KQEMU_MAJOR); + printk("kqemu: could not get major\n"); return ret; } + kqemu_major = ret; + kqemu_class = class_simple_create(THIS_MODULE, "kqemu"); + class_simple_device_add(kqemu_class, MKDEV(kqemu_major,0), NULL, "kqemu"); printk("KQEMU installed, max_instances=%d max_locked_mem=%dkB.\n", KQEMU_MAX_INSTANCES, max_locked_pages * 4); @@ -308,5 +315,7 @@ void cleanup_module(void) { - unregister_chrdev(KQEMU_MAJOR, "kqemu"); + class_simple_device_remove(MKDEV(kqemu_major,0)); + class_simple_destroy(kqemu_class); + unregister_chrdev(kqemu_major, "kqemu"); } --------------000403020009000701040607--