Re: [PATCH 03/10] mtd: nand: omap2: handle nand on gpmc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Afzal Mohammed <afzal@xxxxxx> [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
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux