• Andrew Morton's avatar
    [PATCH] devfs: API changes · bd1f184d
    Andrew Morton authored
    From: Christoph Hellwig <hch@lst.de>
    
    Some people may already have noticed that I've been revamping the devfs API
    recently.  The worst offender still left is devfs_register, it's prototype
    is:
    
    	 devfs_handle_t devfs_register(devfs_handle_t dir,
    		const char *name, unsigned int flags,
    		unsigned int major, unsigned int minor,
    		umode_t mode, void *ops, void *info)
    
    Of these:
    
     - dir and flags are always zero
     - the return value is never used
     - info is only used in one driver which doesn't even need it for
       operation
     - umode_t always describes a character device
     - name very often comes from a stack buffer we sprintf'ed into
    
    so obviously we really want a much simpler API instead.  My first draft for
    this was:
    
    	int devfs_mk_cdev(dev_t dev, umode_t mode,
    		struct file_operations *fops, void *info,
    		const char *fmt, ...)
    
    this removes the unused argumens, switches to a proper dev_t for the device
    number and allows to directly use a printf-like expression as name, getting
    rid of the temporary buffers.
    
    Now Al has reappeared and put the first steps of his CIDR for charater device
    on public ftp and we'll soon have a similar lookup object + fops mechanism in
    generic code as we already habe for blockdevices, i.e.  the devfs code to
    assign fops from an entry will become superflous as generic code already does
    it.  That means the fops and info arguments are obsolete before they were
    introduced, so I'd like to propose the following API instead:
    
    	int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
    
    which is much nicer anyway.  The educated reader will notice that this is
    exactly the same prototype devfs_mk_bdev has so I'll probably get suggestions
    to merge those two into some kind of devfs_mk_node soon.  Personally I don't
    like that as character and blockdevices are two really separate entinities
    and I'll like to keep them as separate as possible.
    
    Example patch that introduces the API and converts drivers/input attached.
    
    Every driver which calls devfs_mk_cdev (about 50) needs conversion.  Note
    that the transition can happen in pieces - devfs_register continues to work
    after this patch, it's just the plan to get rid of it in the end.
    bd1f184d
evdev.c 11.7 KB