staging: xillybus: Fixes related to "rc" variable

"rc" is often used to hold the return value of a function call. This patch
removes unnecessary assignments to this variable, and makes a few related
execution flow improvements.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Eli Billauer 2014-09-04 17:47:48 +03:00 committed by Greg Kroah-Hartman
parent 06bda66b01
commit 40931bbbfe
3 changed files with 15 additions and 32 deletions

View File

@ -613,7 +613,6 @@ static int xilly_scan_idt(struct xilly_endpoint *endpoint,
static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
{
int rc = 0;
struct xilly_channel *channel;
unsigned char *version;
@ -635,8 +634,7 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
if (endpoint->fatal_error)
return -EIO;
rc = -ENODEV;
return rc;
return -ENODEV;
}
endpoint->ephw->hw_sync_sgl_for_cpu(
@ -649,15 +647,13 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
dev_err(endpoint->dev,
"IDT length mismatch (%d != %d). Aborting.\n",
channel->wr_buffers[0]->end_offset, endpoint->idtlen);
rc = -ENODEV;
return rc;
return -ENODEV;
}
if (crc32_le(~0, channel->wr_buffers[0]->addr,
endpoint->idtlen+1) != 0) {
dev_err(endpoint->dev, "IDT failed CRC check. Aborting.\n");
rc = -ENODEV;
return rc;
return -ENODEV;
}
version = channel->wr_buffers[0]->addr;
@ -667,8 +663,7 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
dev_err(endpoint->dev,
"No support for IDT version 0x%02x. Maybe the xillybus driver needs an upgarde. Aborting.\n",
(int) *version);
rc = -ENODEV;
return rc;
return -ENODEV;
}
return 0; /* Success */
@ -696,12 +691,9 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
deadline = jiffies + 1 + XILLY_RX_TIMEOUT;
rc = mutex_lock_interruptible(&channel->wr_mutex);
if (rc)
return rc;
rc = 0; /* Just to be clear about it. Compiler optimizes this out */
while (1) { /* Note that we may drop mutex within this loop */
int bytes_to_do = count - bytes_done;
@ -1010,7 +1002,7 @@ desperate:
static int xillybus_myflush(struct xilly_channel *channel, long timeout)
{
int rc = 0;
int rc;
unsigned long flags;
int end_offset_plus1;
@ -1022,7 +1014,6 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)
if (channel->endpoint->fatal_error)
return -EIO;
rc = mutex_lock_interruptible(&channel->rd_mutex);
if (rc)
return rc;
@ -1120,8 +1111,6 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)
* If bufidx == channel->rd_fpga_buf_idx we're either empty or full.
*/
rc = 0;
while (1) { /* Loop waiting for draining of buffers */
spin_lock_irqsave(&channel->rd_spinlock, flags);
@ -1217,12 +1206,9 @@ static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
return -EIO;
rc = mutex_lock_interruptible(&channel->rd_mutex);
if (rc)
return rc;
rc = 0; /* Just to be clear about it. Compiler optimizes this out */
while (1) {
int bytes_to_do = count - bytes_done;
@ -1840,7 +1826,6 @@ static int xillybus_init_chrdev(struct xilly_endpoint *endpoint,
rc = alloc_chrdev_region(&dev, 0, /* minor start */
endpoint->num_channels,
xillyname);
if (rc) {
dev_warn(endpoint->dev, "Failed to obtain major/minors");
return rc;
@ -1965,7 +1950,7 @@ static int xilly_quiesce(struct xilly_endpoint *endpoint)
int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
{
int rc = 0;
int rc;
void *bootstrap_resources;
int idtbuffersize = (1 << PAGE_SHIFT);
@ -1999,7 +1984,6 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
endpoint->num_channels = 0;
rc = xilly_setupchannels(endpoint, bogus_idt, 1);
if (rc)
return rc;
@ -2121,10 +2105,10 @@ static int __init xillybus_init(void)
xillybus_wq = alloc_workqueue(xillyname, 0, 0);
if (!xillybus_wq) {
class_destroy(xillybus_class);
rc = -ENOMEM;
return -ENOMEM;
}
return rc;
return 0;
}
static void __exit xillybus_exit(void)

View File

@ -106,9 +106,10 @@ static int xilly_map_single_of(struct xilly_endpoint *ep,
if (rc) {
dma_unmap_single(ep->dev, addr, size, direction);
kfree(this);
return rc;
}
return rc;
return 0;
}
static struct xilly_endpoint_hardware of_hw = {
@ -129,7 +130,7 @@ static int xilly_drv_probe(struct platform_device *op)
{
struct device *dev = &op->dev;
struct xilly_endpoint *endpoint;
int rc = 0;
int rc;
int irq;
struct resource res;
struct xilly_endpoint_hardware *ephw = &of_hw;

View File

@ -98,7 +98,7 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
int pci_direction;
dma_addr_t addr;
struct xilly_mapping *this;
int rc = 0;
int rc;
this = kzalloc(sizeof(*this), GFP_KERNEL);
if (!this)
@ -121,13 +121,13 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
*ret_dma_handle = addr;
rc = devm_add_action(ep->dev, xilly_pci_unmap, this);
if (rc) {
pci_unmap_single(ep->pdev, addr, size, pci_direction);
kfree(this);
return rc;
}
return rc;
return 0;
}
static struct xilly_endpoint_hardware pci_hw = {
@ -141,7 +141,7 @@ static int xilly_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct xilly_endpoint *endpoint;
int rc = 0;
int rc;
endpoint = xillybus_init_endpoint(pdev, &pdev->dev, &pci_hw);
@ -151,7 +151,6 @@ static int xilly_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, endpoint);
rc = pcim_enable_device(pdev);
if (rc) {
dev_err(endpoint->dev,
"pcim_enable_device() failed. Aborting.\n");
@ -187,7 +186,6 @@ static int xilly_probe(struct pci_dev *pdev,
}
rc = devm_request_irq(&pdev->dev, pdev->irq, xillybus_isr, 0,
xillyname, endpoint);
if (rc) {
dev_err(endpoint->dev,
"Failed to register MSI handler. Aborting.\n");