Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MTD] Fix !CONFIG_BLOCK compile for mtdsuper.c

As reported by Adrian Bunk, commit d5686b444ff3f72808d2b3fbd58672a86cdf38e7
(switch mtd and dm-table to lookup_bdev()) causes the following compile
error with CONFIG_BLOCK=n:

CC drivers/mtd/mtdsuper.o
drivers/mtd/mtdsuper.c: In function `get_sb_mtd':
drivers/mtd/mtdsuper.c:184: error: implicit declaration of function 'lookup_bdev'
drivers/mtd/mtdsuper.c:184: warning: assignment makes pointer from integer without a cast
drivers/mtd/mtdsuper.c:197: error: implicit declaration of function 'bdput'
make[3]: *** [drivers/mtd/mtdsuper.o] Error 1

Fix it by putting the block device lookup inside #ifdef CONFIG_BLOCK

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

+12 -5
+12 -5
drivers/mtd/mtdsuper.c
··· 125 125 int (*fill_super)(struct super_block *, void *, int), 126 126 struct vfsmount *mnt) 127 127 { 128 + #ifdef CONFIG_BLOCK 128 129 struct block_device *bdev; 129 - int mtdnr, ret; 130 + int ret, major; 131 + #endif 132 + int mtdnr; 130 133 131 134 if (!dev_name) 132 135 return -EINVAL; ··· 181 178 } 182 179 } 183 180 181 + #ifdef CONFIG_BLOCK 184 182 /* try the old way - the hack where we allowed users to mount 185 183 * /dev/mtdblock$(n) but didn't actually _use_ the blockdev 186 184 */ ··· 194 190 DEBUG(1, "MTDSB: lookup_bdev() returned 0\n"); 195 191 196 192 ret = -EINVAL; 197 - if (MAJOR(bdev->bd_dev) != MTD_BLOCK_MAJOR) 198 - goto not_an_MTD_device; 199 193 194 + major = MAJOR(bdev->bd_dev); 200 195 mtdnr = MINOR(bdev->bd_dev); 201 196 bdput(bdev); 197 + 198 + if (major != MTD_BLOCK_MAJOR) 199 + goto not_an_MTD_device; 202 200 203 201 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, 204 202 mnt); 205 203 206 204 not_an_MTD_device: 205 + #endif /* CONFIG_BLOCK */ 206 + 207 207 if (!(flags & MS_SILENT)) 208 208 printk(KERN_NOTICE 209 209 "MTD: Attempt to mount non-MTD device \"%s\"\n", 210 210 dev_name); 211 - bdput(bdev); 212 - return ret; 211 + return -EINVAL; 213 212 } 214 213 215 214 EXPORT_SYMBOL_GPL(get_sb_mtd);