ANDROID: usb: gadget: f_accessory: update to usb_gstrings_attach

For AOA re-connection, since the string ID of accessory has been changed
into a non-zero value, the f_accessory failes to call `usb_string_id` to
increment `next_string_id`. This makes the ADB interface display a wrong
name.

Bug: 270044830
Test: CTS Verifier: USB Accessory Test
Test: manual test
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Change-Id: I807164588e80b28065e8715591a100392b04d3de
This commit is contained in:
Kuen-Han Tsai
2023-03-03 12:47:59 +08:00
committed by Kuen-Han (John) Tsai
parent 0fd1c2a78d
commit bef41f506f

View File

@@ -29,6 +29,7 @@
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <linux/kref.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/file.h>
@@ -1101,6 +1102,7 @@ __acc_function_bind(struct usb_configuration *c,
struct usb_function *f, bool configfs)
{
struct usb_composite_dev *cdev = c->cdev;
struct usb_string *us;
struct acc_dev *dev = func_to_dev(f);
int id;
int ret;
@@ -1108,13 +1110,11 @@ __acc_function_bind(struct usb_configuration *c,
DBG(cdev, "acc_function_bind dev: %p\n", dev);
if (configfs) {
if (acc_string_defs[INTERFACE_STRING_INDEX].id == 0) {
ret = usb_string_id(c->cdev);
if (ret < 0)
return ret;
acc_string_defs[INTERFACE_STRING_INDEX].id = ret;
acc_interface_desc.iInterface = ret;
}
us = usb_gstrings_attach(cdev, acc_strings, ARRAY_SIZE(acc_string_defs));
if (IS_ERR(us))
return PTR_ERR(us);
ret = us[INTERFACE_STRING_INDEX].id;
acc_interface_desc.iInterface = ret;
dev->cdev = c->cdev;
}
ret = hid_register_driver(&acc_hid_driver);