From: Matthew Mastracci <matt@aclaro.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] sysfs patch for kqemu
Date: Sun, 13 Feb 2005 18:24:09 -0700 [thread overview]
Message-ID: <cuou8o$dbq$1@sea.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
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.
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1390 bytes --]
--- 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 <linux/version.h>
#include <linux/ioctl.h>
#include <linux/smp_lock.h>
+#include <linux/device.h>
#include <asm/atomic.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
@@ -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");
}
next reply other threads:[~2005-02-14 1:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-14 1:24 Matthew Mastracci [this message]
2005-02-14 3:16 ` [Qemu-devel] Re: sysfs patch for kqemu - take 2 Matthew Mastracci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='cuou8o$dbq$1@sea.gmane.org' \
--to=matt@aclaro.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.