Skip to content

Commit

Permalink
nfc: pn533: remove redundant assignment
Browse files Browse the repository at this point in the history
In many places,first assign a value to a variable and then return
the variable. which is redundant, we should directly return the value.
in pn533_rf_field funciton,return rc also in the if statement, so we
use return 0 to replace the last return rc.

Signed-off-by: wengjianfeng <wengjianfeng@yulong.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
wengjianfeng authored and David S. Miller committed Apr 12, 2021
1 parent 5711ffd commit a115d24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
8 changes: 2 additions & 6 deletions drivers/nfc/pn533/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ static int pn533_i2c_send_ack(struct pn533 *dev, gfp_t flags)
struct i2c_client *client = phy->i2c_dev;
static const u8 ack[6] = {0x00, 0x00, 0xff, 0x00, 0xff, 0x00};
/* spec 6.2.1.3: Preamble, SoPC (2), ACK Code (2), Postamble */
int rc;

rc = i2c_master_send(client, ack, 6);

return rc;
return i2c_master_send(client, ack, 6);
}

static int pn533_i2c_send_frame(struct pn533 *dev,
Expand Down Expand Up @@ -199,8 +196,7 @@ static int pn533_i2c_probe(struct i2c_client *client,
&phy->i2c_dev->dev);

if (IS_ERR(priv)) {
r = PTR_ERR(priv);
return r;
return PTR_ERR(priv);
}

phy->priv = priv;
Expand Down
17 changes: 4 additions & 13 deletions drivers/nfc/pn533/pn533.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,25 +489,17 @@ static int pn533_send_data_async(struct pn533 *dev, u8 cmd_code,
pn533_send_async_complete_t complete_cb,
void *complete_cb_context)
{
int rc;

rc = __pn533_send_async(dev, cmd_code, req, complete_cb,
return __pn533_send_async(dev, cmd_code, req, complete_cb,
complete_cb_context);

return rc;
}

static int pn533_send_cmd_async(struct pn533 *dev, u8 cmd_code,
struct sk_buff *req,
pn533_send_async_complete_t complete_cb,
void *complete_cb_context)
{
int rc;

rc = __pn533_send_async(dev, cmd_code, req, complete_cb,
return __pn533_send_async(dev, cmd_code, req, complete_cb,
complete_cb_context);

return rc;
}

/*
Expand Down Expand Up @@ -2620,7 +2612,7 @@ static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf)
return rc;
}

return rc;
return 0;
}

static int pn532_sam_configuration(struct nfc_dev *nfc_dev)
Expand Down Expand Up @@ -2794,7 +2786,6 @@ struct pn533 *pn53x_common_init(u32 device_type,
struct device *dev)
{
struct pn533 *priv;
int rc = -ENOMEM;

priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
Expand Down Expand Up @@ -2836,7 +2827,7 @@ struct pn533 *pn53x_common_init(u32 device_type,

error:
kfree(priv);
return ERR_PTR(rc);
return ERR_PTR(-ENOMEM);
}
EXPORT_SYMBOL_GPL(pn53x_common_init);

Expand Down

0 comments on commit a115d24

Please sign in to comment.