1 --- a/drivers/ps3/ps3av.c 2013-03-07 22:13:51.309374686 +0100
2 +++ b/drivers/ps3/ps3av.c 2013-03-07 22:14:15.449376092 +0100
4 #include <linux/ioctl.h>
6 #include <linux/slab.h>
7 +#include <linux/uaccess.h>
8 +#include <linux/miscdevice.h>
10 #include <asm/firmware.h>
11 #include <asm/ps3av.h>
13 #define BUFSIZE 4096 /* vuart buf size */
14 #define PS3AV_BUF_SIZE 512 /* max packet size */
16 +#define DEVICE_NAME "ps3avmngr"
20 static int timeout = 5000; /* in msec ( 5 sec ) */
22 struct ps3av_reply_hdr reply_hdr;
23 u8 raw[PS3AV_BUF_SIZE];
25 + struct miscdevice misc;
32 EXPORT_SYMBOL_GPL(ps3av_audio_mute);
34 +static ssize_t ps3av_misc_read(struct file *file, char __user *usrbuf,
35 + size_t count, loff_t *pos)
40 + buf = kmalloc(count, GFP_KERNEL);
44 + result = ps3_vuart_read(ps3av->dev, buf, count);
48 + if (copy_to_user(usrbuf, buf, count)) {
62 +static ssize_t ps3av_misc_write(struct file *file, const char __user *usrbuf,
63 + size_t count, loff_t *pos)
68 + buf = kmalloc(count, GFP_KERNEL);
72 + if (copy_from_user(buf, usrbuf, count)) {
77 + result = ps3_vuart_write(ps3av->dev, buf, count);
90 +static const struct file_operations ps3av_misc_fops = {
91 + .owner = THIS_MODULE,
92 + .read = ps3av_misc_read,
93 + .write = ps3av_misc_write,
96 static int ps3av_probe(struct ps3_system_bus_device *dev)
99 @@ -1003,11 +1071,34 @@
100 ps3av->ps3av_mode = id;
101 mutex_unlock(&ps3av->mutex);
103 + ps3av->misc.parent = &dev->core;
104 + ps3av->misc.minor = MISC_DYNAMIC_MINOR,
105 + ps3av->misc.name = DEVICE_NAME,
106 + ps3av->misc.fops = &ps3av_misc_fops,
108 + res = misc_register(&ps3av->misc);
110 + dev_err(&dev->core, "%s:%u: misc_register failed %d\n",
111 + __func__, __LINE__, res);
115 + ps3av->misc_ok = 1;
117 + dev_info(&dev->core, "%s:%u: registered misc device %d\n",
118 + __func__, __LINE__, ps3av->misc.minor);
122 dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__);
128 + if (ps3av->misc_ok)
129 + misc_deregister(&ps3av->misc);
134 @@ -1017,6 +1108,9 @@
136 dev_dbg(&dev->core, " -> %s:%d\n", __func__, __LINE__);
138 + if (ps3av->misc_ok)
139 + misc_deregister(&ps3av->misc);
143 destroy_workqueue(ps3av->wq);