X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fsbus%2Fchar%2Fjsflash.c;h=a624f5af4320d4b5e7158d2be4032d1501eb5336;hb=51f00a471ce8f359627dd99aeac322947a0e491b;hp=4942050dc5b6f0ea795d62e992368669ab1f6f6a;hpb=795e74f7a69f9c08afa4fa7c86cc4f18a62bd630;p=pandora-kernel.git diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 4942050dc5b6..a624f5af4320 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include #include @@ -68,6 +68,8 @@ #define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */ #define JSF_PART_MASK 0x3 /* 2 bits mask */ +static DEFINE_MUTEX(jsf_mutex); + /* * Access functions. * We could ioremap(), but it's easier this way. @@ -225,7 +227,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig) { loff_t ret; - lock_kernel(); + mutex_lock(&jsf_mutex); switch (orig) { case 0: file->f_pos = offset; @@ -238,7 +240,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig) default: ret = -EINVAL; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return ret; } @@ -384,18 +386,18 @@ static int jsf_ioctl_program(void __user *arg) static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) { - lock_kernel(); + mutex_lock(&jsf_mutex); int error = -ENOTTY; void __user *argp = (void __user *)arg; if (!capable(CAP_SYS_ADMIN)) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EPERM; } switch (cmd) { case JSFLASH_IDENT: if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EFAULT; } break; @@ -407,7 +409,7 @@ static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) break; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return error; } @@ -418,17 +420,17 @@ static int jsf_mmap(struct file * file, struct vm_area_struct * vma) static int jsf_open(struct inode * inode, struct file * filp) { - lock_kernel(); + mutex_lock(&jsf_mutex); if (jsf0.base == 0) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -ENXIO; } if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { - unlock_kernel(); + mutex_unlock(&jsf_mutex); return -EBUSY; } - unlock_kernel(); + mutex_unlock(&jsf_mutex); return 0; /* XXX What security? */ } @@ -459,7 +461,7 @@ static int jsflash_init(void) { int rc; struct jsflash *jsf; - int node; + phandle node; char banner[128]; struct linux_prom_registers reg0;