Signed-off-by: Jan Luebbe <[email protected]>
---
 drivers/nor/m25p80.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index 61f2195..1722e0a 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -20,6 +20,7 @@
 #include <common.h>
 #include <init.h>
 #include <driver.h>
+#include <ioctl.h>
 #include <spi/spi.h>
 #include <spi/flash.h>
 #include <xfuncs.h>
@@ -690,9 +691,34 @@ static const struct spi_device_id *jedec_probe(struct 
spi_device *spi)
        return NULL;
 }
 
+static int m25p80_ioctl(struct cdev *cdev, int request, void *buf)
+{
+       struct m25p *flash = cdev->priv;
+       struct flash_info *info = flash->info;
+       struct mtd_info_user *user = buf;
+
+       switch (request) {
+       case MEMGETINFO:
+               memset(user, 0, sizeof(*user));
+               user->type = MTD_NORFLASH;
+               user->flags = MTD_CAP_NORFLASH;
+               user->size = flash->size;
+               user->erasesize = info->sector_size;
+               user->writesize = 1;
+               user->oobsize = 0;
+               /* The below fields are obsolete */
+               user->ecctype = -1;
+               user->eccsize = 0;
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
 static struct file_operations m25p80_ops = {
        .read   = m25p80_read,
        .write  = m25p80_write,
+       .ioctl  = m25p80_ioctl,
        .erase  = m25p80_erase,
        .lseek  = dev_lseek_default,
 };
-- 
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to