summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-27 17:05:59 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-10 18:14:34 +0300
commit8704fd73bf5658bf4b827643f7f526481082d83f (patch)
tree28e5ac224166931d4527a375432aa6e94e585419 /drivers/usb/gadget
parenta353397b0d5dfa3c99b372505db3378fc919c6c6 (diff)
downloadlinux-8704fd73bf5658bf4b827643f7f526481082d83f.tar.xz
USB: gadget: f_fs: remove likely/unlikely
They are used way too often in this file, in some ways that are actually wrong. Almost all of these are already known by the compiler and CPU so just remove them all as none of these should be on any "hot paths" where it actually matters. Cc: Felipe Balbi <balbi@kernel.org> Reported-by: Peter Chen <peter.chen@nxp.com> Reviewed-by: Peter Chen <peter.chen@nxp.com> Link: https://lore.kernel.org/r/20201127140559.381351-6-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/function/f_fs.c177
1 files changed, 88 insertions, 89 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 78c003fb05fd..801a8b668a35 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -296,11 +296,11 @@ static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len)
reinit_completion(&ffs->ep0req_completion);
ret = usb_ep_queue(ffs->gadget->ep0, req, GFP_ATOMIC);
- if (unlikely(ret < 0))
+ if (ret < 0)
return ret;
ret = wait_for_completion_interruptible(&ffs->ep0req_completion);
- if (unlikely(ret)) {
+ if (ret) {
usb_ep_dequeue(ffs->gadget->ep0, req);
return -EINTR;
}
@@ -337,7 +337,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
/* Acquire mutex */
ret = ffs_mutex_lock(&ffs->mutex, file->f_flags & O_NONBLOCK);
- if (unlikely(ret < 0))
+ if (ret < 0)
return ret;
/* Check state */
@@ -345,7 +345,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
case FFS_READ_DESCRIPTORS:
case FFS_READ_STRINGS:
/* Copy data */
- if (unlikely(len < 16)) {
+ if (len < 16) {
ret = -EINVAL;
break;
}
@@ -360,7 +360,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
if (ffs->state == FFS_READ_DESCRIPTORS) {
pr_info("read descriptors\n");
ret = __ffs_data_got_descs(ffs, data, len);
- if (unlikely(ret < 0))
+ if (ret < 0)
break;
ffs->state = FFS_READ_STRINGS;
@@ -368,11 +368,11 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
} else {
pr_info("read strings\n");
ret = __ffs_data_got_strings(ffs, data, len);
- if (unlikely(ret < 0))
+ if (ret < 0)
break;
ret = ffs_epfiles_create(ffs);
- if (unlikely(ret)) {
+ if (ret) {
ffs->state = FFS_CLOSING;
break;
}
@@ -381,7 +381,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
mutex_unlock(&ffs->mutex);
ret = ffs_ready(ffs);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
ffs->state = FFS_CLOSING;
return ret;
}
@@ -495,7 +495,7 @@ static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf,
spin_unlock_irq(&ffs->ev.waitq.lock);
mutex_unlock(&ffs->mutex);
- return unlikely(copy_to_user(buf, events, size)) ? -EFAULT : size;
+ return copy_to_user(buf, events, size) ? -EFAULT : size;
}
static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
@@ -514,7 +514,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
/* Acquire mutex */
ret = ffs_mutex_lock(&ffs->mutex, file->f_flags & O_NONBLOCK);
- if (unlikely(ret < 0))
+ if (ret < 0)
return ret;
/* Check state */
@@ -536,7 +536,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
case FFS_NO_SETUP:
n = len / sizeof(struct usb_functionfs_event);
- if (unlikely(!n)) {
+ if (!n) {
ret = -EINVAL;
break;
}
@@ -567,9 +567,9 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
spin_unlock_irq(&ffs->ev.waitq.lock);
- if (likely(len)) {
+ if (len) {
data = kmalloc(len, GFP_KERNEL);
- if (unlikely(!data)) {
+ if (!data) {
ret = -ENOMEM;
goto done_mutex;
}
@@ -586,7 +586,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
/* unlocks spinlock */
ret = __ffs_ep0_queue_wait(ffs, data, len);
- if (likely(ret > 0) && unlikely(copy_to_user(buf, data, len)))
+ if ((ret > 0) && (copy_to_user(buf, data, len)))
ret = -EFAULT;
goto done_mutex;
@@ -608,7 +608,7 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
ENTER();
- if (unlikely(ffs->state == FFS_CLOSING))
+ if (ffs->state == FFS_CLOSING)
return -EBUSY;
file->private_data = ffs;
@@ -657,7 +657,7 @@ static __poll_t ffs_ep0_poll(struct file *file, poll_table *wait)
poll_wait(file, &ffs->ev.waitq, wait);
ret = ffs_mutex_lock(&ffs->mutex, file->f_flags & O_NONBLOCK);
- if (unlikely(ret < 0))
+ if (ret < 0)
return mask;
switch (ffs->state) {
@@ -708,7 +708,7 @@ static const struct file_operations ffs_ep0_operations = {
static void ffs_epfile_io_complete(struct usb_ep *_ep, struct usb_request *req)
{
ENTER();
- if (likely(req->context)) {
+ if (req->context) {
struct ffs_ep *ep = _ep->driver_data;
ep->status = req->status ? req->status : req->actual;
complete(req->context);
@@ -718,10 +718,10 @@ static void ffs_epfile_io_complete(struct usb_ep *_ep, struct usb_request *req)
static ssize_t ffs_copy_to_iter(void *data, int data_len, struct iov_iter *iter)
{
ssize_t ret = copy_to_iter(data, data_len, iter);
- if (likely(ret == data_len))
+ if (ret == data_len)
return ret;
- if (unlikely(iov_iter_count(iter)))
+ if (iov_iter_count(iter))
return -EFAULT;
/*
@@ -887,7 +887,7 @@ static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile,
return ret;
}
- if (unlikely(iov_iter_count(iter))) {
+ if (iov_iter_count(iter)) {
ret = -EFAULT;
} else {
buf->length -= ret;
@@ -908,10 +908,10 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
struct ffs_buffer *buf;
ssize_t ret = copy_to_iter(data, data_len, iter);
- if (likely(data_len == ret))
+ if (data_len == ret)
return ret;
- if (unlikely(iov_iter_count(iter)))
+ if (iov_iter_count(iter))
return -EFAULT;
/* See ffs_copy_to_iter for more context. */
@@ -932,7 +932,7 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
* in struct ffs_epfile for full read_buffer pointer synchronisation
* story.
*/
- if (unlikely(cmpxchg(&epfile->read_buffer, NULL, buf)))
+ if (cmpxchg(&epfile->read_buffer, NULL, buf))
kfree(buf);
return ret;
@@ -970,7 +970,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
/* We will be using request and read_buffer */
ret = ffs_mutex_lock(&epfile->mutex, file->f_flags & O_NONBLOCK);
- if (unlikely(ret))
+ if (ret)
goto error;
/* Allocate & copy */
@@ -1015,7 +1015,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
spin_unlock_irq(&epfile->ffs->eps_lock);
data = ffs_alloc_buffer(io_data, data_len);
- if (unlikely(!data)) {
+ if (!data) {
ret = -ENOMEM;
goto error_mutex;
}
@@ -1035,7 +1035,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
ret = usb_ep_set_halt(ep->ep);
if (!ret)
ret = -EBADMSG;
- } else if (unlikely(data_len == -EINVAL)) {
+ } else if (data_len == -EINVAL) {
/*
* Sanity Check: even though data_len can't be used
* uninitialized at the time I write this comment, some
@@ -1070,12 +1070,12 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
req->complete = ffs_epfile_io_complete;
ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
- if (unlikely(ret < 0))
+ if (ret < 0)
goto error_lock;
spin_unlock_irq(&epfile->ffs->eps_lock);
- if (unlikely(wait_for_completion_interruptible(&done))) {
+ if (wait_for_completion_interruptible(&done)) {
/*
* To avoid race condition with ffs_epfile_io_complete,
* dequeue the request first then check
@@ -1117,7 +1117,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
req->complete = ffs_epfile_async_io_complete;
ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
- if (unlikely(ret)) {
+ if (ret) {
io_data->req = NULL;
usb_ep_free_request(ep->ep, req);
goto error_lock;
@@ -1168,7 +1168,7 @@ static int ffs_aio_cancel(struct kiocb *kiocb)
spin_lock_irqsave(&epfile->ffs->eps_lock, flags);
- if (likely(io_data && io_data->ep && io_data->req))
+ if (io_data && io_data->ep && io_data->req)
value = usb_ep_dequeue(io_data->ep, io_data->req);
else
value = -EINVAL;
@@ -1187,7 +1187,7 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from)
if (!is_sync_kiocb(kiocb)) {
p = kzalloc(sizeof(io_data), GFP_KERNEL);
- if (unlikely(!p))
+ if (!p)
return -ENOMEM;
p->aio = true;
} else {
@@ -1224,7 +1224,7 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to)
if (!is_sync_kiocb(kiocb)) {
p = kzalloc(sizeof(io_data), GFP_KERNEL);
- if (unlikely(!p))
+ if (!p)
return -ENOMEM;
p->aio = true;
} else {
@@ -1388,7 +1388,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
inode = new_inode(sb);
- if (likely(inode)) {
+ if (inode) {
struct timespec64 ts = current_time(inode);
inode->i_ino = get_next_ino();
@@ -1420,11 +1420,11 @@ static struct dentry *ffs_sb_create_file(struct super_block *sb,
ENTER();
dentry = d_alloc_name(sb->s_root, name);
- if (unlikely(!dentry))
+ if (!dentry)
return NULL;
inode = ffs_sb_make_inode(sb, data, fops, NULL, &ffs->file_perms);
- if (unlikely(!inode)) {
+ if (!inode) {
dput(dentry);
return NULL;
}
@@ -1471,12 +1471,11 @@ static int ffs_sb_fill(struct super_block *sb, struct fs_context *fc)
&simple_dir_inode_operations,
&data->perms);
sb->s_root = d_make_root(inode);
- if (unlikely(!sb->s_root))
+ if (!sb->s_root)
return -ENOMEM;
/* EP0 file */
- if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs,
- &ffs_ep0_operations)))
+ if (!ffs_sb_create_file(sb, "ep0", ffs, &ffs_ep0_operations))
return -ENOMEM;
return 0;
@@ -1564,13 +1563,13 @@ static int ffs_fs_get_tree(struct fs_context *fc)
return invalf(fc, "No source specified");
ffs = ffs_data_new(fc->source);
- if (unlikely(!ffs))
+ if (!ffs)
return -ENOMEM;
ffs->file_perms = ctx->perms;
ffs->no_disconnect = ctx->no_disconnect;
ffs->dev_name = kstrdup(fc->source, GFP_KERNEL);
- if (unlikely(!ffs->dev_name)) {
+ if (!ffs->dev_name) {
ffs_data_put(ffs);
return -ENOMEM;
}
@@ -1656,7 +1655,7 @@ static int functionfs_init(void)
ENTER();
ret = register_filesystem(&ffs_fs_type);
- if (likely(!ret))
+ if (!ret)
pr_info("file system registered\n");
else
pr_err("failed registering file system (%d)\n", ret);
@@ -1701,7 +1700,7 @@ static void ffs_data_put(struct ffs_data *ffs)
{
ENTER();
- if (unlikely(refcount_dec_and_test(&ffs->ref))) {
+ if (refcount_dec_and_test(&ffs->ref)) {
pr_info("%s(): freeing\n", __func__);
ffs_data_clear(ffs);
BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
@@ -1743,7 +1742,7 @@ static void ffs_data_closed(struct ffs_data *ffs)
static struct ffs_data *ffs_data_new(const char *dev_name)
{
struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL);
- if (unlikely(!ffs))
+ if (!ffs)
return NULL;
ENTER();
@@ -1833,11 +1832,11 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
return -EBADFD;
first_id = usb_string_ids_n(cdev, ffs->strings_count);
- if (unlikely(first_id < 0))
+ if (first_id < 0)
return first_id;
ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
- if (unlikely(!ffs->ep0req))
+ if (!ffs->ep0req)
return -ENOMEM;
ffs->ep0req->complete = ffs_ep0_complete;
ffs->ep0req->context = ffs;
@@ -1893,7 +1892,7 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
epfile->dentry = ffs_sb_create_file(ffs->sb, epfile->name,
epfile,
&ffs_epfile_operations);
- if (unlikely(!epfile->dentry)) {
+ if (!epfile->dentry) {
ffs_epfiles_destroy(epfiles, i - 1);
return -ENOMEM;
}
@@ -1931,7 +1930,7 @@ static void ffs_func_eps_disable(struct ffs_function *func)
spin_lock_irqsave(&func->ffs->eps_lock, flags);
while (count--) {
/* pending requests get nuked */
- if (likely(ep->ep))
+ if (ep->ep)
usb_ep_disable(ep->ep);
++ep;
@@ -1965,7 +1964,7 @@ static int ffs_func_eps_enable(struct ffs_function *func)
}
ret = usb_ep_enable(ep->ep);
- if (likely(!ret)) {
+ if (!ret) {
epfile->ep = ep;
epfile->in = usb_endpoint_dir_in(ep->ep->desc);
epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc);
@@ -2038,12 +2037,12 @@ static int __must_check ffs_do_single_desc(char *data, unsigned len,
#define __entity_check_ENDPOINT(val) ((val) & USB_ENDPOINT_NUMBER_MASK)
#define __entity(type, val) do { \
pr_vdebug("entity " #type "(%02x)\n", (val)); \
- if (unlikely(!__entity_check_ ##type(val))) { \
+ if (!__entity_check_ ##type(val)) { \
pr_vdebug("invalid entity's value\n"); \
return -EINVAL; \
} \
ret = entity(FFS_ ##type, &val, _ds, priv); \
- if (unlikely(ret < 0)) { \
+ if (ret < 0) { \
pr_debug("entity " #type "(%02x); ret = %d\n", \
(val), ret); \
return ret; \
@@ -2168,7 +2167,7 @@ static int __must_check ffs_do_descs(unsigned count, char *data, unsigned len,
/* Record "descriptor" entity */
ret = entity(FFS_DESCRIPTOR, (u8 *)num, (void *)data, priv);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
pr_debug("entity DESCRIPTOR(%02lx); ret = %d\n",
num, ret);
return ret;
@@ -2179,7 +2178,7 @@ static int __must_check ffs_do_descs(unsigned count, char *data, unsigned len,
ret = ffs_do_single_desc(data, len, entity, priv,
&current_class);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
pr_debug("%s returns %d\n", __func__, ret);
return ret;
}
@@ -2285,7 +2284,7 @@ static int __must_check ffs_do_single_os_desc(char *data, unsigned len,
/* loop over all ext compat/ext prop descriptors */
while (feature_count--) {
ret = entity(type, h, data, len, priv);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
pr_debug("bad OS descriptor, type: %d\n", type);
return ret;
}
@@ -2325,7 +2324,7 @@ static int __must_check ffs_do_os_descs(unsigned count,
return -EINVAL;
ret = __ffs_do_os_desc_header(&type, desc);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
pr_debug("entity OS_DESCRIPTOR(%02lx); ret = %d\n",
num, ret);
return ret;
@@ -2346,7 +2345,7 @@ static int __must_check ffs_do_os_descs(unsigned count,
*/
ret = ffs_do_single_os_desc(data, len, type,
feature_count, entity, priv, desc);
- if (unlikely(ret < 0)) {
+ if (ret < 0) {
pr_debug("%s returns %d\n", __func__, ret);
return ret;
}
@@ -2578,20 +2577,20 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
ENTER();
- if (unlikely(len < 16 ||
- get_unaligned_le32(data) != FUNCTIONFS_STRINGS_MAGIC ||
- get_unaligned_le32(data + 4) != len))
+ if (len < 16 ||
+ get_unaligned_le32(data) != FUNCTIONFS_STRINGS_MAGIC ||
+ get_unaligned_le32(data + 4) != len)
goto error;
str_count = get_unaligned_le32(data + 8);
lang_count = get_unaligned_le32(data + 12);
/* if one is zero the other must be zero */
- if (unlikely(!str_count != !lang_count))
+ if (!str_count != !lang_count)
goto error;
/* Do we have at least as many strings as descriptors need? */
needed_count = ffs->strings_count;
- if (unlikely(str_count < needed_count))
+ if (str_count < needed_count)
goto error;
/*
@@ -2615,7 +2614,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
char *vlabuf = kmalloc(vla_group_size(d), GFP_KERNEL);
- if (unlikely(!vlabuf)) {
+ if (!vlabuf) {
kfree(_data);
return -ENOMEM;
}
@@ -2642,7 +2641,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
do { /* lang_count > 0 so we can use do-while */
unsigned needed = needed_count;
- if (unlikely(len < 3))
+ if (len < 3)
goto error_free;
t->language = get_unaligned_le16(data);
t->strings = s;
@@ -2655,7 +2654,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
do { /* str_count > 0 so we can use do-while */
size_t length = strnlen(data, len);
- if (unlikely(length == len))
+ if (length == len)
goto error_free;
/*
@@ -2663,7 +2662,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
* if that's the case we simply ignore the
* rest
*/
- if (likely(needed)) {
+ if (needed) {
/*
* s->id will be set while adding
* function to configuration so for
@@ -2685,7 +2684,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
} while (--lang_count);
/* Some garbage left? */
- if (unlikely(len))
+ if (len)
goto error_free;
/* Done! */
@@ -2832,7 +2831,7 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep,
ffs_ep = func->eps + idx;
- if (unlikely(ffs_ep->descs[ep_desc_id])) {
+ if (ffs_ep->descs[ep_desc_id]) {
pr_err("two %sspeed descriptors for EP %d\n",
speed_names[ep_desc_id],
ds->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
@@ -2863,12 +2862,12 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep,
wMaxPacketSize = ds->wMaxPacketSize;
pr_vdebug("autoconfig\n");
ep = usb_ep_autoconfig(func->gadget, ds);
- if (unlikely(!ep))
+ if (!ep)
return -ENOTSUPP;
ep->driver_data = func->eps + idx;
req = usb_ep_alloc_request(ep, GFP_KERNEL);
- if (unlikely(!req))
+ if (!req)
return -ENOMEM;
ffs_ep->ep = ep;
@@ -2910,7 +2909,7 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type type, u8 *valuep,
idx = *valuep;
if (func->interfaces_nums[idx] < 0) {
int id = usb_interface_id(func->conf, &func->function);
- if (unlikely(id < 0))
+ if (id < 0)
return id;
func->interfaces_nums[idx] = id;
}
@@ -2931,7 +2930,7 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type type, u8 *valuep,
return 0;
idx = (*valuep & USB_ENDPOINT_NUMBER_MASK) - 1;
- if (unlikely(!func->eps[idx].ep))
+ if (!func->eps[idx].ep)
return -EINVAL;
{
@@ -3114,12 +3113,12 @@ static int _ffs_func_bind(struct usb_configuration *c,
ENTER();
/* Has descriptors only for speeds gadget does not support */
- if (unlikely(!(full | high | super)))
+ if (!(full | high | super))
return -ENOTSUPP;
/* Allocate a single chunk, less management later on */
vlabuf = kzalloc(vla_group_size(d), GFP_KERNEL);
- if (unlikely(!vlabuf))
+ if (!vlabuf)
return -ENOMEM;
ffs->ms_os_descs_ext_prop_avail = vla_ptr(vlabuf, d, ext_prop);
@@ -3148,13 +3147,13 @@ static int _ffs_func_bind(struct usb_configuration *c,
* endpoints first, so that later we can rewrite the endpoint
* numbers without worrying that it may be described later on.
*/
- if (likely(full)) {
+ if (full) {
func->function.fs_descriptors = vla_ptr(vlabuf, d, fs_descs);
fs_len = ffs_do_descs(ffs->fs_descs_count,
vla_ptr(vlabuf, d, raw_descs),
d_raw_descs__sz,
__ffs_func_bind_do_descs, func);
- if (unlikely(fs_len < 0)) {
+ if (fs_len < 0) {
ret = fs_len;
goto error;
}
@@ -3162,13 +3161,13 @@ static int _ffs_func_bind(struct usb_configuration *c,
fs_len = 0;
}
- if (likely(high)) {
+ if (high) {
func->function.hs_descriptors = vla_ptr(vlabuf, d, hs_descs);
hs_len = ffs_do_descs(ffs->hs_descs_count,
vla_ptr(vlabuf, d, raw_descs) + fs_len,
d_raw_descs__sz - fs_len,
__ffs_func_bind_do_descs, func);
- if (unlikely(hs_len < 0)) {
+ if (hs_len < 0) {
ret = hs_len;
goto error;
}
@@ -3176,14 +3175,14 @@ static int _ffs_func_bind(struct usb_configuration *c,
hs_len = 0;
}
- if (likely(super)) {
+ if (super) {
func->function.ss_descriptors = func->function.ssp_descriptors =
vla_ptr(vlabuf, d, ss_descs);
ss_len = ffs_do_descs(ffs->ss_descs_count,
vla_ptr(vlabuf, d, raw_descs) + fs_len + hs_len,
d_raw_descs__sz - fs_len - hs_len,
__ffs_func_bind_do_descs, func);
- if (unlikely(ss_len < 0)) {
+ if (ss_len < 0) {
ret = ss_len;
goto error;
}
@@ -3201,7 +3200,7 @@ static int _ffs_func_bind(struct usb_configuration *c,
(super ? ffs->ss_descs_count : 0),
vla_ptr(vlabuf, d, raw_descs), d_raw_descs__sz,
__ffs_func_bind_do_nums, func);
- if (unlikely(ret < 0))
+ if (ret < 0)
goto error;
func->function.os_desc_table = vla_ptr(vlabuf, d, os_desc_table);
@@ -3222,7 +3221,7 @@ static int _ffs_func_bind(struct usb_configuration *c,
d_raw_descs__sz - fs_len - hs_len -
ss_len,
__ffs_func_bind_do_os_desc, func);
- if (unlikely(ret < 0))
+ if (ret < 0)
goto error;
}
func->function.os_desc_n =
@@ -3273,7 +3272,7 @@ static int ffs_func_set_alt(struct usb_function *f,
if (alt != (unsigned)-1) {
intf = ffs_func_revmap_intf(func, interface);
- if (unlikely(intf < 0))
+ if (intf < 0)
return intf;
}
@@ -3298,7 +3297,7 @@ static int ffs_func_set_alt(struct usb_function *f,
ffs->func = func;
ret = ffs_func_eps_enable(func);
- if (likely(ret >= 0))
+ if (ret >= 0)
ffs_event_add(ffs, FUNCTIONFS_ENABLE);
return ret;
}
@@ -3340,13 +3339,13 @@ static int ffs_func_setup(struct usb_function *f,
switch (creq->bRequestType & USB_RECIP_MASK) {
case USB_RECIP_INTERFACE:
ret = ffs_func_revmap_intf(func, le16_to_cpu(creq->wIndex));
- if (unlikely(ret < 0))
+ if (ret < 0)
return ret;
break;
case USB_RECIP_ENDPOINT:
ret = ffs_func_revmap_ep(func, le16_to_cpu(creq->wIndex));
- if (unlikely(ret < 0))
+ if (ret < 0)
return ret;
if (func->ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
ret = func->ffs->eps_addrmap[ret];
@@ -3601,7 +3600,7 @@ static struct usb_function *ffs_alloc(struct usb_function_instance *fi)
ENTER();
func = kzalloc(sizeof(*func), GFP_KERNEL);
- if (unlikely(!func))
+ if (!func)
return ERR_PTR(-ENOMEM);
func->function.name = "Function FS Gadget";
@@ -3816,7 +3815,7 @@ done:
static int ffs_mutex_lock(struct mutex *mutex, unsigned nonblock)
{
return nonblock
- ? likely(mutex_trylock(mutex)) ? 0 : -EAGAIN
+ ? mutex_trylock(mutex) ? 0 : -EAGAIN
: mutex_lock_interruptible(mutex);
}
@@ -3824,14 +3823,14 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len)
{
char *data;
- if (unlikely(!len))
+ if (!len)
return NULL;
data = kmalloc(len, GFP_KERNEL);
- if (unlikely(!data))
+ if (!data)
return ERR_PTR(-ENOMEM);
- if (unlikely(copy_from_user(data, buf, len))) {
+ if (copy_from_user(data, buf, len)) {
kfree(data);
return ERR_PTR(-EFAULT);
}