17 #include <linux/slab.h>
18 #include <linux/kernel.h>
19 #include <linux/device.h>
20 #include <linux/module.h>
54 #define OBEX_CTRL_IDX 0
55 #define OBEX_DATA_IDX 1
57 static struct usb_string obex_string_defs[] = {
65 .strings = obex_string_defs,
76 .bLength =
sizeof(obex_control_intf),
87 .
bLength =
sizeof(obex_data_nop_intf),
97 .
bLength =
sizeof(obex_data_intf),
107 .
bLength =
sizeof(obex_cdc_header_desc),
114 .
bLength =
sizeof(obex_cdc_union_desc),
196 struct f_obex *obex = func_to_obex(f);
203 DBG(cdev,
"reset obex ttyGS%d control\n", obex->
port_num);
205 }
else if (intf == obex->
data_id) {
209 if (obex->
port.in->driver_data) {
214 if (!obex->
port.in->desc || !obex->
port.out->desc) {
227 DBG(cdev,
"activate obex ttyGS%d\n", obex->
port_num);
240 static int obex_get_alt(
struct usb_function *f,
unsigned intf)
242 struct f_obex *obex = func_to_obex(f);
247 return obex->
port.in->driver_data ? 1 : 0;
252 struct f_obex *obex = func_to_obex(f);
255 DBG(cdev,
"obex ttyGS%d disable\n", obex->
port_num);
261 static void obex_connect(
struct gserial *g)
263 struct f_obex *obex = port_to_obex(g);
272 DBG(cdev,
"obex ttyGS%d function activate --> %d\n",
276 static void obex_disconnect(
struct gserial *g)
278 struct f_obex *obex = port_to_obex(g);
287 DBG(cdev,
"obex ttyGS%d function deactivate --> %d\n",
297 struct f_obex *obex = func_to_obex(f);
308 obex_control_intf.bInterfaceNumber =
status;
309 obex_cdc_union_desc.bMasterInterface0 =
status;
316 obex_data_nop_intf.bInterfaceNumber =
status;
317 obex_data_intf.bInterfaceNumber =
status;
318 obex_cdc_union_desc.bSlaveInterface0 =
status;
341 if (gadget_is_dualspeed(c->
cdev->gadget)) {
343 obex_hs_ep_in_desc.bEndpointAddress =
344 obex_fs_ep_in_desc.bEndpointAddress;
345 obex_hs_ep_out_desc.bEndpointAddress =
346 obex_fs_ep_out_desc.bEndpointAddress;
357 WARNING(cdev,
"obex ttyGS%d: can't prevent enumeration, %d\n",
363 DBG(cdev,
"obex ttyGS%d: %s speed IN/%s OUT/%s\n",
365 gadget_is_dualspeed(c->
cdev->gadget) ?
"dual" :
"full",
366 obex->
port.in->name, obex->
port.out->name);
377 ERROR(cdev,
"%s/%p: can't bind, err %d\n", f->
name, f, status);
385 if (gadget_is_dualspeed(c->
cdev->gadget))
388 kfree(func_to_obex(f));
399 if (!gadget_supports_altsettings(c->
cdev->gadget))
423 if (!can_support_obex(c))
433 obex_control_intf.iInterface =
status;
440 obex_data_nop_intf.iInterface =
441 obex_data_intf.iInterface =
status;
451 obex->
port.connect = obex_connect;
452 obex->
port.disconnect = obex_disconnect;
454 obex->
port.func.name =
"obex";
455 obex->
port.func.strings = obex_strings;
457 obex->
port.func.bind = obex_bind;
458 obex->
port.func.unbind = obex_unbind;
459 obex->
port.func.set_alt = obex_set_alt;
460 obex->
port.func.get_alt = obex_get_alt;
461 obex->
port.func.disable = obex_disable;