From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: gregkh@linuxfoundation.org, hgajjar@de.adit-jv.com,
willmcvicker@google.com
Cc: paul@crapouillou.net, brauner@kernel.org,
christian.koenig@amd.com, jlayton@kernel.org, kees@kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
andre.draszik@linaro.org, peter.griffin@linaro.org,
Tudor Ambarus <tudor.ambarus@linaro.org>
Subject: [PATCH 2/2] usb: gadget: f_fs: pull out f->disable() from ffs_func_set_alt()
Date: Fri, 2 Aug 2024 14:04:28 +0000 [thread overview]
Message-ID: <20240802140428.2000312-3-tudor.ambarus@linaro.org> (raw)
In-Reply-To: <20240802140428.2000312-1-tudor.ambarus@linaro.org>
The ``alt`` parameter was used as a way to differentiate between
f->disable() and f->set_alt(). As the code paths diverge quite a bit,
pull out the f->disable() code from ffs_func_set_alt(), everything will
become clearer and less error prone. No change in functionality
intended.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/usb/gadget/function/f_fs.c | 36 ++++++++++++++++++------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 0bfed1741b3e..e0ceaa721949 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3731,14 +3731,12 @@ static int ffs_func_set_alt(struct usb_function *f,
struct ffs_data *ffs = func->ffs;
int ret = 0, intf;
- if (alt != (unsigned)-1) {
- if (alt > MAX_ALT_SETTINGS)
- return -EINVAL;
+ if (alt > MAX_ALT_SETTINGS)
+ return -EINVAL;
- intf = ffs_func_revmap_intf(func, interface);
- if (intf < 0)
- return intf;
- }
+ intf = ffs_func_revmap_intf(func, interface);
+ if (intf < 0)
+ return intf;
if (ffs->func)
ffs_func_eps_disable(ffs->func);
@@ -3753,12 +3751,6 @@ static int ffs_func_set_alt(struct usb_function *f,
if (ffs->state != FFS_ACTIVE)
return -ENODEV;
- if (alt == (unsigned)-1) {
- ffs->func = NULL;
- ffs_event_add(ffs, FUNCTIONFS_DISABLE);
- return 0;
- }
-
ffs->func = func;
ret = ffs_func_eps_enable(func);
if (ret >= 0) {
@@ -3770,7 +3762,23 @@ static int ffs_func_set_alt(struct usb_function *f,
static void ffs_func_disable(struct usb_function *f)
{
- ffs_func_set_alt(f, 0, (unsigned)-1);
+ struct ffs_function *func = ffs_func_from_usb(f);
+ struct ffs_data *ffs = func->ffs;
+
+ if (ffs->func)
+ ffs_func_eps_disable(ffs->func);
+
+ if (ffs->state == FFS_DEACTIVATED) {
+ ffs->state = FFS_CLOSING;
+ INIT_WORK(&ffs->reset_work, ffs_reset_work);
+ schedule_work(&ffs->reset_work);
+ return;
+ }
+
+ if (ffs->state == FFS_ACTIVE) {
+ ffs->func = NULL;
+ ffs_event_add(ffs, FUNCTIONFS_DISABLE);
+ }
}
static int ffs_func_setup(struct usb_function *f,
--
2.46.0.rc2.264.g509ed76dc8-goog
prev parent reply other threads:[~2024-08-02 14:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 14:04 [PATCH 0/2] usb: gadget: f_fs: restore ffs_func_disable() functionality Tudor Ambarus
2024-08-02 14:04 ` [PATCH 1/2] " Tudor Ambarus
2024-08-07 10:40 ` Greg KH
2024-08-02 14:04 ` Tudor Ambarus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240802140428.2000312-3-tudor.ambarus@linaro.org \
--to=tudor.ambarus@linaro.org \
--cc=andre.draszik@linaro.org \
--cc=brauner@kernel.org \
--cc=christian.koenig@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=hgajjar@de.adit-jv.com \
--cc=jlayton@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=peter.griffin@linaro.org \
--cc=willmcvicker@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox