summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2015-04-30 21:20:46 +0200
committerpopcornmix <popcornmix@gmail.com>2015-05-18 14:13:02 +0100
commit62d6bea512fc18c556dc9165039a7b4f45f706d9 (patch)
tree00a5dcfb5110d8a4d83dea81bad3d29b3dbde3fc
parent2292ac3add3bf116bcbc7464ea5d0f311030cdc1 (diff)
downloadlinux-62d6bea512fc18c556dc9165039a7b4f45f706d9.tar.gz
BCM2708: vcio: Restructure error paths
No need to use if/else clauses on error when return can be used directly. Also test for errors first if possible. This is done to enhance readability. bcm_vcio_probe() is not touched, it will be reworked later. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
-rw-r--r--arch/arm/mach-bcm2708/vcio.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/arch/arm/mach-bcm2708/vcio.c b/arch/arm/mach-bcm2708/vcio.c
index cac8dd7530e4..36e0f1e6ce45 100644
--- a/arch/arm/mach-bcm2708/vcio.c
+++ b/arch/arm/mach-bcm2708/vcio.c
@@ -84,34 +84,28 @@ static void mbox_init(struct vc_mailbox *mbox_out, struct device *dev,
static int mbox_write(struct vc_mailbox *mbox, unsigned chan, uint32_t data28)
{
- int rc;
+ if (mbox->magic != MBOX_MAGIC)
+ return -EINVAL;
- if (mbox->magic != MBOX_MAGIC) {
- rc = -EINVAL;
- } else {
- /* wait for the mailbox FIFO to have some space in it */
- while (0 != (readl(mbox->status) & ARM_MS_FULL))
- cpu_relax();
+ /* wait for the mailbox FIFO to have some space in it */
+ while (0 != (readl(mbox->status) & ARM_MS_FULL))
+ cpu_relax();
- writel(MBOX_MSG(chan, data28), mbox->write);
- rc = 0;
- }
- return rc;
+ writel(MBOX_MSG(chan, data28), mbox->write);
+
+ return 0;
}
static int mbox_read(struct vc_mailbox *mbox, unsigned chan, uint32_t *data28)
{
- int rc;
+ if (mbox->magic != MBOX_MAGIC)
+ return -EINVAL;
- if (mbox->magic != MBOX_MAGIC) {
- rc = -EINVAL;
- } else {
- down(&mbox->sema[chan]);
- *data28 = MBOX_DATA28(mbox->msg[chan]);
- mbox->msg[chan] = 0;
- rc = 0;
- }
- return rc;
+ down(&mbox->sema[chan]);
+ *data28 = MBOX_DATA28(mbox->msg[chan]);
+ mbox->msg[chan] = 0;
+
+ return 0;
}
static irqreturn_t mbox_irq(int irq, void *dev_id)
@@ -180,19 +174,19 @@ static int dev_mbox_read(struct device *dev, unsigned chan, uint32_t *data28)
extern int bcm_mailbox_write(unsigned chan, uint32_t data28)
{
- if (mbox_dev)
- return dev_mbox_write(mbox_dev, chan, data28);
- else
+ if (!mbox_dev)
return -ENODEV;
+
+ return dev_mbox_write(mbox_dev, chan, data28);
}
EXPORT_SYMBOL_GPL(bcm_mailbox_write);
extern int bcm_mailbox_read(unsigned chan, uint32_t *data28)
{
- if (mbox_dev)
- return dev_mbox_read(mbox_dev, chan, data28);
- else
+ if (!mbox_dev)
return -ENODEV;
+
+ return dev_mbox_read(mbox_dev, chan, data28);
}
EXPORT_SYMBOL_GPL(bcm_mailbox_read);