diff options
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/rndis.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 20b15fcc9d49..d252015576fb 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/seq_file.h> | ||
31 | #include <linux/netdevice.h> | 32 | #include <linux/netdevice.h> |
32 | 33 | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
@@ -1294,14 +1295,11 @@ int rndis_rm_hdr(struct sk_buff *skb) | |||
1294 | 1295 | ||
1295 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1296 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1296 | 1297 | ||
1297 | static int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, | 1298 | static int rndis_proc_show(struct seq_file *m, void *v) |
1298 | void *data) | ||
1299 | { | 1299 | { |
1300 | char *out = page; | 1300 | rndis_params *param = m->private; |
1301 | int len; | ||
1302 | rndis_params *param = (rndis_params *) data; | ||
1303 | 1301 | ||
1304 | out += snprintf (out, count, | 1302 | seq_printf(m, |
1305 | "Config Nr. %d\n" | 1303 | "Config Nr. %d\n" |
1306 | "used : %s\n" | 1304 | "used : %s\n" |
1307 | "state : %s\n" | 1305 | "state : %s\n" |
@@ -1324,25 +1322,13 @@ static int rndis_proc_read (char *page, char **start, off_t off, int count, int | |||
1324 | (param->media_state) ? 0 : param->speed*100, | 1322 | (param->media_state) ? 0 : param->speed*100, |
1325 | (param->media_state) ? "disconnected" : "connected", | 1323 | (param->media_state) ? "disconnected" : "connected", |
1326 | param->vendorID, param->vendorDescr); | 1324 | param->vendorID, param->vendorDescr); |
1327 | 1325 | return 0; | |
1328 | len = out - page; | ||
1329 | len -= off; | ||
1330 | |||
1331 | if (len < count) { | ||
1332 | *eof = 1; | ||
1333 | if (len <= 0) | ||
1334 | return 0; | ||
1335 | } else | ||
1336 | len = count; | ||
1337 | |||
1338 | *start = page + off; | ||
1339 | return len; | ||
1340 | } | 1326 | } |
1341 | 1327 | ||
1342 | static int rndis_proc_write (struct file *file, const char __user *buffer, | 1328 | static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, |
1343 | unsigned long count, void *data) | 1329 | size_t count, loff_t *ppos) |
1344 | { | 1330 | { |
1345 | rndis_params *p = data; | 1331 | rndis_params *p = PDE(file->f_path.dentry->d_inode)->data; |
1346 | u32 speed = 0; | 1332 | u32 speed = 0; |
1347 | int i, fl_speed = 0; | 1333 | int i, fl_speed = 0; |
1348 | 1334 | ||
@@ -1384,6 +1370,20 @@ static int rndis_proc_write (struct file *file, const char __user *buffer, | |||
1384 | return count; | 1370 | return count; |
1385 | } | 1371 | } |
1386 | 1372 | ||
1373 | static int rndis_proc_open(struct inode *inode, struct file *file) | ||
1374 | { | ||
1375 | return single_open(file, rndis_proc_show, PDE(inode)->data); | ||
1376 | } | ||
1377 | |||
1378 | static const struct file_operations rndis_proc_fops = { | ||
1379 | .owner = THIS_MODULE, | ||
1380 | .open = rndis_proc_open, | ||
1381 | .read = seq_read, | ||
1382 | .llseek = seq_lseek, | ||
1383 | .release = single_release, | ||
1384 | .write = rndis_proc_write, | ||
1385 | }; | ||
1386 | |||
1387 | #define NAME_TEMPLATE "driver/rndis-%03d" | 1387 | #define NAME_TEMPLATE "driver/rndis-%03d" |
1388 | 1388 | ||
1389 | static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; | 1389 | static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; |
@@ -1401,7 +1401,9 @@ int __init rndis_init (void) | |||
1401 | 1401 | ||
1402 | sprintf (name, NAME_TEMPLATE, i); | 1402 | sprintf (name, NAME_TEMPLATE, i); |
1403 | if (!(rndis_connect_state [i] | 1403 | if (!(rndis_connect_state [i] |
1404 | = create_proc_entry (name, 0660, NULL))) | 1404 | = proc_create_data(name, 0660, NULL, |
1405 | &rndis_proc_fops, | ||
1406 | (void *)(rndis_per_dev_params + i)))) | ||
1405 | { | 1407 | { |
1406 | DBG("%s :remove entries", __func__); | 1408 | DBG("%s :remove entries", __func__); |
1407 | while (i) { | 1409 | while (i) { |
@@ -1411,11 +1413,6 @@ int __init rndis_init (void) | |||
1411 | DBG("\n"); | 1413 | DBG("\n"); |
1412 | return -EIO; | 1414 | return -EIO; |
1413 | } | 1415 | } |
1414 | |||
1415 | rndis_connect_state [i]->write_proc = rndis_proc_write; | ||
1416 | rndis_connect_state [i]->read_proc = rndis_proc_read; | ||
1417 | rndis_connect_state [i]->data = (void *) | ||
1418 | (rndis_per_dev_params + i); | ||
1419 | #endif | 1416 | #endif |
1420 | rndis_per_dev_params [i].confignr = i; | 1417 | rndis_per_dev_params [i].confignr = i; |
1421 | rndis_per_dev_params [i].used = 0; | 1418 | rndis_per_dev_params [i].used = 0; |