| .. | .. |
|---|
| 266 | 266 | .release = serial_attr_release, |
|---|
| 267 | 267 | }; |
|---|
| 268 | 268 | |
|---|
| 269 | +#ifdef CONFIG_U_SERIAL_CONSOLE |
|---|
| 270 | + |
|---|
| 271 | +static ssize_t f_serial_console_store(struct config_item *item, |
|---|
| 272 | + const char *page, size_t count) |
|---|
| 273 | +{ |
|---|
| 274 | + return gserial_set_console(to_f_serial_opts(item)->port_num, |
|---|
| 275 | + page, count); |
|---|
| 276 | +} |
|---|
| 277 | + |
|---|
| 278 | +static ssize_t f_serial_console_show(struct config_item *item, char *page) |
|---|
| 279 | +{ |
|---|
| 280 | + return gserial_get_console(to_f_serial_opts(item)->port_num, page); |
|---|
| 281 | +} |
|---|
| 282 | + |
|---|
| 283 | +CONFIGFS_ATTR(f_serial_, console); |
|---|
| 284 | + |
|---|
| 285 | +#endif /* CONFIG_U_SERIAL_CONSOLE */ |
|---|
| 286 | + |
|---|
| 269 | 287 | static ssize_t f_serial_port_num_show(struct config_item *item, char *page) |
|---|
| 270 | 288 | { |
|---|
| 271 | 289 | return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); |
|---|
| .. | .. |
|---|
| 274 | 292 | CONFIGFS_ATTR_RO(f_serial_, port_num); |
|---|
| 275 | 293 | |
|---|
| 276 | 294 | static struct configfs_attribute *acm_attrs[] = { |
|---|
| 295 | +#ifdef CONFIG_U_SERIAL_CONSOLE |
|---|
| 296 | + &f_serial_attr_console, |
|---|
| 297 | +#endif |
|---|
| 277 | 298 | &f_serial_attr_port_num, |
|---|
| 278 | 299 | NULL, |
|---|
| 279 | 300 | }; |
|---|
| .. | .. |
|---|
| 324 | 345 | |
|---|
| 325 | 346 | static void gser_unbind(struct usb_configuration *c, struct usb_function *f) |
|---|
| 326 | 347 | { |
|---|
| 348 | + struct f_gser *gser = func_to_gser(f); |
|---|
| 349 | + |
|---|
| 350 | + /* Ensure port is disconnected before unbinding */ |
|---|
| 351 | + gserial_disconnect(&gser->port); |
|---|
| 327 | 352 | usb_free_all_descriptors(f); |
|---|
| 353 | +} |
|---|
| 354 | + |
|---|
| 355 | +static void gser_resume(struct usb_function *f) |
|---|
| 356 | +{ |
|---|
| 357 | + struct f_gser *gser = func_to_gser(f); |
|---|
| 358 | + |
|---|
| 359 | + gserial_resume(&gser->port); |
|---|
| 360 | +} |
|---|
| 361 | + |
|---|
| 362 | +static void gser_suspend(struct usb_function *f) |
|---|
| 363 | +{ |
|---|
| 364 | + struct f_gser *gser = func_to_gser(f); |
|---|
| 365 | + |
|---|
| 366 | + gserial_suspend(&gser->port); |
|---|
| 328 | 367 | } |
|---|
| 329 | 368 | |
|---|
| 330 | 369 | static struct usb_function *gser_alloc(struct usb_function_instance *fi) |
|---|
| .. | .. |
|---|
| 348 | 387 | gser->port.func.set_alt = gser_set_alt; |
|---|
| 349 | 388 | gser->port.func.disable = gser_disable; |
|---|
| 350 | 389 | gser->port.func.free_func = gser_free; |
|---|
| 390 | + gser->port.func.resume = gser_resume; |
|---|
| 391 | + gser->port.func.suspend = gser_suspend; |
|---|
| 351 | 392 | |
|---|
| 352 | 393 | return &gser->port.func; |
|---|
| 353 | 394 | } |
|---|