From: Robert Love <rml@novell.com>
To: greg@kroah.com
Cc: ttb@tentacle.dhs.org, linux-kernel@vger.kernel.org
Subject: [patch] add class_device to miscdevice
Date: Wed, 17 Nov 2004 11:48:59 -0500 [thread overview]
Message-ID: <1100710140.5009.6.camel@betsy.boston.ximian.com> (raw)
Greg, et al.
Currently misc_register() throws away the return from
class_simple_device_add(). This makes it impossible to get to the
class_device of the directories in /sys/class/misc and, for example,
thus impossible to add attributes to those directories.
Attached patch adds a class_device structure to the miscdevice structure
and assigns to it the value returned from class_simple_device_add() in
misc_register(), thus caching the value and allowing us to f.e. later
call class_device_create_file().
We need this for inotify, but I can see plenty of other misc. devices
wanting this and consider it missing but required functionality.
Thanks,
Robert Love
Add the class_device structure to miscdevice so that we can add sysfs
attributes to /sys/class/misc/foo
Signed-Off-By: Robert Love <rml@novell.com>
drivers/char/misc.c | 14 ++++++--------
include/linux/miscdevice.h | 5 +++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff -urN linux-2.6.10-rc2/drivers/char/misc.c linux/drivers/char/misc.c
--- linux-2.6.10-rc2/drivers/char/misc.c 2004-10-18 17:55:21.000000000 -0400
+++ linux/drivers/char/misc.c 2004-11-16 14:11:17.164542312 -0500
@@ -207,10 +207,9 @@
int misc_register(struct miscdevice * misc)
{
struct miscdevice *c;
- struct class_device *class;
dev_t dev;
int err;
-
+
down(&misc_sem);
list_for_each_entry(c, &misc_list, list) {
if (c->minor == misc->minor) {
@@ -224,8 +223,7 @@
while (--i >= 0)
if ( (misc_minors[i>>3] & (1 << (i&7))) == 0)
break;
- if (i<0)
- {
+ if (i<0) {
up(&misc_sem);
return -EBUSY;
}
@@ -240,10 +238,10 @@
}
dev = MKDEV(MISC_MAJOR, misc->minor);
- class = class_simple_device_add(misc_class, dev,
- misc->dev, misc->name);
- if (IS_ERR(class)) {
- err = PTR_ERR(class);
+ misc->class = class_simple_device_add(misc_class, dev,
+ misc->dev, misc->name);
+ if (IS_ERR(misc->class)) {
+ err = PTR_ERR(misc->class);
goto out;
}
diff -urN linux-2.6.10-rc2/include/linux/miscdevice.h linux/include/linux/miscdevice.h
--- linux-2.6.10-rc2/include/linux/miscdevice.h 2004-10-18 17:54:32.000000000 -0400
+++ linux/include/linux/miscdevice.h 2004-11-16 14:09:04.345733840 -0500
@@ -2,6 +2,7 @@
#define _LINUX_MISCDEVICE_H
#include <linux/module.h>
#include <linux/major.h>
+#include <linux/device.h>
#define PSMOUSE_MINOR 1
#define MS_BUSMOUSE_MINOR 2
@@ -32,13 +33,13 @@
struct device;
-struct miscdevice
-{
+struct miscdevice {
int minor;
const char *name;
struct file_operations *fops;
struct list_head list;
struct device *dev;
+ struct class_device *class;
char devfs_name[64];
};
next reply other threads:[~2004-11-17 16:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-17 16:48 Robert Love [this message]
2004-12-15 18:48 ` Greg KH
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=1100710140.5009.6.camel@betsy.boston.ximian.com \
--to=rml@novell.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ttb@tentacle.dhs.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 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®