Commit 2682d27c authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Greg Kroah-Hartman

[PATCH] USB: convert the semaphores in the sisusb driver to mutexes

From: Arjan van de Ven <arjan@infradead.org>

Convert the semaphores-used-as-mutex to mutexes in the sisusb video driver;
this required manual checking due to the "return as locked" stuff in this
driver, but the ->lock semaphore is still used as mutex in the end.
Signed-off-by: default avatarArjan van de Ven <arjan@infradead.org>
Cc: Thomas Winischhofer <winischhofer.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7327413c
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/mutex.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/signal.h> #include <linux/signal.h>
...@@ -102,7 +103,7 @@ MODULE_PARM_DESC(last, "Number of last console to take over (1 - MAX_NR_CONSOLES ...@@ -102,7 +103,7 @@ MODULE_PARM_DESC(last, "Number of last console to take over (1 - MAX_NR_CONSOLES
static struct usb_driver sisusb_driver; static struct usb_driver sisusb_driver;
DECLARE_MUTEX(disconnect_sem); DEFINE_MUTEX(disconnect_mutex);
static void static void
sisusb_free_buffers(struct sisusb_usb_data *sisusb) sisusb_free_buffers(struct sisusb_usb_data *sisusb)
...@@ -2552,39 +2553,39 @@ sisusb_open(struct inode *inode, struct file *file) ...@@ -2552,39 +2553,39 @@ sisusb_open(struct inode *inode, struct file *file)
struct usb_interface *interface; struct usb_interface *interface;
int subminor = iminor(inode); int subminor = iminor(inode);
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { if (!(interface = usb_find_interface(&sisusb_driver, subminor))) {
printk(KERN_ERR "sisusb[%d]: Failed to find interface\n", printk(KERN_ERR "sisusb[%d]: Failed to find interface\n",
subminor); subminor);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return -ENODEV; return -ENODEV;
} }
if (!(sisusb = usb_get_intfdata(interface))) { if (!(sisusb = usb_get_intfdata(interface))) {
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return -ENODEV; return -ENODEV;
} }
down(&sisusb->lock); mutex_lock(&sisusb->lock);
if (!sisusb->present || !sisusb->ready) { if (!sisusb->present || !sisusb->ready) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return -ENODEV; return -ENODEV;
} }
if (sisusb->isopen) { if (sisusb->isopen) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return -EBUSY; return -EBUSY;
} }
if (!sisusb->devinit) { if (!sisusb->devinit) {
if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) { if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) {
if (sisusb_init_gfxdevice(sisusb, 0)) { if (sisusb_init_gfxdevice(sisusb, 0)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
printk(KERN_ERR printk(KERN_ERR
"sisusbvga[%d]: Failed to initialize " "sisusbvga[%d]: Failed to initialize "
"device\n", "device\n",
...@@ -2592,8 +2593,8 @@ sisusb_open(struct inode *inode, struct file *file) ...@@ -2592,8 +2593,8 @@ sisusb_open(struct inode *inode, struct file *file)
return -EIO; return -EIO;
} }
} else { } else {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
printk(KERN_ERR printk(KERN_ERR
"sisusbvga[%d]: Device not attached to " "sisusbvga[%d]: Device not attached to "
"USB 2.0 hub\n", "USB 2.0 hub\n",
...@@ -2609,9 +2610,9 @@ sisusb_open(struct inode *inode, struct file *file) ...@@ -2609,9 +2610,9 @@ sisusb_open(struct inode *inode, struct file *file)
file->private_data = sisusb; file->private_data = sisusb;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return 0; return 0;
} }
...@@ -2642,14 +2643,14 @@ sisusb_release(struct inode *inode, struct file *file) ...@@ -2642,14 +2643,14 @@ sisusb_release(struct inode *inode, struct file *file)
struct sisusb_usb_data *sisusb; struct sisusb_usb_data *sisusb;
int myminor; int myminor;
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) { if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) {
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return -ENODEV; return -ENODEV;
} }
down(&sisusb->lock); mutex_lock(&sisusb->lock);
if (sisusb->present) { if (sisusb->present) {
/* Wait for all URBs to finish if device still present */ /* Wait for all URBs to finish if device still present */
...@@ -2662,12 +2663,12 @@ sisusb_release(struct inode *inode, struct file *file) ...@@ -2662,12 +2663,12 @@ sisusb_release(struct inode *inode, struct file *file)
sisusb->isopen = 0; sisusb->isopen = 0;
file->private_data = NULL; file->private_data = NULL;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
/* decrement the usage count on our device */ /* decrement the usage count on our device */
kref_put(&sisusb->kref, sisusb_delete); kref_put(&sisusb->kref, sisusb_delete);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return 0; return 0;
} }
...@@ -2685,11 +2686,11 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) ...@@ -2685,11 +2686,11 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
return -ENODEV; return -ENODEV;
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Sanity check */ /* Sanity check */
if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) { if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -ENODEV; return -ENODEV;
} }
...@@ -2784,7 +2785,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) ...@@ -2784,7 +2785,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
(*ppos) <= SISUSB_PCI_PSEUDO_PCIBASE + 0x5c) { (*ppos) <= SISUSB_PCI_PSEUDO_PCIBASE + 0x5c) {
if (count != 4) { if (count != 4) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -2808,7 +2809,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) ...@@ -2808,7 +2809,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
(*ppos) += bytes_read; (*ppos) += bytes_read;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return errno ? errno : bytes_read; return errno ? errno : bytes_read;
} }
...@@ -2827,11 +2828,11 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, ...@@ -2827,11 +2828,11 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
return -ENODEV; return -ENODEV;
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Sanity check */ /* Sanity check */
if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) { if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -ENODEV; return -ENODEV;
} }
...@@ -2930,7 +2931,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, ...@@ -2930,7 +2931,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,
(*ppos) <= SISUSB_PCI_PSEUDO_PCIBASE + SISUSB_PCI_PCONFSIZE) { (*ppos) <= SISUSB_PCI_PSEUDO_PCIBASE + SISUSB_PCI_PCONFSIZE) {
if (count != 4) { if (count != 4) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -2956,7 +2957,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, ...@@ -2956,7 +2957,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,
(*ppos) += bytes_written; (*ppos) += bytes_written;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return errno ? errno : bytes_written; return errno ? errno : bytes_written;
} }
...@@ -2970,11 +2971,11 @@ sisusb_lseek(struct file *file, loff_t offset, int orig) ...@@ -2970,11 +2971,11 @@ sisusb_lseek(struct file *file, loff_t offset, int orig)
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
return -ENODEV; return -ENODEV;
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Sanity check */ /* Sanity check */
if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) { if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -ENODEV; return -ENODEV;
} }
...@@ -2994,7 +2995,7 @@ sisusb_lseek(struct file *file, loff_t offset, int orig) ...@@ -2994,7 +2995,7 @@ sisusb_lseek(struct file *file, loff_t offset, int orig)
ret = -EINVAL; ret = -EINVAL;
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return ret; return ret;
} }
...@@ -3136,7 +3137,7 @@ sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -3136,7 +3137,7 @@ sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
return -ENODEV; return -ENODEV;
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Sanity check */ /* Sanity check */
if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) { if (!sisusb->present || !sisusb->ready || !sisusb->sisusb_dev) {
...@@ -3193,7 +3194,7 @@ sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -3193,7 +3194,7 @@ sisusb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
} }
err_out: err_out:
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return retval; return retval;
} }
...@@ -3258,7 +3259,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3258,7 +3259,7 @@ static int sisusb_probe(struct usb_interface *intf,
} }
kref_init(&sisusb->kref); kref_init(&sisusb->kref);
init_MUTEX(&(sisusb->lock)); mutex_init(&(sisusb->lock));
/* Register device */ /* Register device */
if ((retval = usb_register_dev(intf, &usb_sisusb_class))) { if ((retval = usb_register_dev(intf, &usb_sisusb_class))) {
...@@ -3429,9 +3430,9 @@ static void sisusb_disconnect(struct usb_interface *intf) ...@@ -3429,9 +3430,9 @@ static void sisusb_disconnect(struct usb_interface *intf)
* protect all other routines from the disconnect * protect all other routines from the disconnect
* case, not the other way round. * case, not the other way round.
*/ */
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Wait for all URBs to complete and kill them in case (MUST do) */ /* Wait for all URBs to complete and kill them in case (MUST do) */
if (!sisusb_wait_all_out_complete(sisusb)) if (!sisusb_wait_all_out_complete(sisusb))
...@@ -3462,12 +3463,12 @@ static void sisusb_disconnect(struct usb_interface *intf) ...@@ -3462,12 +3463,12 @@ static void sisusb_disconnect(struct usb_interface *intf)
sisusb->present = 0; sisusb->present = 0;
sisusb->ready = 0; sisusb->ready = 0;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
/* decrement our usage count */ /* decrement our usage count */
kref_put(&sisusb->kref, sisusb_delete); kref_put(&sisusb->kref, sisusb_delete);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
printk(KERN_INFO "sisusbvga[%d]: Disconnected\n", minor); printk(KERN_INFO "sisusbvga[%d]: Disconnected\n", minor);
} }
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#define SISUSB_NEW_CONFIG_COMPAT #define SISUSB_NEW_CONFIG_COMPAT
#endif #endif
#include <linux/mutex.h>
/* For older kernels, support for text consoles is by default /* For older kernels, support for text consoles is by default
* off. To ensable text console support, change the following: * off. To ensable text console support, change the following:
*/ */
...@@ -60,11 +62,9 @@ ...@@ -60,11 +62,9 @@
#define INCL_SISUSB_CON 1 #define INCL_SISUSB_CON 1
#endif #endif
#ifdef INCL_SISUSB_CON
#include <linux/console.h> #include <linux/console.h>
#include <linux/vt_kern.h> #include <linux/vt_kern.h>
#include "sisusb_struct.h" #include "sisusb_struct.h"
#endif
/* USB related */ /* USB related */
...@@ -116,7 +116,7 @@ struct sisusb_usb_data { ...@@ -116,7 +116,7 @@ struct sisusb_usb_data {
struct usb_interface *interface; struct usb_interface *interface;
struct kref kref; struct kref kref;
wait_queue_head_t wait_q; /* for syncind and timeouts */ wait_queue_head_t wait_q; /* for syncind and timeouts */
struct semaphore lock; /* general race avoidance */ struct mutex lock; /* general race avoidance */
unsigned int ifnum; /* interface number of the USB device */ unsigned int ifnum; /* interface number of the USB device */
int minor; /* minor (for logging clarity) */ int minor; /* minor (for logging clarity) */
int isopen; /* !=0 if open */ int isopen; /* !=0 if open */
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/mutex.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/signal.h> #include <linux/signal.h>
...@@ -102,7 +103,7 @@ static struct sisusb_usb_data *mysisusbs[MAX_NR_CONSOLES]; ...@@ -102,7 +103,7 @@ static struct sisusb_usb_data *mysisusbs[MAX_NR_CONSOLES];
/* Forward declaration */ /* Forward declaration */
static const struct consw sisusb_con; static const struct consw sisusb_con;
extern struct semaphore disconnect_sem; extern struct mutex disconnect_mutex;
static inline void static inline void
sisusbcon_memsetw(u16 *s, u16 c, unsigned int count) sisusbcon_memsetw(u16 *s, u16 c, unsigned int count)
...@@ -194,11 +195,11 @@ sisusb_get_sisusb_lock_and_check(unsigned short console) ...@@ -194,11 +195,11 @@ sisusb_get_sisusb_lock_and_check(unsigned short console)
if (!(sisusb = sisusb_get_sisusb(console))) if (!(sisusb = sisusb_get_sisusb(console)))
return NULL; return NULL;
down(&sisusb->lock); mutex_lock(&sisusb->lock);
if (!sisusb_sisusb_valid(sisusb) || if (!sisusb_sisusb_valid(sisusb) ||
!sisusb->havethisconsole[console]) { !sisusb->havethisconsole[console]) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return NULL; return NULL;
} }
...@@ -236,18 +237,18 @@ sisusbcon_init(struct vc_data *c, int init) ...@@ -236,18 +237,18 @@ sisusbcon_init(struct vc_data *c, int init)
* are set up/restored. * are set up/restored.
*/ */
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
if (!(sisusb = sisusb_get_sisusb(c->vc_num))) { if (!(sisusb = sisusb_get_sisusb(c->vc_num))) {
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return; return;
} }
down(&sisusb->lock); mutex_lock(&sisusb->lock);
if (!sisusb_sisusb_valid(sisusb)) { if (!sisusb_sisusb_valid(sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return; return;
} }
...@@ -284,9 +285,9 @@ sisusbcon_init(struct vc_data *c, int init) ...@@ -284,9 +285,9 @@ sisusbcon_init(struct vc_data *c, int init)
if (!*c->vc_uni_pagedir_loc) if (!*c->vc_uni_pagedir_loc)
con_set_default_unimap(c); con_set_default_unimap(c);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
if (init) { if (init) {
c->vc_cols = cols; c->vc_cols = cols;
...@@ -306,14 +307,14 @@ sisusbcon_deinit(struct vc_data *c) ...@@ -306,14 +307,14 @@ sisusbcon_deinit(struct vc_data *c)
* and others, ie not under our control. * and others, ie not under our control.
*/ */
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
if (!(sisusb = sisusb_get_sisusb(c->vc_num))) { if (!(sisusb = sisusb_get_sisusb(c->vc_num))) {
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return; return;
} }
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Clear ourselves in mysisusbs */ /* Clear ourselves in mysisusbs */
mysisusbs[c->vc_num] = NULL; mysisusbs[c->vc_num] = NULL;
...@@ -332,12 +333,12 @@ sisusbcon_deinit(struct vc_data *c) ...@@ -332,12 +333,12 @@ sisusbcon_deinit(struct vc_data *c)
} }
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
/* decrement the usage count on our sisusb */ /* decrement the usage count on our sisusb */
kref_put(&sisusb->kref, sisusb_delete); kref_put(&sisusb->kref, sisusb_delete);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
} }
/* interface routine */ /* interface routine */
...@@ -417,7 +418,7 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x) ...@@ -417,7 +418,7 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x)
#endif #endif
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -425,7 +426,7 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x) ...@@ -425,7 +426,7 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x)
sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
(u32)SISUSB_HADDR(x, y), 2, &written); (u32)SISUSB_HADDR(x, y), 2, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
/* Interface routine */ /* Interface routine */
...@@ -453,14 +454,14 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, ...@@ -453,14 +454,14 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s,
sisusbcon_writew(sisusbcon_readw(s++), dest++); sisusbcon_writew(sisusbcon_readw(s++), dest++);
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y),
(u32)SISUSB_HADDR(x, y), count * 2, &written); (u32)SISUSB_HADDR(x, y), count * 2, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
/* Interface routine */ /* Interface routine */
...@@ -504,7 +505,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) ...@@ -504,7 +505,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width)
} }
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -514,7 +515,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) ...@@ -514,7 +515,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width)
sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y), sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y),
(u32)SISUSB_HADDR(x, y), length, &written); (u32)SISUSB_HADDR(x, y), length, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
/* Interface routine */ /* Interface routine */
...@@ -576,7 +577,7 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx, ...@@ -576,7 +577,7 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx,
#endif #endif
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -586,7 +587,7 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx, ...@@ -586,7 +587,7 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx,
sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(dx, dy), sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(dx, dy),
(u32)SISUSB_HADDR(dx, dy), length, &written); (u32)SISUSB_HADDR(dx, dy), length, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
/* interface routine */ /* interface routine */
...@@ -609,7 +610,7 @@ sisusbcon_switch(struct vc_data *c) ...@@ -609,7 +610,7 @@ sisusbcon_switch(struct vc_data *c)
/* Don't write to screen if in gfx mode */ /* Don't write to screen if in gfx mode */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -618,7 +619,7 @@ sisusbcon_switch(struct vc_data *c) ...@@ -618,7 +619,7 @@ sisusbcon_switch(struct vc_data *c)
* as origin. * as origin.
*/ */
if (c->vc_origin == (unsigned long)c->vc_screenbuf) { if (c->vc_origin == (unsigned long)c->vc_screenbuf) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_DEBUG "sisusb: ASSERT ORIGIN != SCREENBUF!\n"); printk(KERN_DEBUG "sisusb: ASSERT ORIGIN != SCREENBUF!\n");
return 0; return 0;
} }
...@@ -635,7 +636,7 @@ sisusbcon_switch(struct vc_data *c) ...@@ -635,7 +636,7 @@ sisusbcon_switch(struct vc_data *c)
(u32)SISUSB_HADDR(0, 0), (u32)SISUSB_HADDR(0, 0),
length, &written); length, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -657,7 +658,7 @@ sisusbcon_save_screen(struct vc_data *c) ...@@ -657,7 +658,7 @@ sisusbcon_save_screen(struct vc_data *c)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -669,7 +670,7 @@ sisusbcon_save_screen(struct vc_data *c) ...@@ -669,7 +670,7 @@ sisusbcon_save_screen(struct vc_data *c)
sisusbcon_memcpyw((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin, sisusbcon_memcpyw((u16 *)c->vc_screenbuf, (u16 *)c->vc_origin,
length); length);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
/* interface routine */ /* interface routine */
...@@ -690,7 +691,7 @@ sisusbcon_set_palette(struct vc_data *c, unsigned char *table) ...@@ -690,7 +691,7 @@ sisusbcon_set_palette(struct vc_data *c, unsigned char *table)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -705,7 +706,7 @@ sisusbcon_set_palette(struct vc_data *c, unsigned char *table) ...@@ -705,7 +706,7 @@ sisusbcon_set_palette(struct vc_data *c, unsigned char *table)
break; break;
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -728,7 +729,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) ...@@ -728,7 +729,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch)
sisusb->is_gfx = blank ? 1 : 0; sisusb->is_gfx = blank ? 1 : 0;
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -777,7 +778,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) ...@@ -777,7 +778,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch)
cr63 = 0x40; cr63 = 0x40;
break; break;
default: default:
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -788,7 +789,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch) ...@@ -788,7 +789,7 @@ sisusbcon_blank(struct vc_data *c, int blank, int mode_switch)
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return ret; return ret;
} }
...@@ -809,7 +810,7 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines) ...@@ -809,7 +810,7 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -849,7 +850,7 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines) ...@@ -849,7 +850,7 @@ sisusbcon_scrolldelta(struct vc_data *c, int lines)
sisusbcon_set_start_address(sisusb, c); sisusbcon_set_start_address(sisusb, c);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 1; return 1;
} }
...@@ -867,7 +868,7 @@ sisusbcon_cursor(struct vc_data *c, int mode) ...@@ -867,7 +868,7 @@ sisusbcon_cursor(struct vc_data *c, int mode)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -879,7 +880,7 @@ sisusbcon_cursor(struct vc_data *c, int mode) ...@@ -879,7 +880,7 @@ sisusbcon_cursor(struct vc_data *c, int mode)
if (mode == CM_ERASE) { if (mode == CM_ERASE) {
sisusb_setidxregor(sisusb, SISCR, 0x0a, 0x20); sisusb_setidxregor(sisusb, SISCR, 0x0a, 0x20);
sisusb->sisusb_cursor_size_to = -1; sisusb->sisusb_cursor_size_to = -1;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return; return;
} }
...@@ -919,7 +920,7 @@ sisusbcon_cursor(struct vc_data *c, int mode) ...@@ -919,7 +920,7 @@ sisusbcon_cursor(struct vc_data *c, int mode)
sisusb->sisusb_cursor_size_to = to; sisusb->sisusb_cursor_size_to = to;
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
} }
static int static int
...@@ -961,7 +962,7 @@ sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb, ...@@ -961,7 +962,7 @@ sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb,
sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t), sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t),
(u32)SISUSB_HADDR(0, t), length, &written); (u32)SISUSB_HADDR(0, t), length, &written);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 1; return 1;
} }
...@@ -994,7 +995,7 @@ sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines) ...@@ -994,7 +995,7 @@ sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb)) { if (sisusb_is_inactive(c, sisusb)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -1084,7 +1085,7 @@ sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines) ...@@ -1084,7 +1085,7 @@ sisusbcon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
c->vc_pos = c->vc_pos - oldorigin + c->vc_origin; c->vc_pos = c->vc_pos - oldorigin + c->vc_origin;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 1; return 1;
} }
...@@ -1106,7 +1107,7 @@ sisusbcon_set_origin(struct vc_data *c) ...@@ -1106,7 +1107,7 @@ sisusbcon_set_origin(struct vc_data *c)
/* sisusb->lock is down */ /* sisusb->lock is down */
if (sisusb_is_inactive(c, sisusb) || sisusb->con_blanked) { if (sisusb_is_inactive(c, sisusb) || sisusb->con_blanked) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -1116,7 +1117,7 @@ sisusbcon_set_origin(struct vc_data *c) ...@@ -1116,7 +1117,7 @@ sisusbcon_set_origin(struct vc_data *c)
sisusb->con_rolled_over = 0; sisusb->con_rolled_over = 0;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 1; return 1;
} }
...@@ -1133,7 +1134,7 @@ sisusbcon_resize(struct vc_data *c, unsigned int newcols, unsigned int newrows) ...@@ -1133,7 +1134,7 @@ sisusbcon_resize(struct vc_data *c, unsigned int newcols, unsigned int newrows)
fh = sisusb->current_font_height; fh = sisusb->current_font_height;
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
/* We are quite unflexible as regards resizing. The vt code /* We are quite unflexible as regards resizing. The vt code
* handles sizes where the line length isn't equal the pitch * handles sizes where the line length isn't equal the pitch
...@@ -1167,7 +1168,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot, ...@@ -1167,7 +1168,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot,
if ((slot != 0 && slot != 2) || !fh) { if ((slot != 0 && slot != 2) || !fh) {
if (uplock) if (uplock)
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1327,7 +1328,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot, ...@@ -1327,7 +1328,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot,
} }
if (uplock) if (uplock)
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
if (dorecalc && c) { if (dorecalc && c) {
int i, rows = c->vc_scan_lines / fh; int i, rows = c->vc_scan_lines / fh;
...@@ -1351,7 +1352,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot, ...@@ -1351,7 +1352,7 @@ sisusbcon_do_font_op(struct sisusb_usb_data *sisusb, int set, int slot,
font_op_error: font_op_error:
if (uplock) if (uplock)
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -EIO; return -EIO;
} }
...@@ -1417,19 +1418,19 @@ sisusbcon_font_get(struct vc_data *c, struct console_font *font) ...@@ -1417,19 +1418,19 @@ sisusbcon_font_get(struct vc_data *c, struct console_font *font)
font->charcount = 256; font->charcount = 256;
if (!font->data) { if (!font->data) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
if (!sisusb->font_backup) { if (!sisusb->font_backup) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return -ENODEV; return -ENODEV;
} }
/* Copy 256 chars only, like vgacon */ /* Copy 256 chars only, like vgacon */
memcpy(font->data, sisusb->font_backup, 256 * 32); memcpy(font->data, sisusb->font_backup, 256 * 32);
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
return 0; return 0;
} }
...@@ -1512,14 +1513,14 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1512,14 +1513,14 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
{ {
int i, ret, minor = sisusb->minor; int i, ret, minor = sisusb->minor;
down(&disconnect_sem); mutex_lock(&disconnect_mutex);
down(&sisusb->lock); mutex_lock(&sisusb->lock);
/* Erm.. that should not happen */ /* Erm.. that should not happen */
if (sisusb->haveconsole || !sisusb->SiS_Pr) { if (sisusb->haveconsole || !sisusb->SiS_Pr) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return 1; return 1;
} }
...@@ -1529,15 +1530,15 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1529,15 +1530,15 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
if (first > last || if (first > last ||
first > MAX_NR_CONSOLES || first > MAX_NR_CONSOLES ||
last > MAX_NR_CONSOLES) { last > MAX_NR_CONSOLES) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return 1; return 1;
} }
/* If gfxcore not initialized or no consoles given, quit graciously */ /* If gfxcore not initialized or no consoles given, quit graciously */
if (!sisusb->gfxinit || first < 1 || last < 1) { if (!sisusb->gfxinit || first < 1 || last < 1) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
return 0; return 0;
} }
...@@ -1547,8 +1548,8 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1547,8 +1548,8 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
/* Set up text mode (and upload default font) */ /* Set up text mode (and upload default font) */
if (sisusb_reset_text_mode(sisusb, 1)) { if (sisusb_reset_text_mode(sisusb, 1)) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
printk(KERN_ERR printk(KERN_ERR
"sisusbvga[%d]: Failed to set up text mode\n", "sisusbvga[%d]: Failed to set up text mode\n",
minor); minor);
...@@ -1571,16 +1572,16 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1571,16 +1572,16 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
/* Allocate screen buffer */ /* Allocate screen buffer */
if (!(sisusb->scrbuf = (unsigned long)vmalloc(sisusb->scrbuf_size))) { if (!(sisusb->scrbuf = (unsigned long)vmalloc(sisusb->scrbuf_size))) {
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
printk(KERN_ERR printk(KERN_ERR
"sisusbvga[%d]: Failed to allocate screen buffer\n", "sisusbvga[%d]: Failed to allocate screen buffer\n",
minor); minor);
return 1; return 1;
} }
up(&sisusb->lock); mutex_unlock(&sisusb->lock);
up(&disconnect_sem); mutex_unlock(&disconnect_mutex);
/* Now grab the desired console(s) */ /* Now grab the desired console(s) */
ret = take_over_console(&sisusb_con, first - 1, last - 1, 0); ret = take_over_console(&sisusb_con, first - 1, last - 1, 0);
......
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