All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Afzal Mohammed <afzal@ti.com>
Cc: artem.bityutskiy@linux.intel.com, ivan.djelic@parrot.com,
	linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 03/10] mtd: nand: omap2: handle nand on gpmc
Date: Wed, 13 Jun 2012 03:45:06 -0700	[thread overview]
Message-ID: <20120613104505.GI12766@atomide.com> (raw)
In-Reply-To: <f39c9f3c8403d1ddc925ddcb6bf03ce1fe805c59.1338790117.git.afzal@ti.com>

* Afzal Mohammed <afzal@ti.com> [120604 00:06]:
> +static int omap_prefetch_enable(int cs, int fifo_th, int dma_mode,
> +	unsigned int u32_count, int is_write, struct omap_nand_info *info)
> +{
> +	u32 val;
> +
> +	if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX) {
> +		pr_err("gpmc: fifo threshold is not supported\n");
> +		return -1;
> +	} else if (!(readl(info->reg.gpmc_prefetch_control))) {
> +		/* Set the amount of bytes to be prefetched */
> +		writel(u32_count, info->reg.gpmc_prefetch_config2);
> +
> +		/* Set dma/mpu mode, the prefetch read / post write and
> +		 * enable the engine. Set which cs is has requested for.
> +		 */
> +		val = ((cs << PREFETCH_CONFIG1_CS_SHIFT) |
> +					PREFETCH_FIFOTHRESHOLD(fifo_th) |
> +					ENABLE_PREFETCH |
> +					(dma_mode << DMA_MPU_MODE_SHIFT) |
> +					(0x1 & is_write));
> +		writel(val, info->reg.gpmc_prefetch_config1);
> +
> +		/*  Start the prefetch engine */
> +		writel(0x1, info->reg.gpmc_prefetch_control);
> +	} else {
> +		return -EBUSY;
> +	}
> +
> +	return 0;
> +}

You can simplify the above by leaving out the if else stuff by
returning early:

	if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX)
		return -1;

	if (readl(info->reg.gpmc_prefetch_control))
		return -EBUSY;

	/* Set the amount of bytes to be prefetched */
	writel(u32_count, info->reg.gpmc_prefetch_config2);
	...

	return 0;

Regards,

Tony

WARNING: multiple messages have this Message-ID (diff)
From: Tony Lindgren <tony@atomide.com>
To: Afzal Mohammed <afzal@ti.com>
Cc: artem.bityutskiy@linux.intel.com, linux-omap@vger.kernel.org,
	linux-mtd@lists.infradead.org, ivan.djelic@parrot.com
Subject: Re: [PATCH 03/10] mtd: nand: omap2: handle nand on gpmc
Date: Wed, 13 Jun 2012 03:45:06 -0700	[thread overview]
Message-ID: <20120613104505.GI12766@atomide.com> (raw)
In-Reply-To: <f39c9f3c8403d1ddc925ddcb6bf03ce1fe805c59.1338790117.git.afzal@ti.com>

* Afzal Mohammed <afzal@ti.com> [120604 00:06]:
> +static int omap_prefetch_enable(int cs, int fifo_th, int dma_mode,
> +	unsigned int u32_count, int is_write, struct omap_nand_info *info)
> +{
> +	u32 val;
> +
> +	if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX) {
> +		pr_err("gpmc: fifo threshold is not supported\n");
> +		return -1;
> +	} else if (!(readl(info->reg.gpmc_prefetch_control))) {
> +		/* Set the amount of bytes to be prefetched */
> +		writel(u32_count, info->reg.gpmc_prefetch_config2);
> +
> +		/* Set dma/mpu mode, the prefetch read / post write and
> +		 * enable the engine. Set which cs is has requested for.
> +		 */
> +		val = ((cs << PREFETCH_CONFIG1_CS_SHIFT) |
> +					PREFETCH_FIFOTHRESHOLD(fifo_th) |
> +					ENABLE_PREFETCH |
> +					(dma_mode << DMA_MPU_MODE_SHIFT) |
> +					(0x1 & is_write));
> +		writel(val, info->reg.gpmc_prefetch_config1);
> +
> +		/*  Start the prefetch engine */
> +		writel(0x1, info->reg.gpmc_prefetch_control);
> +	} else {
> +		return -EBUSY;
> +	}
> +
> +	return 0;
> +}

You can simplify the above by leaving out the if else stuff by
returning early:

	if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX)
		return -1;

	if (readl(info->reg.gpmc_prefetch_control))
		return -EBUSY;

	/* Set the amount of bytes to be prefetched */
	writel(u32_count, info->reg.gpmc_prefetch_config2);
	...

	return 0;

Regards,

Tony

  reply	other threads:[~2012-06-13 10:45 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04  6:45 [PATCH 00/10] Prepare for GPMC driver conversion (w.r.t MTD) Afzal Mohammed
2012-06-04  6:45 ` Afzal Mohammed
2012-06-04  6:46 ` [PATCH 01/10] ARM: OMAP2+: gpmc: update nand register helper Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-04  6:46 ` [PATCH 02/10] ARM: OMAP2+: gpmc-nand: update gpmc-nand regs Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-04  6:46 ` [PATCH 03/10] mtd: nand: omap2: handle nand on gpmc Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-13 10:45   ` Tony Lindgren [this message]
2012-06-13 10:45     ` Tony Lindgren
2012-06-04  6:46 ` [PATCH 04/10] ARM: OMAP2+: gpmc-nand: update resource with memory Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-04  6:46 ` [PATCH 05/10] ARM: OMAP2+: gpmc-onenand: provide memory as resource Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-04  6:46 ` [PATCH 06/10] mtd: nand: omap2: obtain memory from resource Afzal Mohammed
2012-06-04  6:46   ` Afzal Mohammed
2012-06-04  6:47 ` [PATCH 07/10] mtd: onenand: " Afzal Mohammed
2012-06-04  6:47   ` Afzal Mohammed
2012-06-04  6:47 ` [PATCH 08/10] ARM: OMAP2+: gpmc: Modify interrupt handling Afzal Mohammed
2012-06-04  6:47   ` Afzal Mohammed
2012-06-04  6:47 ` [PATCH 09/10] ARM: OMAP2+: gpmc-nand: Modify Interrupt handling Afzal Mohammed
2012-06-04  6:47   ` Afzal Mohammed
2012-06-04  6:47 ` [PATCH 10/10] mtd: nand: omap2: use gpmc provided irqs Afzal Mohammed
2012-06-04  6:47   ` Afzal Mohammed
2012-06-07 15:14 ` [PATCH 00/10] Prepare for GPMC driver conversion (w.r.t MTD) Mohammed, Afzal
2012-06-12  9:57   ` Mohammed, Afzal
2012-06-13 11:09     ` Tony Lindgren
2012-06-13 11:09       ` Tony Lindgren
2012-06-13 11:12       ` Mohammed, Afzal
2012-06-13 11:12         ` Mohammed, Afzal
2012-06-14 16:01       ` Mohammed, Afzal
2012-06-14 16:01         ` Mohammed, Afzal
2012-06-14 16:17         ` Artem Bityutskiy
2012-06-14 16:17           ` Artem Bityutskiy
2012-06-14 16:17           ` Mohammed, Afzal
2012-06-14 16:17             ` Mohammed, Afzal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120613104505.GI12766@atomide.com \
    --to=tony@atomide.com \
    --cc=afzal@ti.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=ivan.djelic@parrot.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.