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:
parent
06bda66b01
commit
40931bbbfe
|
@ -613,7 +613,6 @@ static int xilly_scan_idt(struct xilly_endpoint *endpoint,
|
||||||
|
|
||||||
static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
|
static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
|
||||||
struct xilly_channel *channel;
|
struct xilly_channel *channel;
|
||||||
unsigned char *version;
|
unsigned char *version;
|
||||||
|
|
||||||
|
@ -635,8 +634,7 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
|
||||||
if (endpoint->fatal_error)
|
if (endpoint->fatal_error)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
rc = -ENODEV;
|
return -ENODEV;
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint->ephw->hw_sync_sgl_for_cpu(
|
endpoint->ephw->hw_sync_sgl_for_cpu(
|
||||||
|
@ -649,15 +647,13 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
|
||||||
dev_err(endpoint->dev,
|
dev_err(endpoint->dev,
|
||||||
"IDT length mismatch (%d != %d). Aborting.\n",
|
"IDT length mismatch (%d != %d). Aborting.\n",
|
||||||
channel->wr_buffers[0]->end_offset, endpoint->idtlen);
|
channel->wr_buffers[0]->end_offset, endpoint->idtlen);
|
||||||
rc = -ENODEV;
|
return -ENODEV;
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crc32_le(~0, channel->wr_buffers[0]->addr,
|
if (crc32_le(~0, channel->wr_buffers[0]->addr,
|
||||||
endpoint->idtlen+1) != 0) {
|
endpoint->idtlen+1) != 0) {
|
||||||
dev_err(endpoint->dev, "IDT failed CRC check. Aborting.\n");
|
dev_err(endpoint->dev, "IDT failed CRC check. Aborting.\n");
|
||||||
rc = -ENODEV;
|
return -ENODEV;
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = channel->wr_buffers[0]->addr;
|
version = channel->wr_buffers[0]->addr;
|
||||||
|
@ -667,8 +663,7 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
|
||||||
dev_err(endpoint->dev,
|
dev_err(endpoint->dev,
|
||||||
"No support for IDT version 0x%02x. Maybe the xillybus driver needs an upgarde. Aborting.\n",
|
"No support for IDT version 0x%02x. Maybe the xillybus driver needs an upgarde. Aborting.\n",
|
||||||
(int) *version);
|
(int) *version);
|
||||||
rc = -ENODEV;
|
return -ENODEV;
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* Success */
|
return 0; /* Success */
|
||||||
|
@ -696,12 +691,9 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
|
||||||
deadline = jiffies + 1 + XILLY_RX_TIMEOUT;
|
deadline = jiffies + 1 + XILLY_RX_TIMEOUT;
|
||||||
|
|
||||||
rc = mutex_lock_interruptible(&channel->wr_mutex);
|
rc = mutex_lock_interruptible(&channel->wr_mutex);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return 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 */
|
while (1) { /* Note that we may drop mutex within this loop */
|
||||||
int bytes_to_do = count - bytes_done;
|
int bytes_to_do = count - bytes_done;
|
||||||
|
|
||||||
|
@ -1010,7 +1002,7 @@ desperate:
|
||||||
|
|
||||||
static int xillybus_myflush(struct xilly_channel *channel, long timeout)
|
static int xillybus_myflush(struct xilly_channel *channel, long timeout)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
int end_offset_plus1;
|
int end_offset_plus1;
|
||||||
|
@ -1022,7 +1014,6 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout)
|
||||||
if (channel->endpoint->fatal_error)
|
if (channel->endpoint->fatal_error)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
rc = mutex_lock_interruptible(&channel->rd_mutex);
|
rc = mutex_lock_interruptible(&channel->rd_mutex);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return 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.
|
* If bufidx == channel->rd_fpga_buf_idx we're either empty or full.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rc = 0;
|
|
||||||
|
|
||||||
while (1) { /* Loop waiting for draining of buffers */
|
while (1) { /* Loop waiting for draining of buffers */
|
||||||
spin_lock_irqsave(&channel->rd_spinlock, flags);
|
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;
|
return -EIO;
|
||||||
|
|
||||||
rc = mutex_lock_interruptible(&channel->rd_mutex);
|
rc = mutex_lock_interruptible(&channel->rd_mutex);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = 0; /* Just to be clear about it. Compiler optimizes this out */
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int bytes_to_do = count - bytes_done;
|
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 */
|
rc = alloc_chrdev_region(&dev, 0, /* minor start */
|
||||||
endpoint->num_channels,
|
endpoint->num_channels,
|
||||||
xillyname);
|
xillyname);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_warn(endpoint->dev, "Failed to obtain major/minors");
|
dev_warn(endpoint->dev, "Failed to obtain major/minors");
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -1965,7 +1950,7 @@ static int xilly_quiesce(struct xilly_endpoint *endpoint)
|
||||||
|
|
||||||
int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
|
int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc;
|
||||||
|
|
||||||
void *bootstrap_resources;
|
void *bootstrap_resources;
|
||||||
int idtbuffersize = (1 << PAGE_SHIFT);
|
int idtbuffersize = (1 << PAGE_SHIFT);
|
||||||
|
@ -1999,7 +1984,6 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
|
||||||
endpoint->num_channels = 0;
|
endpoint->num_channels = 0;
|
||||||
|
|
||||||
rc = xilly_setupchannels(endpoint, bogus_idt, 1);
|
rc = xilly_setupchannels(endpoint, bogus_idt, 1);
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -2121,10 +2105,10 @@ static int __init xillybus_init(void)
|
||||||
xillybus_wq = alloc_workqueue(xillyname, 0, 0);
|
xillybus_wq = alloc_workqueue(xillyname, 0, 0);
|
||||||
if (!xillybus_wq) {
|
if (!xillybus_wq) {
|
||||||
class_destroy(xillybus_class);
|
class_destroy(xillybus_class);
|
||||||
rc = -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit xillybus_exit(void)
|
static void __exit xillybus_exit(void)
|
||||||
|
|
|
@ -106,9 +106,10 @@ static int xilly_map_single_of(struct xilly_endpoint *ep,
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dma_unmap_single(ep->dev, addr, size, direction);
|
dma_unmap_single(ep->dev, addr, size, direction);
|
||||||
kfree(this);
|
kfree(this);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct xilly_endpoint_hardware of_hw = {
|
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 device *dev = &op->dev;
|
||||||
struct xilly_endpoint *endpoint;
|
struct xilly_endpoint *endpoint;
|
||||||
int rc = 0;
|
int rc;
|
||||||
int irq;
|
int irq;
|
||||||
struct resource res;
|
struct resource res;
|
||||||
struct xilly_endpoint_hardware *ephw = &of_hw;
|
struct xilly_endpoint_hardware *ephw = &of_hw;
|
||||||
|
|
|
@ -98,7 +98,7 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
|
||||||
int pci_direction;
|
int pci_direction;
|
||||||
dma_addr_t addr;
|
dma_addr_t addr;
|
||||||
struct xilly_mapping *this;
|
struct xilly_mapping *this;
|
||||||
int rc = 0;
|
int rc;
|
||||||
|
|
||||||
this = kzalloc(sizeof(*this), GFP_KERNEL);
|
this = kzalloc(sizeof(*this), GFP_KERNEL);
|
||||||
if (!this)
|
if (!this)
|
||||||
|
@ -121,13 +121,13 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
|
||||||
*ret_dma_handle = addr;
|
*ret_dma_handle = addr;
|
||||||
|
|
||||||
rc = devm_add_action(ep->dev, xilly_pci_unmap, this);
|
rc = devm_add_action(ep->dev, xilly_pci_unmap, this);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
pci_unmap_single(ep->pdev, addr, size, pci_direction);
|
pci_unmap_single(ep->pdev, addr, size, pci_direction);
|
||||||
kfree(this);
|
kfree(this);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct xilly_endpoint_hardware pci_hw = {
|
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)
|
const struct pci_device_id *ent)
|
||||||
{
|
{
|
||||||
struct xilly_endpoint *endpoint;
|
struct xilly_endpoint *endpoint;
|
||||||
int rc = 0;
|
int rc;
|
||||||
|
|
||||||
endpoint = xillybus_init_endpoint(pdev, &pdev->dev, &pci_hw);
|
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);
|
pci_set_drvdata(pdev, endpoint);
|
||||||
|
|
||||||
rc = pcim_enable_device(pdev);
|
rc = pcim_enable_device(pdev);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(endpoint->dev,
|
dev_err(endpoint->dev,
|
||||||
"pcim_enable_device() failed. Aborting.\n");
|
"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,
|
rc = devm_request_irq(&pdev->dev, pdev->irq, xillybus_isr, 0,
|
||||||
xillyname, endpoint);
|
xillyname, endpoint);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(endpoint->dev,
|
dev_err(endpoint->dev,
|
||||||
"Failed to register MSI handler. Aborting.\n");
|
"Failed to register MSI handler. Aborting.\n");
|
||||||
|
|
Loading…
Reference in New Issue