hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/usb/gadget/function/f_serial.c
....@@ -266,6 +266,24 @@
266266 .release = serial_attr_release,
267267 };
268268
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
+
269287 static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
270288 {
271289 return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
....@@ -274,6 +292,9 @@
274292 CONFIGFS_ATTR_RO(f_serial_, port_num);
275293
276294 static struct configfs_attribute *acm_attrs[] = {
295
+#ifdef CONFIG_U_SERIAL_CONSOLE
296
+ &f_serial_attr_console,
297
+#endif
277298 &f_serial_attr_port_num,
278299 NULL,
279300 };
....@@ -324,7 +345,25 @@
324345
325346 static void gser_unbind(struct usb_configuration *c, struct usb_function *f)
326347 {
348
+ struct f_gser *gser = func_to_gser(f);
349
+
350
+ /* Ensure port is disconnected before unbinding */
351
+ gserial_disconnect(&gser->port);
327352 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);
328367 }
329368
330369 static struct usb_function *gser_alloc(struct usb_function_instance *fi)
....@@ -348,6 +387,8 @@
348387 gser->port.func.set_alt = gser_set_alt;
349388 gser->port.func.disable = gser_disable;
350389 gser->port.func.free_func = gser_free;
390
+ gser->port.func.resume = gser_resume;
391
+ gser->port.func.suspend = gser_suspend;
351392
352393 return &gser->port.func;
353394 }