mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
IB/qib: Cleanup qib_register_observer()
Returning directly is easier to read than do-nothing gotos. Remove the duplicative check on "olp" and pull the code in one indent level. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
This commit is contained in:
parent
49c0e2414b
commit
186f8ba062
1 changed files with 10 additions and 15 deletions
|
@ -694,28 +694,23 @@ int qib_register_observer(struct qib_devdata *dd,
|
|||
const struct diag_observer *op)
|
||||
{
|
||||
struct diag_observer_list_elt *olp;
|
||||
int ret = -EINVAL;
|
||||
unsigned long flags;
|
||||
|
||||
if (!dd || !op)
|
||||
goto bail;
|
||||
ret = -ENOMEM;
|
||||
return -EINVAL;
|
||||
olp = vmalloc(sizeof *olp);
|
||||
if (!olp) {
|
||||
pr_err("vmalloc for observer failed\n");
|
||||
goto bail;
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (olp) {
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&dd->qib_diag_trans_lock, flags);
|
||||
olp->op = op;
|
||||
olp->next = dd->diag_observer_list;
|
||||
dd->diag_observer_list = olp;
|
||||
spin_unlock_irqrestore(&dd->qib_diag_trans_lock, flags);
|
||||
ret = 0;
|
||||
}
|
||||
bail:
|
||||
return ret;
|
||||
spin_lock_irqsave(&dd->qib_diag_trans_lock, flags);
|
||||
olp->op = op;
|
||||
olp->next = dd->diag_observer_list;
|
||||
dd->diag_observer_list = olp;
|
||||
spin_unlock_irqrestore(&dd->qib_diag_trans_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove all registered observers when device is closed */
|
||||
|
|
Loading…
Reference in a new issue