Skip to content

Commit

Permalink
rapidio: return an error code only as a constant in two functions
Browse files Browse the repository at this point in the history
* Return an error code without storing it in an intermediate variable.

* Delete the label "out" and local variable "rc" which became unnecessary
  with this refactoring.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Markus Elfring <[email protected]>
Acked-by: Alexandre Bounine <[email protected]>
Cc: Matt Porter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
elfring authored and torvalds committed Feb 7, 2018
1 parent 002f6f4 commit 1acd14b
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions drivers/rapidio/rio.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,10 @@ rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst,
u16 info))
{
int rc = 0;
struct rio_dbell *dbell = kmalloc(sizeof(*dbell), GFP_KERNEL);

if (!dbell) {
rc = -ENOMEM;
goto out;
}
if (!dbell)
return -ENOMEM;

dbell->res = res;
dbell->dinb = dinb;
Expand All @@ -417,9 +414,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
mutex_lock(&mport->lock);
list_add_tail(&dbell->node, &mport->dbells);
mutex_unlock(&mport->lock);

out:
return rc;
return 0;
}

/**
Expand Down Expand Up @@ -563,21 +558,17 @@ int rio_add_mport_pw_handler(struct rio_mport *mport, void *context,
int (*pwcback)(struct rio_mport *mport,
void *context, union rio_pw_msg *msg, int step))
{
int rc = 0;
struct rio_pwrite *pwrite = kzalloc(sizeof(*pwrite), GFP_KERNEL);

if (!pwrite) {
rc = -ENOMEM;
goto out;
}
if (!pwrite)
return -ENOMEM;

pwrite->pwcback = pwcback;
pwrite->context = context;
mutex_lock(&mport->lock);
list_add_tail(&pwrite->node, &mport->pwrites);
mutex_unlock(&mport->lock);
out:
return rc;
return 0;
}
EXPORT_SYMBOL_GPL(rio_add_mport_pw_handler);

Expand Down

0 comments on commit 1acd14b

Please sign in to comment.