aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/f_fs.c114
-rw-r--r--drivers/usb/gadget/u_fs.h2
2 files changed, 0 insertions, 116 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 8d318eaaaf20..9c8c74c25f1e 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -97,19 +97,12 @@ static struct ffs_function *ffs_func_from_usb(struct usb_function *f)
97 return container_of(f, struct ffs_function, function); 97 return container_of(f, struct ffs_function, function);
98} 98}
99 99
100#ifdef USB_FFS_INCLUDED
101static void ffs_func_free(struct ffs_function *func);
102#endif
103 100
104static void ffs_func_eps_disable(struct ffs_function *func); 101static void ffs_func_eps_disable(struct ffs_function *func);
105static int __must_check ffs_func_eps_enable(struct ffs_function *func); 102static int __must_check ffs_func_eps_enable(struct ffs_function *func);
106 103
107static int ffs_func_bind(struct usb_configuration *, 104static int ffs_func_bind(struct usb_configuration *,
108 struct usb_function *); 105 struct usb_function *);
109#ifdef USB_FFS_INCLUDED
110static void old_ffs_func_unbind(struct usb_configuration *,
111 struct usb_function *);
112#endif
113static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned); 106static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned);
114static void ffs_func_disable(struct usb_function *); 107static void ffs_func_disable(struct usb_function *);
115static int ffs_func_setup(struct usb_function *, 108static int ffs_func_setup(struct usb_function *,
@@ -165,9 +158,7 @@ ffs_sb_create_file(struct super_block *sb, const char *name, void *data,
165/* Devices management *******************************************************/ 158/* Devices management *******************************************************/
166 159
167DEFINE_MUTEX(ffs_lock); 160DEFINE_MUTEX(ffs_lock);
168#ifndef USB_FFS_INCLUDED
169EXPORT_SYMBOL(ffs_lock); 161EXPORT_SYMBOL(ffs_lock);
170#endif
171 162
172static struct ffs_dev *ffs_find_dev(const char *name); 163static struct ffs_dev *ffs_find_dev(const char *name);
173static void *ffs_acquire_dev(const char *dev_name); 164static void *ffs_acquire_dev(const char *dev_name);
@@ -1303,75 +1294,6 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)
1303 kfree(epfiles); 1294 kfree(epfiles);
1304} 1295}
1305 1296
1306#ifdef USB_FFS_INCLUDED
1307
1308static int functionfs_bind_config(struct usb_composite_dev *cdev,
1309 struct usb_configuration *c,
1310 struct ffs_data *ffs)
1311{
1312 struct ffs_function *func;
1313 int ret;
1314
1315 ENTER();
1316
1317 func = kzalloc(sizeof *func, GFP_KERNEL);
1318 if (unlikely(!func))
1319 return -ENOMEM;
1320
1321 func->function.name = "Function FS Gadget";
1322 func->function.strings = ffs->stringtabs;
1323
1324 func->function.bind = ffs_func_bind;
1325 func->function.unbind = old_ffs_func_unbind;
1326 func->function.set_alt = ffs_func_set_alt;
1327 func->function.disable = ffs_func_disable;
1328 func->function.setup = ffs_func_setup;
1329 func->function.suspend = ffs_func_suspend;
1330 func->function.resume = ffs_func_resume;
1331
1332 func->conf = c;
1333 func->gadget = cdev->gadget;
1334 func->ffs = ffs;
1335 ffs_data_get(ffs);
1336
1337 ret = usb_add_function(c, &func->function);
1338 if (unlikely(ret))
1339 ffs_func_free(func);
1340
1341 return ret;
1342}
1343
1344static void ffs_func_free(struct ffs_function *func)
1345{
1346 struct ffs_ep *ep = func->eps;
1347 unsigned count = func->ffs->eps_count;
1348 unsigned long flags;
1349
1350 ENTER();
1351
1352 /* cleanup after autoconfig */
1353 spin_lock_irqsave(&func->ffs->eps_lock, flags);
1354 do {
1355 if (ep->ep && ep->req)
1356 usb_ep_free_request(ep->ep, ep->req);
1357 ep->req = NULL;
1358 ++ep;
1359 } while (--count);
1360 spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
1361
1362 ffs_data_put(func->ffs);
1363
1364 kfree(func->eps);
1365 /*
1366 * eps and interfaces_nums are allocated in the same chunk so
1367 * only one free is required. Descriptors are also allocated
1368 * in the same chunk.
1369 */
1370
1371 kfree(func);
1372}
1373
1374#endif
1375 1297
1376static void ffs_func_eps_disable(struct ffs_function *func) 1298static void ffs_func_eps_disable(struct ffs_function *func)
1377{ 1299{
@@ -2035,7 +1957,6 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type type, u8 *valuep,
2035 return 0; 1957 return 0;
2036} 1958}
2037 1959
2038#ifndef USB_FFS_INCLUDED
2039static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f, 1960static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
2040 struct usb_configuration *c) 1961 struct usb_configuration *c)
2041{ 1962{
@@ -2084,7 +2005,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
2084 2005
2085 return ffs_opts; 2006 return ffs_opts;
2086} 2007}
2087#endif
2088 2008
2089static int _ffs_func_bind(struct usb_configuration *c, 2009static int _ffs_func_bind(struct usb_configuration *c,
2090 struct usb_function *f) 2010 struct usb_function *f)
@@ -2190,12 +2110,10 @@ error:
2190static int ffs_func_bind(struct usb_configuration *c, 2110static int ffs_func_bind(struct usb_configuration *c,
2191 struct usb_function *f) 2111 struct usb_function *f)
2192{ 2112{
2193#ifndef USB_FFS_INCLUDED
2194 struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c); 2113 struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
2195 2114
2196 if (IS_ERR(ffs_opts)) 2115 if (IS_ERR(ffs_opts))
2197 return PTR_ERR(ffs_opts); 2116 return PTR_ERR(ffs_opts);
2198#endif
2199 2117
2200 return _ffs_func_bind(c, f); 2118 return _ffs_func_bind(c, f);
2201} 2119}
@@ -2203,28 +2121,6 @@ static int ffs_func_bind(struct usb_configuration *c,
2203 2121
2204/* Other USB function hooks *************************************************/ 2122/* Other USB function hooks *************************************************/
2205 2123
2206#ifdef USB_FFS_INCLUDED
2207
2208static void old_ffs_func_unbind(struct usb_configuration *c,
2209 struct usb_function *f)
2210{
2211 struct ffs_function *func = ffs_func_from_usb(f);
2212 struct ffs_data *ffs = func->ffs;
2213
2214 ENTER();
2215
2216 if (ffs->func == func) {
2217 ffs_func_eps_disable(func);
2218 ffs->func = NULL;
2219 }
2220
2221 ffs_event_add(ffs, FUNCTIONFS_UNBIND);
2222
2223 ffs_func_free(func);
2224}
2225
2226#endif
2227
2228static int ffs_func_set_alt(struct usb_function *f, 2124static int ffs_func_set_alt(struct usb_function *f,
2229 unsigned interface, unsigned alt) 2125 unsigned interface, unsigned alt)
2230{ 2126{
@@ -2401,8 +2297,6 @@ static struct ffs_dev *ffs_find_dev(const char *name)
2401 2297
2402/* Function registration interface ******************************************/ 2298/* Function registration interface ******************************************/
2403 2299
2404#ifndef USB_FFS_INCLUDED
2405
2406static void ffs_free_inst(struct usb_function_instance *f) 2300static void ffs_free_inst(struct usb_function_instance *f)
2407{ 2301{
2408 struct f_fs_opts *opts; 2302 struct f_fs_opts *opts;
@@ -2507,8 +2401,6 @@ static struct usb_function *ffs_alloc(struct usb_function_instance *fi)
2507 return &func->function; 2401 return &func->function;
2508} 2402}
2509 2403
2510#endif
2511
2512/* 2404/*
2513 * ffs_lock must be taken by the caller of this function 2405 * ffs_lock must be taken by the caller of this function
2514 */ 2406 */
@@ -2567,9 +2459,7 @@ int ffs_name_dev(struct ffs_dev *dev, const char *name)
2567 2459
2568 return ret; 2460 return ret;
2569} 2461}
2570#ifndef USB_FFS_INCLUDED
2571EXPORT_SYMBOL(ffs_name_dev); 2462EXPORT_SYMBOL(ffs_name_dev);
2572#endif
2573 2463
2574int ffs_single_dev(struct ffs_dev *dev) 2464int ffs_single_dev(struct ffs_dev *dev)
2575{ 2465{
@@ -2586,9 +2476,7 @@ int ffs_single_dev(struct ffs_dev *dev)
2586 ffs_dev_unlock(); 2476 ffs_dev_unlock();
2587 return ret; 2477 return ret;
2588} 2478}
2589#ifndef USB_FFS_INCLUDED
2590EXPORT_SYMBOL(ffs_single_dev); 2479EXPORT_SYMBOL(ffs_single_dev);
2591#endif
2592 2480
2593/* 2481/*
2594 * ffs_lock must be taken by the caller of this function 2482 * ffs_lock must be taken by the caller of this function
@@ -2719,8 +2607,6 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len)
2719 return data; 2607 return data;
2720} 2608}
2721 2609
2722#ifndef USB_FFS_INCLUDED
2723DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc); 2610DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc);
2724MODULE_LICENSE("GPL"); 2611MODULE_LICENSE("GPL");
2725MODULE_AUTHOR("Michal Nazarewicz"); 2612MODULE_AUTHOR("Michal Nazarewicz");
2726#endif
diff --git a/drivers/usb/gadget/u_fs.h b/drivers/usb/gadget/u_fs.h
index d60a9ddc0332..09313750f913 100644
--- a/drivers/usb/gadget/u_fs.h
+++ b/drivers/usb/gadget/u_fs.h
@@ -249,7 +249,6 @@ struct ffs_data {
249}; 249};
250 250
251 251
252#ifndef USB_FFS_INCLUDED
253struct f_fs_opts { 252struct f_fs_opts {
254 struct usb_function_instance func_inst; 253 struct usb_function_instance func_inst;
255 struct ffs_dev *dev; 254 struct ffs_dev *dev;
@@ -261,6 +260,5 @@ static inline struct f_fs_opts *to_f_fs_opts(struct usb_function_instance *fi)
261{ 260{
262 return container_of(fi, struct f_fs_opts, func_inst); 261 return container_of(fi, struct f_fs_opts, func_inst);
263} 262}
264#endif
265 263
266#endif /* U_FFS_H */ 264#endif /* U_FFS_H */