linux-mips
[Top] [All Lists]

Re: [PATCH 1/8] MIPS: BCM63XX: move flash registration out of board_bcm9

To: Jonas Gorski <jonas.gorski@gmail.com>
Subject: Re: [PATCH 1/8] MIPS: BCM63XX: move flash registration out of board_bcm963xx.c
From: Ralf Baechle <ralf@linux-mips.org>
Date: Wed, 13 Jun 2012 14:48:01 +0100
Cc: linux-mips@linux-mips.org, Maxime Bizon <mbizon@freebox.fr>, Florian Fainelli <florian@openwrt.org>, Kevin Cernekee <cernekee@gmail.com>
In-reply-to: <1339489425-19037-2-git-send-email-jonas.gorski@gmail.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1339489425-19037-1-git-send-email-jonas.gorski@gmail.com> <1339489425-19037-2-git-send-email-jonas.gorski@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
On Tue, Jun 12, 2012 at 10:23:38AM +0200, Jonas Gorski wrote:

> board_bcm963xx.c is already large enough.

And the grand cure for that sort of issue is FDT - we by now have built
big deserts of code just registering platform devices like this..  See
John Crispin's Lantiq work or David's Cavium code for FDT examples.

> +int __init bcm63xx_flash_register(void)
> +{
> +     u32 val;
> +
> +     /* read base address of boot chip select (0) */
> +     val = bcm_mpi_readl(MPI_CSBASE_REG(0));
> +     val &= MPI_CSBASE_BASE_MASK;
> +
> +     mtd_resources[0].start = val;
> +     mtd_resources[0].end = 0x1FFFFFFF;
> +
> +     return platform_device_register(&mtd_dev);
> +}
> diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h 
> b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
> new file mode 100644
> index 0000000..8dcb541
> --- /dev/null
> +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
> @@ -0,0 +1,6 @@
> +#ifndef __BCM63XX_FLASH_H
> +#define __BCM63XX_FLASH_H
> +
> +int __init bcm63xx_flash_register(void);

Don't use __init in declarations.  It doesn't make any difference to the
compiler but it may cause build errors if <linux/init.h> has not been
included before which this file doesn't.

> +#endif /* __BCM63XX_FLASH_H */

I suggest to make bcm63xx_flash_register an arch_initcall.  It already is
being called indirectly from an bcm63xx_flash_register() so this would
allow making the function static, get rid of bcm63xx_dev_flash.h which
only exists to silence checkpatch warnings and make board_register_devices
a little cleaner.

  Ralf

PS: Don't forget about FDT :-)  Eventually, not necessarily now.

<Prev in Thread] Current Thread [Next in Thread>