lightnvm: check for NAND flash and its type
authorMatias Bjørling <m@bjorling.me>
Mon, 16 Nov 2015 14:34:41 +0000 (15:34 +0100)
committerJens Axboe <axboe@fb.com>
Mon, 16 Nov 2015 22:20:30 +0000 (15:20 -0700)
Only NAND flash with SLC and MLC is supported. Make sure to not try to
initialize TLC memory or other non-volatile memory types.

Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/lightnvm/core.c

index f659e605a4067bed3489723470e32cc9ae02b791..0985a032debc6abbd98c0119e2c4b172ba00b266 100644 (file)
@@ -185,6 +185,16 @@ static int nvm_core_init(struct nvm_dev *dev)
        dev->plane_mode = NVM_PLANE_SINGLE;
        dev->max_rq_size = dev->ops->max_phys_sect * dev->sec_size;
 
+       if (grp->mtype != 0) {
+               pr_err("nvm: memory type not supported\n");
+               return -EINVAL;
+       }
+
+       if (grp->fmtype != 0 && grp->fmtype != 1) {
+               pr_err("nvm: flash type not supported\n");
+               return -EINVAL;
+       }
+
        if (grp->mpos & 0x020202)
                dev->plane_mode = NVM_PLANE_DOUBLE;
        if (grp->mpos & 0x040404)