aboutsummaryrefslogtreecommitdiff
path: root/drivers/sbus/char/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sbus/char/flash.c')
-rw-r--r--drivers/sbus/char/flash.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
index 41083472ff4..25c738e9ef1 100644
--- a/drivers/sbus/char/flash.c
+++ b/drivers/sbus/char/flash.c
@@ -7,22 +7,20 @@
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
-#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/mm.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/upa.h>
+static DEFINE_MUTEX(flash_mutex);
static DEFINE_SPINLOCK(flash_lock);
static struct {
unsigned long read_base; /* Physical read address */
@@ -81,7 +79,7 @@ flash_mmap(struct file *file, struct vm_area_struct *vma)
static long long
flash_llseek(struct file *file, long long offset, int origin)
{
- lock_kernel();
+ mutex_lock(&flash_mutex);
switch (origin) {
case 0:
file->f_pos = offset;
@@ -95,10 +93,10 @@ flash_llseek(struct file *file, long long offset, int origin)
file->f_pos = flash.read_size;
break;
default:
- unlock_kernel();
+ mutex_unlock(&flash_mutex);
return -EINVAL;
}
- unlock_kernel();
+ mutex_unlock(&flash_mutex);
return file->f_pos;
}
@@ -106,9 +104,9 @@ static ssize_t
flash_read(struct file * file, char __user * buf,
size_t count, loff_t *ppos)
{
- unsigned long p = file->f_pos;
+ loff_t p = *ppos;
int i;
-
+
if (count > flash.read_size - p)
count = flash.read_size - p;
@@ -119,20 +117,20 @@ flash_read(struct file * file, char __user * buf,
buf++;
}
- file->f_pos += count;
+ *ppos += count;
return count;
}
static int
flash_open(struct inode *inode, struct file *file)
{
- lock_kernel();
+ mutex_lock(&flash_mutex);
if (test_and_set_bit(0, (void *)&flash.busy) != 0) {
- unlock_kernel();
+ mutex_unlock(&flash_mutex);
return -EBUSY;
}
- unlock_kernel();
+ mutex_unlock(&flash_mutex);
return 0;
}
@@ -160,10 +158,9 @@ static const struct file_operations flash_fops = {
static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops };
-static int __devinit flash_probe(struct of_device *op,
- const struct of_device_id *match)
+static int flash_probe(struct platform_device *op)
{
- struct device_node *dp = op->node;
+ struct device_node *dp = op->dev.of_node;
struct device_node *parent;
parent = dp->parent;
@@ -185,14 +182,14 @@ static int __devinit flash_probe(struct of_device *op,
flash.busy = 0;
printk(KERN_INFO "%s: OBP Flash, RD %lx[%lx] WR %lx[%lx]\n",
- op->node->full_name,
+ op->dev.of_node->full_name,
flash.read_base, flash.read_size,
flash.write_base, flash.write_size);
return misc_register(&flash_dev);
}
-static int __devexit flash_remove(struct of_device *op)
+static int flash_remove(struct platform_device *op)
{
misc_deregister(&flash_dev);
@@ -207,23 +204,16 @@ static const struct of_device_id flash_match[] = {
};
MODULE_DEVICE_TABLE(of, flash_match);
-static struct of_platform_driver flash_driver = {
- .name = "flash",
- .match_table = flash_match,
+static struct platform_driver flash_driver = {
+ .driver = {
+ .name = "flash",
+ .owner = THIS_MODULE,
+ .of_match_table = flash_match,
+ },
.probe = flash_probe,
- .remove = __devexit_p(flash_remove),
+ .remove = flash_remove,
};
-static int __init flash_init(void)
-{
- return of_register_driver(&flash_driver, &of_bus_type);
-}
-
-static void __exit flash_cleanup(void)
-{
- of_unregister_driver(&flash_driver);
-}
+module_platform_driver(flash_driver);
-module_init(flash_init);
-module_exit(flash_cleanup);
MODULE_LICENSE("GPL");