--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
-@@ -136,6 +136,10 @@ config MTD_BCM47XXSFLASH
+@@ -135,6 +135,10 @@ config MTD_BCM47XXSFLASH
registered by bcma as platform devices. This enables driver for
serial flash memories (only read-only mode is implemented).
--- /dev/null
+++ b/drivers/mtd/devices/ar2315.c
-@@ -0,0 +1,515 @@
+@@ -0,0 +1,527 @@
+
+/*
+ * MTD driver for the SPI Flash Memory support on Atheros AR2315
+#include <linux/sched.h>
+#include <linux/root_dev.h>
+#include <linux/delay.h>
-+#include <asm/delay.h>
-+#include <asm/io.h>
++#include <linux/io.h>
+
+#include <ar2315_spiflash.h>
+#include <ar231x_platform.h>
+
+const struct flashconfig flashconfig_tbl[] = {
+ [FLASH_NONE] = { 0, 0, 0},
-+ [FLASH_1MB] = { STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT, STM_1MB_SECTOR_SIZE},
-+ [FLASH_2MB] = { STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE},
-+ [FLASH_4MB] = { STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE},
-+ [FLASH_8MB] = { STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE},
-+ [FLASH_16MB] = { STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT, STM_16MB_SECTOR_SIZE}
++ [FLASH_1MB] = { STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT,
++ STM_1MB_SECTOR_SIZE},
++ [FLASH_2MB] = { STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT,
++ STM_2MB_SECTOR_SIZE},
++ [FLASH_4MB] = { STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT,
++ STM_4MB_SECTOR_SIZE},
++ [FLASH_8MB] = { STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT,
++ STM_8MB_SECTOR_SIZE},
++ [FLASH_16MB] = { STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT,
++ STM_16MB_SECTOR_SIZE}
+};
+
+/* Mapping of generic opcodes to STM serial flash opcodes */
+};
+
+struct opcodes {
-+ __u16 code;
-+ __s8 tx_cnt;
-+ __s8 rx_cnt;
++ __u16 code;
++ __s8 tx_cnt;
++ __s8 rx_cnt;
+};
++
+const struct opcodes stm_opcodes[] = {
+ [SPI_WRITE_ENABLE] = {STM_OP_WR_ENABLE, 1, 0},
+ [SPI_WRITE_DISABLE] = {STM_OP_WR_DISABLE, 1, 0},
+ FL_WRITING
+};
+
-+/***************************************************************************************************/
++/*****************************************************************************/
+
+static u32
+spiflash_read_reg(struct spiflash_priv *priv, int reg)
+}
+
+static u32
-+spiflash_sendcmd (struct spiflash_priv *priv, int opcode, u32 addr)
++spiflash_sendcmd(struct spiflash_priv *priv, int opcode, u32 addr)
+{
+ const struct opcodes *op;
+ u32 reg, mask;
+ * and flashconfig_tbl array index for success.
+ */
+static int
-+spiflash_probe_chip (struct spiflash_priv *priv)
++spiflash_probe_chip(struct spiflash_priv *priv)
+{
+ u32 sig;
+ int flash_size;
+ flash_size = FLASH_16MB;
+ break;
+ default:
-+ printk (KERN_WARNING SPIFLASH "Read of flash device signature failed!\n");
++ pr_warn(SPIFLASH "Read of flash device signature failed!\n");
+ return 0;
+ }
+
+ schedule();
+ remove_wait_queue(&priv->wq, &wait);
+
-+ if(signal_pending(current))
++ if (signal_pending(current))
+ return 0;
+
+ goto retry;
+
+
+static int
-+spiflash_erase (struct mtd_info *mtd, struct erase_info *instr)
++spiflash_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+ struct spiflash_priv *priv = to_spiflash(mtd);
+ const struct opcodes *op;
+}
+
+static int
-+spiflash_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
++spiflash_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
++ u_char *buf)
+{
+ struct spiflash_priv *priv = to_spiflash(mtd);
+ u8 *read_addr;
+}
+
+static int
-+spiflash_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u8 *buf)
++spiflash_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
++ const u8 *buf)
+{
+ struct spiflash_priv *priv = to_spiflash(mtd);
+ u32 opcode, bytes_left;
+
+
+#if defined CONFIG_MTD_REDBOOT_PARTS || CONFIG_MTD_MYLOADER_PARTS
-+static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", "MyLoader", NULL };
++static const char * const part_probe_types[] = {
++ "cmdlinepart", "RedBoot", "MyLoader", NULL
++};
+#endif
+
+
+
+ priv->mmraddr = ioremap_nocache(SPI_FLASH_MMR, SPI_FLASH_MMR_SIZE);
+ if (!priv->mmraddr) {
-+ printk(KERN_WARNING SPIFLASH "Failed to map flash device\n");
++ dev_warn(&pdev->dev, SPIFLASH "Failed to map flash device\n");
+ goto error;
+ }
+
+ index = spiflash_probe_chip(priv);
+ if (!index) {
-+ printk (KERN_WARNING SPIFLASH "Found no serial flash device\n");
++ dev_warn(&pdev->dev, SPIFLASH "Found no flash device\n");
+ goto error;
+ }
+
-+ priv->readaddr = ioremap_nocache(SPI_FLASH_READ, flashconfig_tbl[index].byte_cnt);
++ priv->readaddr = ioremap_nocache(SPI_FLASH_READ,
++ flashconfig_tbl[index].byte_cnt);
+ if (!priv->readaddr) {
-+ printk (KERN_WARNING SPIFLASH "Failed to map flash device\n");
++ dev_warn(&pdev->dev, SPIFLASH "Failed to map flash device\n");
+ goto error;
+ }
+
+ mtd->_write = spiflash_write;
+ mtd->owner = THIS_MODULE;
+
++ dev_info(&pdev->dev, "%lld Kbytes flash detected\n", mtd->size >> 10);
++
+#if defined CONFIG_MTD_REDBOOT_PARTS || CONFIG_MTD_MYLOADER_PARTS
+ /* parse redboot partitions */
+
+}
+
+static int
-+spiflash_remove (struct platform_device *pdev)
++spiflash_remove(struct platform_device *pdev)
+{
+ struct spiflash_priv *priv = platform_get_drvdata(pdev);
+ struct mtd_info *mtd = &priv->mtd;
+};
+
+int __init
-+spiflash_init (void)
++spiflash_init(void)
+{
+ return platform_driver_register(&spiflash_driver);
+}
+
+void __exit
-+spiflash_exit (void)
++spiflash_exit(void)
+{
+ return platform_driver_unregister(&spiflash_driver);
+}
+
-+module_init (spiflash_init);
-+module_exit (spiflash_exit);
++module_init(spiflash_init);
++module_exit(spiflash_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("OpenWrt.org, Atheros Communications Inc");