Driver Core update for 2.6.1
Subsystems (5)
PATCH 1/1 Driver Core update for 2.6.1
Hi,
Here are a few kobject and driver core changes for 2.6.1. The majority of these are the "class_simple" patches that have been in the -mm tree for quite a while now. They add sysfs class support for a wide range of different class devices, which is required for tools like udev to be able to do device naming in userspace. Andrew suggested that I send them to you now. All of the different driver subsystem maintainers (when there is one) have ACKed these changes.
Please pull from:
bk://kernel.bkbits.net/gregkh/linux/driver-2.6
thanks,
greg k-h
p.s. I'll send these as patches in response to this email to lkml for those who want to see them.
drivers/base/Makefile | 2 drivers/base/class.c | 14 +++ drivers/base/class_simple.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ drivers/base/core.c | 9 + drivers/char/lp.c | 6 + drivers/char/mem.c | 7 + drivers/char/misc.c | 17 +++ drivers/char/tty_io.c | 91 ++----------------- drivers/input/evdev.c | 4 drivers/input/input.c | 8 - drivers/input/joydev.c | 4 drivers/input/mousedev.c | 8 + drivers/input/tsdev.c | 4 include/linux/device.h | 10 ++ include/linux/input.h | 3 include/linux/kobject.h | 1 include/linux/miscdevice.h | 3 include/sound/core.h | 1 lib/kobject.c | 51 ++++------- sound/core/sound.c | 34 ++++--- sound/oss/soundcard.c | 13 ++ sound/pci/intel8x0.c | 1 sound/sound_core.c | 10 ++ 23 files changed, 368 insertions(+), 134 deletions(-)
-----
Dmitry Torokhov:
o kobject: make kobject hotplug function public
Greg Kroah-Hartman:
o Kobject: prevent oops in kset_find_obj() if kobject_name() is NULL
o ALSA: add sysfs class support for ALSA sound devices
o OSS: add sysfs class support for OSS sound devices
o MISC: add sysfs class support for misc devices
o MEM: add sysfs class support for mem devices
o LP: add sysfs class support for lp devices
o Input: add sysfs class support for input devices
o TTY: clean up sysfs class support for tty devices
o Driver Core: add class_simple support
Hollis Blanchard:
o Driver Core: add device_find() function
PATCH 1/1 Driver Core update and fixes for 2.6.1
ChangeSet 1.1495, 2004/01/19 16:21:50-08:00, [email protected]
[PATCH] kobject: make kobject hotplug function public
make kobject hotplug mechanism public so that others may call it.
include/linux/kobject.h | 1 lib/kobject.c | 49 ++++++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 28 deletions(-)
include/linux/kobject.h +1 -0
@@ -56,6 +56,7 @@extern struct kobject *kobject_get (struct kobject *);extern void kobject_put (struct kobject *); +extern void kobject_hotplug (const char *action,struct kobject *);struct kobj_type {void (*release)(struct kobject *);
lib/kobject.c +21 -28
81 lines not on this page · raw message
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1496, 2004/01/19 16:31:36-08:00, [email protected]
[PATCH] Driver Core: add device_find() function
Quoted 3 lines · Greg KH
How about just adding a
device_find()function to the driver core, where you pass in a name and a type, so that others can use it?
Something like this?
drivers/base/core.c | 9 +++++++++ include/linux/device.h | 1 + 2 files changed, 10 insertions(+)
drivers/base/core.c +9 -0
@@ -400,6 +400,14 @@return error; } +struct device *device_find (const char *name,struct bus_type *bus) +{ +struct kobject *k =kset_find_obj (&bus->devices, name); +if (k) +return to_dev (k); +return NULL ; +} +int __init devices_init (void ) {return subsystem_register (&devices_subsys);
@@ -416,6 +424,7 @@EXPORT_SYMBOL (device_unregister_wait);EXPORT_SYMBOL (get_device);EXPORT_SYMBOL (put_device); +EXPORT_SYMBOL (device_find);EXPORT_SYMBOL (device_create_file);EXPORT_SYMBOL (device_remove_file);
include/linux/device.h +1 -0
@@ -354,6 +354,7 @@*/ extern struct device *get_device (struct device * dev);extern void put_device (struct device * dev); +extern struct device *device_find (const char *name,struct bus_type *bus);/* drivers/base/platform.c */
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1497, 2004/01/19 16:33:14-08:00, [email protected]
[PATCH] Driver Core: add class_simple support
This patch adds a struct class_simple which can be used to create "simple" class support for subsystems.
It also adds a class_release() callback for struct class, as it is needed to properly handle the reference counting logic.
drivers/base/Makefile | 2 drivers/base/class.c | 14 +++ drivers/base/class_simple.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 9 + 4 files changed, 225 insertions(+), 1 deletion(-)
drivers/base/Makefile +1 -1
@@ -1,7 +1,7 @@ # Makefile for the Linux device tree obj-y := core.o sys.o interface.o bus.o \ - driver.o class.o platform.o \ + driver.o class.o class_simple.o platform.o \ cpu.o firmware.o init.o map.o obj-y += power/ obj-$(CONFIG_FW_LOADER) += firmware_class.o
drivers/base/class.c +14 -0
@@ -46,6 +46,19 @@return ret; } +static void class_release (struct kobject * kobj) +{ +struct class *class =to_class (kobj); + +pr_debug ("class '%s': release.\n" , class->name); + +if (class->class_release) + class->class_release (class); +else +pr_debug ("class '%s' does not have a release() function, " +"be careful\n" , class->name); +} +static struct sysfs_ops class_sysfs_ops = { .show = class_attr_show, .store = class_attr_store,
@@ -53,6 +66,7 @@static struct kobj_type ktype_class = { .sysfs_ops = &class_sysfs_ops, + .release = class_release, };/* Hotplug events for classes go to the class_obj subsys */
drivers/base/class_simple.c new file +201 -0
201 lines not on this page · raw message
include/linux/device.h +9 -0
@@ -46,6 +46,7 @@struct device_driver ;struct class ;struct class_device ; +struct class_simple ;struct bus_type {char * name;
@@ -155,6 +156,7 @@ int num_envp, char *buffer, int buffer_size);void (*release)(struct class_device *dev); +void (*class_release)(struct class *class); };extern int class_register (struct class *);
@@ -245,6 +247,13 @@extern int class_interface_register (struct class_interface *);extern void class_interface_unregister (struct class_interface *); + +/* interface for class simple stuff */ +extern struct class_simple *class_simple_create (struct module *owner,char *name); +extern void class_simple_destroy (struct class_simple *cs); +extern struct class_device *class_simple_device_add (struct class_simple *cs,dev_t dev,struct device *device,const char *fmt, ...) + __attribute__((format (printf,4 ,5 ))); +extern void class_simple_device_remove (dev_t dev);struct device {
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1498, 2004/01/19 16:36:04-08:00, [email protected]
[PATCH] TTY: clean up sysfs class support for tty devices
This patch ports the existing tty class support to the class_simple interface, saving a lot of code in the process.
drivers/char/tty_io.c | 91 ++++++-------------------------------------------- 1 files changed, 11 insertions(+), 80 deletions(-)
drivers/char/tty_io.c +11 -80
@@ -2069,79 +2069,7 @@ tty->driver->write (tty,0 , &ch,1 ); } -struct tty_dev { -struct list_head node; -dev_t dev; -struct class_device class_dev; -}; -#define to_tty_dev (d) container_of(d, struct tty_dev, class_dev) - -static void release_tty_dev (struct class_device *class_dev) -{ -struct tty_dev *tty_dev =to_tty_dev (class_dev); -kfree (tty_dev); -} - -static struct class tty_class = { - .name ="tty" , - .release = &release_tty_dev, -}; - -static LIST_HEAD (tty_dev_list); -static spinlock_t tty_dev_list_lock =SPIN_LOCK_UNLOCKED ; - -static ssize_t show_dev (struct class_device *class_dev,char *buf) -{ -struct tty_dev *tty_dev =to_tty_dev (class_dev); -return print_dev_t (buf, tty_dev->dev); -} -static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL); - -static void tty_add_class_device (char *name,dev_t dev,struct device *device) -{ -struct tty_dev *tty_dev =NULL ; -int retval; - - tty_dev =kmalloc (sizeof (*tty_dev),GFP_KERNEL ); -if (!tty_dev) -return ; -memset (tty_dev,0x00 ,sizeof (*tty_dev)); - - tty_dev->class_dev.dev = device; - tty_dev->class_dev.class = &tty_class; -snprintf (tty_dev->class_dev.class_id,BUS_ID_SIZE ,"%s" , name); - retval =class_device_register (&tty_dev->class_dev); -if (retval) - goto error; -class_device_create_file (&tty_dev->class_dev, &class_device_attr_dev); - tty_dev->dev = dev; -spin_lock (&tty_dev_list_lock); -list_add (&tty_dev->node, &tty_dev_list); -spin_unlock (&tty_dev_list_lock); -return ; -error: -kfree (tty_dev); -} - -static void tty_remove_class_device (dev_t dev) -{ -struct tty_dev *tty_dev =NULL ; -struct list_head *tmp; -int found =0 ; - -spin_lock (&tty_dev_list_lock); - list_for_each (tmp, &tty_dev_list) { - tty_dev = list_entry(tmp, struct tty_dev, node); -if (tty_dev->dev == dev) { -list_del (&tty_dev->node); - found =1 ; -break ; - } - } -spin_unlock (&tty_dev_list_lock); -if (found) -class_device_unregister (&tty_dev->class_dev); -} +static struct class_simple *tty_class;/** * tty_register_device - register a tty device
@@ -2174,7 +2102,7 @@if (driver->type !=TTY_DRIVER_TYPE_PTY ) {char name[64 ];tty_line_name (driver, index, name); -tty_add_class_device (name, dev, device); +class_simple_device_add (tty_class, dev, device, name); } }
@@ -2189,7 +2117,7 @@void tty_unregister_device (struct tty_driver *driver,unsigned index) {devfs_remove ("%s%d" , driver->devfs_name, index + driver->name_base); -tty_remove_class_device (MKDEV (driver->major, driver->minor_start) + index); +class_simple_device_remove (MKDEV (driver->major, driver->minor_start) + index); }EXPORT_SYMBOL (tty_register_device);
@@ -2406,7 +2334,10 @@static int __init tty_class_init (void ) { -return class_register (&tty_class); + tty_class =class_simple_create (THIS_MODULE ,"tty" ); +if (IS_ERR (tty_class)) +return PTR_ERR (tty_class); +return 0 ; }postcore_initcall (tty_class_init);
@@ -2431,7 +2362,7 @@ register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)panic ("Couldn't register /dev/tty driver\n" );devfs_mk_cdev (MKDEV (TTYAUX_MAJOR ,0 ),S_IFCHR |S_IRUGO |S_IWUGO ,"tty" ); -tty_add_class_device ("tty" ,MKDEV (TTYAUX_MAJOR ,0 ),NULL ); +class_simple_device_add (tty_class,MKDEV (TTYAUX_MAJOR ,0 ),NULL ,"tty" );strcpy (console_cdev.kobj.name,"dev.console" );cdev_init (&console_cdev, &console_fops);
@@ -2439,7 +2370,7 @@ register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)panic ("Couldn't register /dev/console driver\n" );devfs_mk_cdev (MKDEV (TTYAUX_MAJOR ,1 ),S_IFCHR |S_IRUSR |S_IWUSR ,"console" ); -tty_add_class_device ("console" ,MKDEV (TTYAUX_MAJOR ,1 ),NULL ); +class_simple_device_add (tty_class,MKDEV (TTYAUX_MAJOR ,1 ),NULL ,"console" ); tty_kobj.kset = tty_cdev.kobj.kset;kobject_register (&tty_kobj);
@@ -2451,7 +2382,7 @@ register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)panic ("Couldn't register /dev/ptmx driver\n" );devfs_mk_cdev (MKDEV (TTYAUX_MAJOR ,2 ),S_IFCHR |S_IRUGO |S_IWUGO ,"ptmx" ); -tty_add_class_device ("ptmx" ,MKDEV (TTYAUX_MAJOR ,2 ),NULL ); +class_simple_device_add (tty_class,MKDEV (TTYAUX_MAJOR ,2 ),NULL ,"ptmx" );#endif #ifdef CONFIG_VT
@@ -2461,7 +2392,7 @@ register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)panic ("Couldn't register /dev/tty0 driver\n" );devfs_mk_cdev (MKDEV (TTY_MAJOR ,0 ),S_IFCHR |S_IRUSR |S_IWUSR ,"vc/0" ); -tty_add_class_device ("tty0" ,MKDEV (TTY_MAJOR ,0 ),NULL ); +class_simple_device_add (tty_class,MKDEV (TTY_MAJOR ,0 ),NULL ,"tty0" );vty_init ();#endif
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1499, 2004/01/19 16:38:36-08:00, [email protected]
[PATCH] Input: add sysfs class support for input devices
This patch adds sysfs support for all input devices. It also provides the "device" and "driver" symlink for all Input devices that specify it.
drivers/input/evdev.c | 4 ++++ drivers/input/input.c | 8 +++----- drivers/input/joydev.c | 4 ++++ drivers/input/mousedev.c | 8 +++++++- drivers/input/tsdev.c | 4 ++++ include/linux/input.h | 3 ++- 6 files changed, 24 insertions(+), 7 deletions(-)
drivers/input/evdev.c +4 -0
@@ -92,6 +92,7 @@static void evdev_free (struct evdev *evdev) {devfs_remove ("input/event%d" , evdev->minor); +class_simple_device_remove (MKDEV (INPUT_MAJOR ,EVDEV_MINOR_BASE + evdev->minor)); evdev_table[evdev->minor] =NULL ;kfree (evdev); }
@@ -426,6 +427,9 @@devfs_mk_cdev (MKDEV (INPUT_MAJOR ,EVDEV_MINOR_BASE + minor),S_IFCHR |S_IRUGO |S_IWUSR ,"input/event%d" , minor); +class_simple_device_add (input_class, +MKDEV (INPUT_MAJOR ,EVDEV_MINOR_BASE + minor), + dev->dev,"event%d" , minor);return &evdev->handle; }
drivers/input/input.c +3 -5
@@ -720,15 +720,13 @@static inline int input_proc_init (void ) {return 0 ; }#endif -struct class input_class = { - .name ="input" , -}; +struct class_simple *input_class;static int __init input_init (void ) {int retval = -ENOMEM ; -class_register (&input_class); + input_class =class_simple_create (THIS_MODULE ,"input" );input_proc_init (); retval =register_chrdev (INPUT_MAJOR ,"input" , &input_fops);if (retval) {
@@ -757,7 +755,7 @@devfs_remove ("input" );unregister_chrdev (INPUT_MAJOR ,"input" ); -class_unregister (&input_class); +class_simple_destroy (input_class); }subsys_initcall (input_init);
drivers/input/joydev.c +4 -0
@@ -145,6 +145,7 @@ {devfs_remove ("js%d" , joydev->minor); joydev_table[joydev->minor] =NULL ; +class_simple_device_remove (MKDEV (INPUT_MAJOR ,JOYDEV_MINOR_BASE + joydev->minor));kfree (joydev); }
@@ -444,6 +445,9 @@devfs_mk_cdev (MKDEV (INPUT_MAJOR ,JOYDEV_MINOR_BASE + minor),S_IFCHR |S_IRUGO |S_IWUSR ,"js%d" , minor); +class_simple_device_add (input_class, +MKDEV (INPUT_MAJOR ,JOYDEV_MINOR_BASE + minor), + dev->dev,"js%d" , minor);return &joydev->handle; }
drivers/input/mousedev.c +7 -1
@@ -225,6 +225,7 @@static void mousedev_free (struct mousedev *mousedev) {devfs_remove ("input/mouse%d" , mousedev->minor); +class_simple_device_remove (MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE + mousedev->minor)); mousedev_table[mousedev->minor] =NULL ;kfree (mousedev); }
@@ -486,6 +487,9 @@devfs_mk_cdev (MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE + minor),S_IFCHR |S_IRUGO |S_IWUSR ,"input/mouse%d" , minor); +class_simple_device_add (input_class, +MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE + minor), + dev->dev,"mouse%d" , minor);return &mousedev->handle; }
@@ -564,7 +568,8 @@devfs_mk_cdev (MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE +MOUSEDEV_MIX ),S_IFCHR |S_IRUGO |S_IWUSR ,"input/mice" ); - +class_simple_device_add (input_class,MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE +MOUSEDEV_MIX ), +NULL ,"mice" );#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX if (!(mousedev_mix.misc = !misc_register (&psaux_mouse)))
@@ -583,6 +588,7 @@misc_deregister (&psaux_mouse);#endif devfs_remove ("input/mice" ); +class_simple_device_remove (MKDEV (INPUT_MAJOR ,MOUSEDEV_MINOR_BASE +MOUSEDEV_MIX ));input_unregister_handler (&mousedev_handler); }
drivers/input/tsdev.c +4 -0
@@ -129,6 +129,7 @@static void tsdev_free (struct tsdev *tsdev) {devfs_remove ("input/ts%d" , tsdev->minor); +class_simple_device_remove (MKDEV (INPUT_MAJOR ,TSDEV_MINOR_BASE + tsdev->minor)); tsdev_table[tsdev->minor] =NULL ;kfree (tsdev); }
@@ -343,6 +344,9 @@devfs_mk_cdev (MKDEV (INPUT_MAJOR ,TSDEV_MINOR_BASE + minor),S_IFCHR |S_IRUGO |S_IWUSR ,"input/ts%d" , minor); +class_simple_device_add (input_class, +MKDEV (INPUT_MAJOR ,TSDEV_MINOR_BASE + minor), + dev->dev,"ts%d" , minor);return &tsdev->handle; }
include/linux/input.h +2 -1
@@ -809,6 +809,7 @@int (*erase_effect)(struct input_dev *dev,int effect_id);struct input_handle *grab; +struct device *dev;struct list_head h_list;struct list_head node;
@@ -921,7 +922,7 @@#define input_regs (a,b) do { (a)->regs = (b); } while (0)#define input_sync (a) do { input_event(a, EV_SYN, SYN_REPORT, 0); (a)->regs = NULL; } while (0) -extern struct class input_class; +extern struct class_simple *input_class;#endif #endif
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1500, 2004/01/19 16:39:52-08:00, [email protected]
[PATCH] LP: add sysfs class support for lp devices
Add sysfs class support for lp devices.
Based on a patch from Hanna Linder <[email protected]>
drivers/char/lp.c | 6 ++++++ 1 files changed, 6 insertions(+)
drivers/char/lp.c +6 -0
@@ -145,6 +145,7 @@struct lp_struct lp_table[LP_NO ];static unsigned int lp_count =0 ; +static struct class_simple *lp_class;#ifdef CONFIG_LP_CONSOLE static struct parport *console_registered;// initially NULL
@@ -795,6 +796,8 @@if (reset)lp_reset (nr); +class_simple_device_add (lp_class,MKDEV (LP_MAJOR , nr),NULL , +"lp%d" , nr);devfs_mk_cdev (MKDEV (LP_MAJOR , nr),S_IFCHR |S_IRUGO |S_IWUGO ,"printers/%d" , nr);
@@ -897,6 +900,7 @@ }devfs_mk_dir ("printers" ); + lp_class =class_simple_create (THIS_MODULE ,"printer" );if (parport_register_driver (&lp_driver)) {printk (KERN_ERR "lp: unable to register with parport\n" );
@@ -958,8 +962,10 @@continue ;parport_unregister_device (lp_table[offset].dev);devfs_remove ("printers/%d" , offset); +class_simple_device_remove (MKDEV (LP_MAJOR , offset)); }devfs_remove ("printers" ); +class_simple_destroy (lp_class); }__setup ("lp=" , lp_setup);
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1501, 2004/01/19 16:40:57-08:00, [email protected]
[PATCH] MEM: add sysfs class support for mem devices
This adds class/mem/ for all memory devices (random, raw, null, etc.)
drivers/char/mem.c | 7 +++++++ 1 files changed, 7 insertions(+)
drivers/char/mem.c +7 -0
@@ -24,6 +24,7 @@#include <linux/smp_lock.h> #include <linux/devfs_fs_kernel.h> #include <linux/ptrace.h> +#include <linux/device.h> #include <asm/uaccess.h> #include <asm/io.h>
@@ -676,6 +677,8 @@ {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops}, }; +static struct class_simple *mem_class; +static int __init chr_dev_init (void ) {int i;
@@ -683,7 +686,11 @@if (register_chrdev (MEM_MAJOR ,"mem" ,&memory_fops))printk ("unable to get major %d for memory devs\n" ,MEM_MAJOR ); + mem_class =class_simple_create (THIS_MODULE ,"mem" );for (i =0 ; i <ARRAY_SIZE (devlist); i++) { +class_simple_device_add (mem_class, +MKDEV (MEM_MAJOR , devlist[i].minor), +NULL , devlist[i].name);devfs_mk_cdev (MKDEV (MEM_MAJOR , devlist[i].minor),S_IFCHR | devlist[i].mode, devlist[i].name); }
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1502, 2004/01/19 16:41:53-08:00, [email protected]
[PATCH] MISC: add sysfs class support for misc devices
This adds class/misc/ for all misc devices (ones that use the misc_register() function).
drivers/char/misc.c | 17 +++++++++++++++-- include/linux/miscdevice.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/char/misc.c +15 -2
@@ -47,7 +47,7 @@#include <linux/devfs_fs_kernel.h> #include <linux/stat.h> #include <linux/init.h> - +#include <linux/device.h> #include <linux/tty.h> #include <linux/kmod.h>
@@ -180,6 +180,13 @@return err; } +/* +* TODO for 2.7: +* - add a struct class_device to struct miscdevice and make all usages of +* them dynamic. +*/ +static struct class_simple *misc_class; +static struct file_operations misc_fops = { .owner =THIS_MODULE , .open = misc_open,
@@ -234,6 +241,8 @@ "misc/%s", misc->name); } +class_simple_device_add (misc_class,MKDEV (MISC_MAJOR , misc->minor), + misc->dev, misc->name);devfs_mk_cdev (MKDEV (MISC_MAJOR , misc->minor),S_IFCHR |S_IRUSR |S_IWUSR |S_IRGRP , misc->devfs_name);
@@ -265,6 +274,7 @@down (&misc_sem);list_del (&misc->list); +class_simple_device_remove (MKDEV (MISC_MAJOR , misc->minor));devfs_remove (misc->devfs_name);if (i <DYNAMIC_MINORS && i>0 ) { misc_minors[i>>3 ] &= ~(1 << (misc->minor &7 ));
@@ -285,6 +295,9 @@if (ent) ent->proc_fops = &misc_proc_fops;#endif + misc_class =class_simple_create (THIS_MODULE ,"misc" ); +if (IS_ERR (misc_class)) +return PTR_ERR (misc_class);#ifdef CONFIG_MVME16xrtc_MK48T08_init ();#endif
@@ -319,4 +332,4 @@ }return 0 ; } -module_init (misc_init); +subsys_initcall (misc_init);
include/linux/miscdevice.h +3 -0
@@ -36,12 +36,15 @@#define TUN_MINOR 200 +struct device ; +struct miscdevice {int minor;const char *name;struct file_operations *fops;struct list_head list; +struct device *dev;char devfs_name[64 ]; };
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1503, 2004/01/19 16:45:11-08:00, [email protected]
[PATCH] OSS: add sysfs class support for OSS sound devices
This patch adds support for all OSS sound devices.
This patch is based on a work originally written by Leann Ogasawara <[email protected]>
sound/oss/soundcard.c | 13 ++++++++++++- sound/sound_core.c | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
sound/oss/soundcard.c +12 -1
@@ -73,6 +73,7 @@unsigned long seq_time =0 ;/* Time for /dev/sequencer */ +extern struct class_simple *sound_class;/* * Table for configurable mixer volume handling
@@ -569,6 +570,9 @@devfs_mk_cdev (MKDEV (SOUND_MAJOR , dev_list[i].minor),S_IFCHR | dev_list[i].mode,"sound/%s" , dev_list[i].name); +class_simple_device_add (sound_class, +MKDEV (SOUND_MAJOR , dev_list[i].minor), +NULL ,"%s" , dev_list[i].name);if (!dev_list[i].num)continue ;
@@ -578,6 +582,10 @@ dev_list[i].minor + (j*0x10)),S_IFCHR | dev_list[i].mode, "sound/%s%d", dev_list[i].name, j); +class_simple_device_add (sound_class, +MKDEV (SOUND_MAJOR , dev_list[i].minor + (j*0x10 )), +NULL , +"%s%d" , dev_list[i].name, j); } }
@@ -593,10 +601,13 @@for (i =0 ; i <sizeof (dev_list) /sizeof *dev_list; i++) {devfs_remove ("sound/%s" , dev_list[i].name); +class_simple_device_remove (MKDEV (SOUND_MAJOR , dev_list[i].minor));if (!dev_list[i].num)continue ; -for (j =1 ; j < *dev_list[i].num; j++) +for (j =1 ; j < *dev_list[i].num; j++) {devfs_remove ("sound/%s%d" , dev_list[i].name, j); +class_simple_device_remove (MKDEV (SOUND_MAJOR , dev_list[i].minor + (j*0x10 ))); + } }unregister_sound_special (1 );
sound/sound_core.c +10 -0
@@ -65,6 +65,9 @@extern int msnd_pinnacle_init (void );#endif +struct class_simple *sound_class; +EXPORT_SYMBOL (sound_class); +/* * Low level list operator. Scan the ordered list, find a hole and * join into it. Called with the lock asserted
@@ -171,6 +174,8 @@devfs_mk_cdev (MKDEV (SOUND_MAJOR , s->unit_minor),S_IFCHR | mode, s->name); +class_simple_device_add (sound_class,MKDEV (SOUND_MAJOR , s->unit_minor), +NULL , s->name+6 );return r; fail:
@@ -193,6 +198,7 @@spin_unlock (&sound_loader_lock);if (p) {devfs_remove (p->name); +class_simple_device_remove (MKDEV (SOUND_MAJOR , p->unit_minor));kfree (p); } }
@@ -556,6 +562,7 @@empty */ unregister_chrdev (SOUND_MAJOR ,"sound" );devfs_remove ("sound" ); +class_simple_destroy (sound_class); }static int __init init_soundcore (void )
@@ -565,6 +572,9 @@return -EBUSY ; }devfs_mk_dir ("sound" ); + sound_class =class_simple_create (THIS_MODULE ,"sound" ); +if (IS_ERR (sound_class)) +return PTR_ERR (sound_class);return 0 ; }
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1504, 2004/01/19 16:45:49-08:00, [email protected]
[PATCH] ALSA: add sysfs class support for ALSA sound devices
This patch adds support for all ALSA sound devices. The previous OSS sound patch is required for this one to work properly.
This patch is based on a work originally written by Leann Ogasawara <[email protected]>
include/sound/core.h | 1 + sound/core/sound.c | 34 ++++++++++++++++++++-------------- sound/pci/intel8x0.c | 1 + 3 files changed, 22 insertions(+), 14 deletions(-)
include/sound/core.h +1 -0
@@ -160,6 +160,7 @@int shutdown;/* this card is going down */ wait_queue_head_t shutdown_sleep;struct work_struct free_workq;/* for free in workqueue */ +struct device *dev;#ifdef CONFIG_PM int (*set_power_state) (snd_card_t *card,unsigned int state);
sound/core/sound.c +20 -14
@@ -38,9 +38,7 @@static int major =CONFIG_SND_MAJOR ;int snd_major;static int cards_limit =SNDRV_CARDS ; -#ifdef CONFIG_DEVFS_FS static int device_mode =S_IFCHR |S_IRUGO |S_IWUGO ; -#endif MODULE_AUTHOR ("Jaroslav Kysela <[email protected]>" );MODULE_DESCRIPTION ("Advanced Linux Sound Architecture driver for soundcards." );
@@ -66,6 +64,7 @@static DECLARE_MUTEX (sound_mutex); +extern struct class_simple *sound_class;#ifdef CONFIG_KMOD /**
@@ -203,6 +202,7 @@ {int minor =snd_kernel_minor (type, card, dev);snd_minor_t *preg; +struct device *device =NULL ;if (minor <0 )return minor;
@@ -221,10 +221,14 @@return -EBUSY ; }list_add_tail (&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD (minor)]); -#ifdef CONFIG_DEVFS_FS -if (strncmp (name,"controlC" ,8 ))/* created in sound.c */ + +if (strncmp (name,"controlC" ,8 )) {/* created in sound.c */ devfs_mk_cdev (MKDEV (major, minor),S_IFCHR | device_mode,"snd/%s" , name); -#endif +if (card) + device = card->dev; +class_simple_device_add (sound_class,MKDEV (major, minor), device, name); + } +up (&sound_mutex);return 0 ; }
@@ -252,10 +256,12 @@up (&sound_mutex);return -EINVAL ; } -#ifdef CONFIG_DEVFS_FS -if (strncmp (mptr->name,"controlC" ,8 ))/* created in sound.c */ + +if (strncmp (mptr->name,"controlC" ,8 )) {/* created in sound.c */ devfs_remove ("snd/%s" , mptr->name); -#endif +class_simple_device_remove (MKDEV (major, minor)); + } +list_del (&mptr->list);up (&sound_mutex);kfree (mptr);
@@ -322,9 +328,7 @@static int __init alsa_sound_init (void ) { -#ifdef CONFIG_DEVFS_FS short controlnum; -#endif #ifdef CONFIG_SND_OSSEMUL int err;#endif
@@ -358,10 +362,10 @@#ifdef CONFIG_SND_OSSEMUL snd_info_minor_register ();#endif -#ifdef CONFIG_DEVFS_FS -for (controlnum =0 ; controlnum < cards_limit; controlnum++) +for (controlnum =0 ; controlnum < cards_limit; controlnum++) {devfs_mk_cdev (MKDEV (major, controlnum<<5 ),S_IFCHR | device_mode,"snd/controlC%d" , controlnum); -#endif +class_simple_device_add (sound_class,MKDEV (major, controlnum<<5 ),NULL ,"controlC%d" , controlnum); + }#ifndef MODULE printk (KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n" );#endif
@@ -372,8 +376,10 @@ {short controlnum; -for (controlnum =0 ; controlnum < cards_limit; controlnum++) +for (controlnum =0 ; controlnum < cards_limit; controlnum++) {devfs_remove ("snd/controlC%d" , controlnum); +class_simple_device_remove (MKDEV (major, controlnum<<5 )); + }#ifdef CONFIG_SND_OSSEMUL snd_info_minor_unregister ();
sound/pci/intel8x0.c +1 -0
@@ -2591,6 +2591,7 @@break ; } } + card->dev = &pci->dev;if ((err =snd_intel8x0_create (card, pci, pci_id->driver_data, &chip)) <0 ) {snd_card_free (card);
Re: [PATCH] Driver Core update and fixes for 2.6.1
ChangeSet 1.1505, 2004/01/19 16:57:07-08:00, [email protected]
[PATCH] Kobject: prevent oops in kset_find_obj() if kobject_name() is NULL
Thanks to Hollis Blanchard <[email protected]> for pointing this out.
lib/kobject.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
@@ -547,7 +547,7 @@down_read (&kset->subsys->rwsem);list_for_each (entry,&kset->list) {struct kobject * k =to_kobj (entry); -if (!strcmp (kobject_name (k),name)) { +if (kobject_name (k) && (!strcmp (kobject_name (k),name))) { ret = k;break ; }
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
I have an maestro3 sound chip, and /sys/class/sound/ contains device information for both oss emulation and alsa devices.
Andreas
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
I see.
BTW, I still don't get a snd/controlC0 in /udev. All the other ALSA devices are there.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 14 lines · Måns Rullgård
Quoted 11 lines · Greg KH
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
Quoted 4 lines
I see.
BTW, I still don't get a snd/controlC0 in /udev. All the other ALSA devices are there.
Is there for me :)
What does /sys/class/sound show for you?
thanks,
greg k-h
Quoted 15 lines · Greg KH
Quoted 14 lines · Måns Rullgård
Quoted 11 lines · Greg KH
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
Quoted 8 lines
Quoted 4 lines
I see.
BTW, I still don't get a snd/controlC0 in /udev. All the other ALSA devices are there.
Is there for me :)
What does
/sys/class/soundshow for you?
$ ls /sys/class/sound pcmC0D0c pcmC0D0p pcmC0D1c timer
FWIW, I've updated my kernel to ALSA 1.0.1 and merged your patches.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 22 lines · Måns Rullgård
Quoted 20 lines · Greg KH
Quoted 18 lines · Måns Rullgård
Quoted 11 lines · Greg KH
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
I see.
BTW, I still don't get a snd/controlC0 in /udev. All the other ALSA devices are there.
Quoted 8 lines
Quoted 3 lines
Is there for me :)
What does
/sys/class/soundshow for you?$ ls /sys/class/sound pcmC0D0c pcmC0D0p pcmC0D1c timerFWIW, I've updated my kernel to ALSA 1.0.1 and merged your patches.
I don't know if any recent ALSA changes took away the controlC nodes, but your sound/core/sound.c::alsa_sound_init() should have a line in it that looks like:
class_simple_device_add(sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);
and that should always get called (make sure you took the stupid #ifdef CONFIG_DEVFS around that for loop.)
I'm guessing you didn't merge quite right :)
thanks,
greg k-h
Quoted 32 lines · Greg KH
Quoted 22 lines · Måns Rullgård
Quoted 20 lines · Greg KH
Quoted 18 lines · Måns Rullgård
Quoted 11 lines · Greg KH
Quoted 5 lines · Måns Rullgård
Quoted 1 line · Greg KH
o ALSA: add sysfs class support for ALSA sound devices
This is still only completed for the intel8x0 driver, right?
The "device" and "driver" symlink will only show up for that driver, yes. But the class support will work for all alsa devices. Now we can add 1 line patches for all of the alsa drivers to enable those symlinks...
I see.
BTW, I still don't get a snd/controlC0 in /udev. All the other ALSA devices are there.
Quoted 8 lines
Quoted 3 lines
Is there for me :)
What does
/sys/class/soundshow for you?$ ls /sys/class/sound pcmC0D0c pcmC0D0p pcmC0D1c timerFWIW, I've updated my kernel to ALSA 1.0.1 and merged your patches.
Quoted 8 lines
I don't know if any recent ALSA changes took away the controlC nodes, but your sound/core/sound.c::alsa_sound_init() should have a line in it that looks like:
class_simple_device_add(sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);and that should always get called (make sure you took the stupid #ifdef
CONFIG_DEVFSaround that for loop.)I'm guessing you didn't merge quite right :)
It seems like something did go wrong with my merge. I'm still trying to get the hang of bitkeeper, so I'll blame it on the learning curve.
Signature · 2 lines
Måns Rullgård [email protected]