Commit 558d8e73 authored by Linus Torvalds's avatar Linus Torvalds

Import 2.3.99pre3-5

parent a69c5745
...@@ -220,7 +220,7 @@ int __init acq_init(void) ...@@ -220,7 +220,7 @@ int __init acq_init(void)
{ {
printk("WDT driver for Acquire single board computer initialising.\n"); printk("WDT driver for Acquire single board computer initialising.\n");
spin_lock_init(acq_lock); spin_lock_init(&acq_lock);
misc_register(&acq_miscdev); misc_register(&acq_miscdev);
request_region(WDT_STOP, 1, "Acquire WDT"); request_region(WDT_STOP, 1, "Acquire WDT");
request_region(WDT_START, 1, "Acquire WDT"); request_region(WDT_START, 1, "Acquire WDT");
......
...@@ -116,8 +116,8 @@ static int __init atixl_busmouse_init(void) ...@@ -116,8 +116,8 @@ static int __init atixl_busmouse_init(void)
* nowdays. We can throw it away on error. Otherwise we * nowdays. We can throw it away on error. Otherwise we
* may race another module load of the same I/O * may race another module load of the same I/O
*/ */
if (request_region(ATIXL_MSE_DATA_PORT, 3)) if (request_region(ATIXL_MSE_DATA_PORT, 3, "atixlmouse"))
return -EIO; return -EIO;
a = inb( ATIXL_MSE_SIGNATURE_PORT ); /* Get signature */ a = inb( ATIXL_MSE_SIGNATURE_PORT ); /* Get signature */
......
...@@ -70,7 +70,13 @@ struct busmouse_data { ...@@ -70,7 +70,13 @@ struct busmouse_data {
#define DEV_TO_MOUSE(dev) MINOR_TO_MOUSE(MINOR(dev)) #define DEV_TO_MOUSE(dev) MINOR_TO_MOUSE(MINOR(dev))
#define MINOR_TO_MOUSE(minor) ((minor) - FIRST_MOUSE) #define MINOR_TO_MOUSE(minor) ((minor) - FIRST_MOUSE)
/*
* List of mice and guarding semaphore. You must take the semaphore
* before you take the misc device semaphore if you need both
*/
static struct busmouse_data *busmouse_data[NR_MICE]; static struct busmouse_data *busmouse_data[NR_MICE];
static DECLARE_MUTEX(mouse_sem);
/* a mouse driver just has to interface with these functions /* a mouse driver just has to interface with these functions
* These are !!!OLD!!! Do not use!!! * These are !!!OLD!!! Do not use!!!
...@@ -98,8 +104,7 @@ int add_mouse_buttonchange(int set, int value) ...@@ -98,8 +104,7 @@ int add_mouse_buttonchange(int set, int value)
/* New interface. !!! Use this one !!! /* New interface. !!! Use this one !!!
* These routines will most probably be called from interrupt. * These routines will most probably be called from interrupt.
*/ */
void void busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons)
busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons)
{ {
struct busmouse_data *mse = busmouse_data[mousedev]; struct busmouse_data *mse = busmouse_data[mousedev];
int changed; int changed;
...@@ -141,24 +146,21 @@ busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons) ...@@ -141,24 +146,21 @@ busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons)
} }
} }
void void busmouse_add_movement(int mousedev, int dx, int dy)
busmouse_add_movement(int mousedev, int dx, int dy)
{ {
struct busmouse_data *mse = busmouse_data[mousedev]; struct busmouse_data *mse = busmouse_data[mousedev];
busmouse_add_movementbuttons(mousedev, dx, dy, mse->buttons); busmouse_add_movementbuttons(mousedev, dx, dy, mse->buttons);
} }
void void busmouse_add_buttons(int mousedev, int clear, int eor)
busmouse_add_buttons(int mousedev, int clear, int eor)
{ {
struct busmouse_data *mse = busmouse_data[mousedev]; struct busmouse_data *mse = busmouse_data[mousedev];
busmouse_add_movementbuttons(mousedev, 0, 0, (mse->buttons & ~clear) ^ eor); busmouse_add_movementbuttons(mousedev, 0, 0, (mse->buttons & ~clear) ^ eor);
} }
static int static int busmouse_fasync(int fd, struct file *filp, int on)
busmouse_fasync(int fd, struct file *filp, int on)
{ {
struct busmouse_data *mse = (struct busmouse_data *)filp->private_data; struct busmouse_data *mse = (struct busmouse_data *)filp->private_data;
int retval; int retval;
...@@ -169,8 +171,7 @@ busmouse_fasync(int fd, struct file *filp, int on) ...@@ -169,8 +171,7 @@ busmouse_fasync(int fd, struct file *filp, int on)
return 0; return 0;
} }
static int static int busmouse_release(struct inode *inode, struct file *file)
busmouse_release(struct inode *inode, struct file *file)
{ {
struct busmouse_data *mse = (struct busmouse_data *)file->private_data; struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
int ret = 0; int ret = 0;
...@@ -190,33 +191,34 @@ busmouse_release(struct inode *inode, struct file *file) ...@@ -190,33 +191,34 @@ busmouse_release(struct inode *inode, struct file *file)
return ret; return ret;
} }
static int static int busmouse_open(struct inode *inode, struct file *file)
busmouse_open(struct inode *inode, struct file *file)
{ {
struct busmouse_data *mse; struct busmouse_data *mse;
unsigned long flags; unsigned long flags;
unsigned int mousedev; unsigned int mousedev;
int ret = 0; int ret = -ENODEV;
mousedev = DEV_TO_MOUSE(inode->i_rdev); mousedev = DEV_TO_MOUSE(inode->i_rdev);
if (mousedev >= NR_MICE) if (mousedev >= NR_MICE)
return -EINVAL; return -EINVAL;
down(&mouse_sem);
mse = busmouse_data[mousedev]; mse = busmouse_data[mousedev];
if (!mse) if (!mse)
/* shouldn't happen, but... */ /* shouldn't happen, but... */
return -ENODEV; goto end;
if (mse->ops && if (mse->ops &&
mse->ops->open) mse->ops->open)
ret = mse->ops->open(inode, file); ret = mse->ops->open(inode, file);
if (ret) if (ret)
return ret; goto end;
file->private_data = mse; file->private_data = mse;
if (mse->active++) if (mse->active++)
return 0; goto end;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
...@@ -231,18 +233,17 @@ busmouse_open(struct inode *inode, struct file *file) ...@@ -231,18 +233,17 @@ busmouse_open(struct inode *inode, struct file *file)
mse->buttons = 7; mse->buttons = 7;
spin_unlock_irqrestore(&mse->lock, flags); spin_unlock_irqrestore(&mse->lock, flags);
end:
return 0; up(&mouse_sem);
return ret;
} }
static ssize_t static ssize_t busmouse_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
busmouse_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
{ {
return -EINVAL; return -EINVAL;
} }
static ssize_t static ssize_t busmouse_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
busmouse_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
{ {
struct busmouse_data *mse = (struct busmouse_data *)file->private_data; struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -328,8 +329,7 @@ busmouse_read(struct file *file, char *buffer, size_t count, loff_t *ppos) ...@@ -328,8 +329,7 @@ busmouse_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
return count; return count;
} }
static unsigned int static unsigned int busmouse_poll(struct file *file, poll_table *wait)
busmouse_poll(struct file *file, poll_table *wait)
{ {
struct busmouse_data *mse = (struct busmouse_data *)file->private_data; struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
...@@ -351,8 +351,16 @@ struct file_operations busmouse_fops= ...@@ -351,8 +351,16 @@ struct file_operations busmouse_fops=
fasync: busmouse_fasync, fasync: busmouse_fasync,
}; };
int /**
register_busmouse(struct busmouse *ops) * register_busmouse - register a bus mouse interface
* @ops: busmouse structure for the mouse
*
* Registers a mouse with the driver. The return is mouse number on
* success and a negative errno code on an error. The passed ops
* structure most not be freed until the mouser is unregistered
*/
int register_busmouse(struct busmouse *ops)
{ {
unsigned int msedev = MINOR_TO_MOUSE(ops->minor); unsigned int msedev = MINOR_TO_MOUSE(ops->minor);
struct busmouse_data *mse; struct busmouse_data *mse;
...@@ -364,13 +372,18 @@ register_busmouse(struct busmouse *ops) ...@@ -364,13 +372,18 @@ register_busmouse(struct busmouse *ops)
return -EINVAL; return -EINVAL;
} }
if (busmouse_data[msedev])
return -EBUSY;
mse = kmalloc(sizeof(*mse), GFP_KERNEL); mse = kmalloc(sizeof(*mse), GFP_KERNEL);
if (!mse) if (!mse)
return -ENOMEM; return -ENOMEM;
down(&mouse_sem);
if (busmouse_data[msedev])
{
up(&mouse_sem);
kfree(mse);
return -EBUSY;
}
memset(mse, 0, sizeof(*mse)); memset(mse, 0, sizeof(*mse));
mse->miscdev.minor = ops->minor; mse->miscdev.minor = ops->minor;
...@@ -385,13 +398,23 @@ register_busmouse(struct busmouse *ops) ...@@ -385,13 +398,23 @@ register_busmouse(struct busmouse *ops)
ret = misc_register(&mse->miscdev); ret = misc_register(&mse->miscdev);
if (!ret) if (!ret)
ret = msedev; ret = msedev;
up(&mouse_sem);
return ret; return ret;
} }
int /**
unregister_busmouse(int mousedev) * unregister_busmouse - unregister a bus mouse interface
* @mousedev: Mouse number to release
*
* Unregister a previously installed mouse handler. The mousedev
* passed is the return code from a previous call to register_busmouse
*/
int unregister_busmouse(int mousedev)
{ {
int err = -EINVAL;
if (mousedev < 0) if (mousedev < 0)
return 0; return 0;
if (mousedev >= NR_MICE) { if (mousedev >= NR_MICE) {
...@@ -400,27 +423,30 @@ unregister_busmouse(int mousedev) ...@@ -400,27 +423,30 @@ unregister_busmouse(int mousedev)
return -EINVAL; return -EINVAL;
} }
down(&mouse_sem);
if (!busmouse_data[mousedev]) { if (!busmouse_data[mousedev]) {
printk(KERN_WARNING "busmouse: trying to free free mouse" printk(KERN_WARNING "busmouse: trying to free free mouse"
" on mousedev %d\n", mousedev); " on mousedev %d\n", mousedev);
return -EINVAL; goto fail;
} }
if (busmouse_data[mousedev]->active) { if (busmouse_data[mousedev]->active) {
printk(KERN_ERR "busmouse: trying to free active mouse" printk(KERN_ERR "busmouse: trying to free active mouse"
" on mousedev %d\n", mousedev); " on mousedev %d\n", mousedev);
return -EINVAL; goto fail;
} }
misc_deregister(&busmouse_data[mousedev]->miscdev); err=misc_deregister(&busmouse_data[mousedev]->miscdev);
kfree(busmouse_data[mousedev]); kfree(busmouse_data[mousedev]);
busmouse_data[mousedev] = NULL; busmouse_data[mousedev] = NULL;
return 0; fail:
up(&mouse_sem);
return err;
} }
int __init int __init bus_mouse_init(void)
bus_mouse_init(void)
{ {
#ifdef CONFIG_SUN_MOUSE #ifdef CONFIG_SUN_MOUSE
sun_mouse_init(); sun_mouse_init();
...@@ -435,14 +461,12 @@ EXPORT_SYMBOL(register_busmouse); ...@@ -435,14 +461,12 @@ EXPORT_SYMBOL(register_busmouse);
EXPORT_SYMBOL(unregister_busmouse); EXPORT_SYMBOL(unregister_busmouse);
#ifdef MODULE #ifdef MODULE
int int init_module(void)
init_module(void)
{ {
return bus_mouse_init(); return bus_mouse_init();
} }
void void cleanup_module(void)
cleanup_module(void)
{ {
} }
#endif #endif
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
* Head entry for the doubly linked miscdevice list * Head entry for the doubly linked miscdevice list
*/ */
static struct miscdevice misc_list = { 0, "head", NULL, &misc_list, &misc_list }; static struct miscdevice misc_list = { 0, "head", NULL, &misc_list, &misc_list };
static DECLARE_MUTEX(misc_sem);
/* /*
* Assigned numbers, used for dynamic minors * Assigned numbers, used for dynamic minors
...@@ -96,32 +97,42 @@ static int misc_read_proc(char *buf, char **start, off_t offset, ...@@ -96,32 +97,42 @@ static int misc_read_proc(char *buf, char **start, off_t offset,
static int misc_open(struct inode * inode, struct file * file) static int misc_open(struct inode * inode, struct file * file)
{ {
int minor = MINOR(inode->i_rdev); int minor = MINOR(inode->i_rdev);
struct miscdevice *c = misc_list.next; struct miscdevice *c;
int err = -ENODEV;
file->f_op = NULL; file->f_op = NULL;
down(&misc_sem);
c = misc_list.next;
while ((c != &misc_list) && (c->minor != minor)) while ((c != &misc_list) && (c->minor != minor))
c = c->next; c = c->next;
if (c == &misc_list) { if (c == &misc_list) {
char modname[20]; char modname[20];
up(&misc_sem);
sprintf(modname, "char-major-%d-%d", MISC_MAJOR, minor); sprintf(modname, "char-major-%d-%d", MISC_MAJOR, minor);
request_module(modname); request_module(modname);
down(&misc_sem);
c = misc_list.next; c = misc_list.next;
while ((c != &misc_list) && (c->minor != minor)) while ((c != &misc_list) && (c->minor != minor))
c = c->next; c = c->next;
if (c == &misc_list) if (c == &misc_list)
return -ENODEV; goto fail;
} }
if ((file->f_op = c->fops) && file->f_op->open) if ((file->f_op = c->fops) && file->f_op->open)
return file->f_op->open(inode,file); err=file->f_op->open(inode,file);
else fail:
return -ENODEV; up(&misc_sem);
return err;
} }
static struct file_operations misc_fops = { static struct file_operations misc_fops = {
open: misc_open, open: misc_open,
}; };
/** /**
* misc_register - register a miscellaneous device * misc_register - register a miscellaneous device
* @misc: device structure * @misc: device structure
...@@ -144,12 +155,17 @@ int misc_register(struct miscdevice * misc) ...@@ -144,12 +155,17 @@ int misc_register(struct miscdevice * misc)
if (misc->next || misc->prev) if (misc->next || misc->prev)
return -EBUSY; return -EBUSY;
down(&misc_sem);
if (misc->minor == MISC_DYNAMIC_MINOR) { if (misc->minor == MISC_DYNAMIC_MINOR) {
int i = DYNAMIC_MINORS; int i = DYNAMIC_MINORS;
while (--i >= 0) while (--i >= 0)
if ( (misc_minors[i>>3] & (1 << (i&7))) == 0) if ( (misc_minors[i>>3] & (1 << (i&7))) == 0)
break; break;
if (i<0) return -EBUSY; if (i<0)
{
up(&misc_sem);
return -EBUSY;
}
misc->minor = i; misc->minor = i;
} }
if (misc->minor < DYNAMIC_MINORS) if (misc->minor < DYNAMIC_MINORS)
...@@ -170,6 +186,7 @@ int misc_register(struct miscdevice * misc) ...@@ -170,6 +186,7 @@ int misc_register(struct miscdevice * misc)
misc->next = misc_list.next; misc->next = misc_list.next;
misc->prev->next = misc; misc->prev->next = misc;
misc->next->prev = misc; misc->next->prev = misc;
up(&misc_sem);
return 0; return 0;
} }
...@@ -188,6 +205,7 @@ int misc_deregister(struct miscdevice * misc) ...@@ -188,6 +205,7 @@ int misc_deregister(struct miscdevice * misc)
int i = misc->minor; int i = misc->minor;
if (!misc->next || !misc->prev) if (!misc->next || !misc->prev)
return -EINVAL; return -EINVAL;
down(&misc_sem);
misc->prev->next = misc->next; misc->prev->next = misc->next;
misc->next->prev = misc->prev; misc->next->prev = misc->prev;
misc->next = NULL; misc->next = NULL;
...@@ -196,6 +214,7 @@ int misc_deregister(struct miscdevice * misc) ...@@ -196,6 +214,7 @@ int misc_deregister(struct miscdevice * misc)
if (i < DYNAMIC_MINORS && i>0) { if (i < DYNAMIC_MINORS && i>0) {
misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
} }
up(&misc_sem);
return 0; return 0;
} }
......
...@@ -147,7 +147,6 @@ static int fs_index(const char * __name) ...@@ -147,7 +147,6 @@ static int fs_index(const char * __name)
err = index; err = index;
break; break;
} }
index++;
} }
spin_unlock(&file_systems_lock); spin_unlock(&file_systems_lock);
putname(name); putname(name);
......
...@@ -207,6 +207,7 @@ EXPORT_SYMBOL(posix_unblock_lock); ...@@ -207,6 +207,7 @@ EXPORT_SYMBOL(posix_unblock_lock);
EXPORT_SYMBOL(locks_mandatory_area); EXPORT_SYMBOL(locks_mandatory_area);
EXPORT_SYMBOL(dput); EXPORT_SYMBOL(dput);
EXPORT_SYMBOL(is_root_busy); EXPORT_SYMBOL(is_root_busy);
EXPORT_SYMBOL(have_submounts);
EXPORT_SYMBOL(prune_dcache); EXPORT_SYMBOL(prune_dcache);
EXPORT_SYMBOL(shrink_dcache_sb); EXPORT_SYMBOL(shrink_dcache_sb);
EXPORT_SYMBOL(shrink_dcache_parent); EXPORT_SYMBOL(shrink_dcache_parent);
...@@ -324,12 +325,20 @@ EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); ...@@ -324,12 +325,20 @@ EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
EXPORT_SYMBOL(proc_doulongvec_minmax); EXPORT_SYMBOL(proc_doulongvec_minmax);
/* interrupt handling */ /* interrupt handling */
EXPORT_SYMBOL(add_timer);
EXPORT_SYMBOL(del_timer);
EXPORT_SYMBOL(request_irq); EXPORT_SYMBOL(request_irq);
EXPORT_SYMBOL(free_irq); EXPORT_SYMBOL(free_irq);
/* The notion of irq probe/assignment is foreign to S/390 */
#if !defined(CONFIG_ARCH_S390)
EXPORT_SYMBOL(probe_irq_on); EXPORT_SYMBOL(probe_irq_on);
EXPORT_SYMBOL(probe_irq_off); EXPORT_SYMBOL(probe_irq_off);
EXPORT_SYMBOL(add_timer); EXPORT_SYMBOL(autoirq_setup);
EXPORT_SYMBOL(del_timer); EXPORT_SYMBOL(autoirq_report);
#endif
#ifdef __SMP__ #ifdef __SMP__
EXPORT_SYMBOL(del_timer_sync); EXPORT_SYMBOL(del_timer_sync);
#endif #endif
...@@ -366,10 +375,6 @@ EXPORT_SYMBOL(lock_kiovec); ...@@ -366,10 +375,6 @@ EXPORT_SYMBOL(lock_kiovec);
EXPORT_SYMBOL(unlock_kiovec); EXPORT_SYMBOL(unlock_kiovec);
EXPORT_SYMBOL(brw_kiovec); EXPORT_SYMBOL(brw_kiovec);
/* autoirq from drivers/net/auto_irq.c */
EXPORT_SYMBOL(autoirq_setup);
EXPORT_SYMBOL(autoirq_report);
/* dma handling */ /* dma handling */
EXPORT_SYMBOL(request_dma); EXPORT_SYMBOL(request_dma);
EXPORT_SYMBOL(free_dma); EXPORT_SYMBOL(free_dma);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment