From 551c6efeb2a0a13c82b99bed6fc4036a24cf475e Mon Sep 17 00:00:00 2001 From: Will McVicker Date: Thu, 1 Aug 2024 13:02:38 -0700 Subject: [PATCH] ANDROID: Revert "usb: gadget: f_fs: Add the missing get_alt callback" This reverts the upstream commit 2f550553e23c8 ("usb: gadget: f_fs: Add the missing get_alt callback") [1] due to causing Pixel 6 to kernel panic when USB is disconnected. [1] https://lore.kernel.org/all/20240102123419.13491-1-hgajjar@de.adit-jv.com/ Bug: 356910732 Change-Id: I0d8ceddfd330785f29a8788698186fcffd6ee81e Signed-off-by: Will McVicker --- drivers/usb/gadget/function/f_fs.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 1f21459b1188..a057cbedf3c9 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -45,7 +45,6 @@ #include "configfs.h" #define FUNCTIONFS_MAGIC 0xa647361 /* Chosen by a honest dice roll ;) */ -#define MAX_ALT_SETTINGS 2 /* Allow up to 2 alt settings to be set. */ #define DMABUF_ENQUEUE_TIMEOUT_MS 5000 @@ -83,7 +82,6 @@ struct ffs_function { short *interfaces_nums; struct usb_function function; - int cur_alt[MAX_CONFIG_INTERFACES]; }; @@ -107,7 +105,6 @@ static int __must_check ffs_func_eps_enable(struct ffs_function *func); static int ffs_func_bind(struct usb_configuration *, struct usb_function *); static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned); -static int ffs_func_get_alt(struct usb_function *f, unsigned int intf); static void ffs_func_disable(struct usb_function *); static int ffs_func_setup(struct usb_function *, const struct usb_ctrlrequest *); @@ -3715,15 +3712,6 @@ static void ffs_reset_work(struct work_struct *work) ffs_data_reset(ffs); } -static int ffs_func_get_alt(struct usb_function *f, - unsigned int interface) -{ - struct ffs_function *func = ffs_func_from_usb(f); - int intf = ffs_func_revmap_intf(func, interface); - - return (intf < 0) ? intf : func->cur_alt[interface]; -} - static int ffs_func_set_alt(struct usb_function *f, unsigned interface, unsigned alt) { @@ -3731,9 +3719,6 @@ static int ffs_func_set_alt(struct usb_function *f, struct ffs_data *ffs = func->ffs; int ret = 0, intf; - if (alt > MAX_ALT_SETTINGS) - return -EINVAL; - if (alt != (unsigned)-1) { intf = ffs_func_revmap_intf(func, interface); if (intf < 0) @@ -3761,10 +3746,8 @@ static int ffs_func_set_alt(struct usb_function *f, ffs->func = func; ret = ffs_func_eps_enable(func); - if (ret >= 0) { + if (ret >= 0) ffs_event_add(ffs, FUNCTIONFS_ENABLE); - func->cur_alt[interface] = alt; - } return ret; } @@ -4091,7 +4074,6 @@ static struct usb_function *ffs_alloc(struct usb_function_instance *fi) func->function.bind = ffs_func_bind; func->function.unbind = ffs_func_unbind; func->function.set_alt = ffs_func_set_alt; - func->function.get_alt = ffs_func_get_alt; func->function.disable = ffs_func_disable; func->function.setup = ffs_func_setup; func->function.req_match = ffs_func_req_match;