Re: [PATCH] USB and Driver Core patches for 2.6.10

From: Greg KH (greg_at_kroah.com)
Date: 01/08/05

  • Next message: Greg KH: "Re: [PATCH] USB and Driver Core patches for 2.6.10"
    Date:	Fri, 7 Jan 2005 21:47:38 -0800
    To: linux-usb-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
    
    

    ChangeSet 1.1938.444.1, 2004/12/15 10:48:19-08:00, rml@novell.com

    [PATCH] add class_device to miscdevice

    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.

    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>
    Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>

     drivers/char/misc.c | 14 ++++++--------
     include/linux/miscdevice.h | 5 +++--
     2 files changed, 9 insertions(+), 10 deletions(-)

    diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
    --- a/drivers/char/misc.c 2005-01-07 15:52:07 -08:00
    +++ b/drivers/char/misc.c 2005-01-07 15:52:07 -08:00
    @@ -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 -Nru a/include/linux/miscdevice.h b/include/linux/miscdevice.h
    --- a/include/linux/miscdevice.h 2005-01-07 15:52:07 -08:00
    +++ b/include/linux/miscdevice.h 2005-01-07 15:52:07 -08:00
    @@ -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];
     };
     

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Greg KH: "Re: [PATCH] USB and Driver Core patches for 2.6.10"

    Relevant Pages

    • [patch] inotify: make our sysfs files show up
      ... miscdevice") this patch uses the newly attainable class_device value to ... In order to attach attributes to the class_device, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [patch] add class_device to miscdevice
      ... Attached patch adds a class_device structure to the miscdevice structure ... but I can see plenty of other misc. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [2.6 patch] SCSI 53c700.c: make NCR_700_intr static
      ... This patch was already sent on: ... struct NCR_700_Host_Parameters *, struct device *, ... STATIC int NCR_700_abort; ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH 2/3] MODULE_ALIAS() in char devices
      ... extern int misc_deregister(struct miscdevice * misc); ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [RFC] add class/video to fb drivers - Take 2
      ... Only those that have a struct device associated with them ... > this probnlem still present in this patch. ... Ideally in 2.7 I'd like to convert to have all fb drivers create the ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)

    Loading