diff options
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
-rw-r--r-- | drivers/usb/mon/mon_bin.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 0af11a66207c..c03dfd7a9d36 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * This is a binary format reader. | 4 | * This is a binary format reader. |
5 | * | 5 | * |
6 | * Copyright (C) 2006 Paolo Abeni (paolo.abeni@email.it) | 6 | * Copyright (C) 2006 Paolo Abeni (paolo.abeni@email.it) |
7 | * Copyright (C) 2006 Pete Zaitcev (zaitcev@redhat.com) | 7 | * Copyright (C) 2006,2007 Pete Zaitcev (zaitcev@redhat.com) |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
@@ -172,6 +172,7 @@ static inline struct mon_bin_hdr *MON_OFF2HDR(const struct mon_reader_bin *rp, | |||
172 | 172 | ||
173 | #define MON_RING_EMPTY(rp) ((rp)->b_cnt == 0) | 173 | #define MON_RING_EMPTY(rp) ((rp)->b_cnt == 0) |
174 | 174 | ||
175 | static struct class *mon_bin_class; | ||
175 | static dev_t mon_bin_dev0; | 176 | static dev_t mon_bin_dev0; |
176 | static struct cdev mon_bin_cdev; | 177 | static struct cdev mon_bin_cdev; |
177 | 178 | ||
@@ -1144,10 +1145,38 @@ static void mon_free_buff(struct mon_pgmap *map, int npages) | |||
1144 | free_page((unsigned long) map[n].ptr); | 1145 | free_page((unsigned long) map[n].ptr); |
1145 | } | 1146 | } |
1146 | 1147 | ||
1148 | int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus) | ||
1149 | { | ||
1150 | struct device *dev; | ||
1151 | unsigned minor = ubus? ubus->busnum: 0; | ||
1152 | |||
1153 | if (minor >= MON_BIN_MAX_MINOR) | ||
1154 | return 0; | ||
1155 | |||
1156 | dev = device_create(mon_bin_class, ubus? ubus->controller: NULL, | ||
1157 | MKDEV(MAJOR(mon_bin_dev0), minor), "usbmon%d", minor); | ||
1158 | if (IS_ERR(dev)) | ||
1159 | return 0; | ||
1160 | |||
1161 | mbus->classdev = dev; | ||
1162 | return 1; | ||
1163 | } | ||
1164 | |||
1165 | void mon_bin_del(struct mon_bus *mbus) | ||
1166 | { | ||
1167 | device_destroy(mon_bin_class, mbus->classdev->devt); | ||
1168 | } | ||
1169 | |||
1147 | int __init mon_bin_init(void) | 1170 | int __init mon_bin_init(void) |
1148 | { | 1171 | { |
1149 | int rc; | 1172 | int rc; |
1150 | 1173 | ||
1174 | mon_bin_class = class_create(THIS_MODULE, "usbmon"); | ||
1175 | if (IS_ERR(mon_bin_class)) { | ||
1176 | rc = PTR_ERR(mon_bin_class); | ||
1177 | goto err_class; | ||
1178 | } | ||
1179 | |||
1151 | rc = alloc_chrdev_region(&mon_bin_dev0, 0, MON_BIN_MAX_MINOR, "usbmon"); | 1180 | rc = alloc_chrdev_region(&mon_bin_dev0, 0, MON_BIN_MAX_MINOR, "usbmon"); |
1152 | if (rc < 0) | 1181 | if (rc < 0) |
1153 | goto err_dev; | 1182 | goto err_dev; |
@@ -1164,6 +1193,8 @@ int __init mon_bin_init(void) | |||
1164 | err_add: | 1193 | err_add: |
1165 | unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR); | 1194 | unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR); |
1166 | err_dev: | 1195 | err_dev: |
1196 | class_destroy(mon_bin_class); | ||
1197 | err_class: | ||
1167 | return rc; | 1198 | return rc; |
1168 | } | 1199 | } |
1169 | 1200 | ||
@@ -1171,4 +1202,5 @@ void mon_bin_exit(void) | |||
1171 | { | 1202 | { |
1172 | cdev_del(&mon_bin_cdev); | 1203 | cdev_del(&mon_bin_cdev); |
1173 | unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR); | 1204 | unregister_chrdev_region(mon_bin_dev0, MON_BIN_MAX_MINOR); |
1205 | class_destroy(mon_bin_class); | ||
1174 | } | 1206 | } |