[PATCH 4/6] block2mtd: attach device OF node to MTD device

kernel test robot lkp at intel.com
Sun Aug 4 06:58:32 PDT 2024


Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240804-194357
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804114108.1893-5-ansuelsmth%40gmail.com
patch subject: [PATCH 4/6] block2mtd: attach device OF node to MTD device
config: i386-buildonly-randconfig-001-20240804 (https://download.01.org/0day-ci/archive/20240804/202408042135.nXaBv2UM-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240804/202408042135.nXaBv2UM-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp at intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408042135.nXaBv2UM-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/mtd/devices/block2mtd.c: In function 'add_device':
>> drivers/mtd/devices/block2mtd.c:332:9: error: 'ddev' undeclared (first use in this function); did you mean 'dev'?
     332 |         ddev = disk_to_dev(dev->blkdev->bd_disk);
         |         ^~~~
         |         dev
   drivers/mtd/devices/block2mtd.c:332:9: note: each undeclared identifier is reported only once for each function it appears in
   In file included from drivers/mtd/devices/block2mtd.c:22:
>> drivers/mtd/devices/block2mtd.c:332:31: error: 'struct block2mtd_dev' has no member named 'blkdev'
     332 |         ddev = disk_to_dev(dev->blkdev->bd_disk);
         |                               ^~
   include/linux/blkdev.h:258:13: note: in definition of macro 'disk_to_dev'
     258 |         (&((disk)->part0->bd_device))
         |             ^~~~
   drivers/mtd/devices/block2mtd.c:333:25: error: 'struct block2mtd_dev' has no member named 'blkdev'
     333 |         if (ddev == &dev->blkdev->bd_device)
         |                         ^~


vim +332 drivers/mtd/devices/block2mtd.c

   260	
   261	static struct block2mtd_dev *add_device(char *devname, int erase_size,
   262			char *label, int timeout)
   263	{
   264		const blk_mode_t mode = BLK_OPEN_READ | BLK_OPEN_WRITE;
   265		struct file *bdev_file;
   266		struct block_device *bdev;
   267		struct block2mtd_dev *dev;
   268		loff_t size;
   269		char *name;
   270	
   271		if (!devname)
   272			return NULL;
   273	
   274		dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
   275		if (!dev)
   276			return NULL;
   277	
   278		/* Get a handle on the device */
   279		bdev_file = bdev_file_open_by_path(devname, mode, dev, NULL);
   280		if (IS_ERR(bdev_file))
   281			bdev_file = mdtblock_early_get_bdev(devname, mode, timeout,
   282							      dev);
   283		if (IS_ERR(bdev_file)) {
   284			pr_err("error: cannot open device %s\n", devname);
   285			goto err_free_block2mtd;
   286		}
   287		dev->bdev_file = bdev_file;
   288		bdev = file_bdev(bdev_file);
   289	
   290		if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
   291			pr_err("attempting to use an MTD device as a block device\n");
   292			goto err_free_block2mtd;
   293		}
   294	
   295		size = bdev_nr_bytes(bdev);
   296		if ((long)size % erase_size) {
   297			pr_err("erasesize must be a divisor of device size\n");
   298			goto err_free_block2mtd;
   299		}
   300	
   301		mutex_init(&dev->write_mutex);
   302	
   303		/* Setup the MTD structure */
   304		/* make the name contain the block device in */
   305		if (!label)
   306			name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
   307		else
   308			name = kstrdup(label, GFP_KERNEL);
   309		if (!name)
   310			goto err_destroy_mutex;
   311	
   312		dev->mtd.name = name;
   313	
   314		dev->mtd.size = size & PAGE_MASK;
   315		dev->mtd.erasesize = erase_size;
   316		dev->mtd.writesize = 1;
   317		dev->mtd.writebufsize = PAGE_SIZE;
   318		dev->mtd.type = MTD_RAM;
   319		dev->mtd.flags = MTD_CAP_RAM;
   320		dev->mtd._erase = block2mtd_erase;
   321		dev->mtd._write = block2mtd_write;
   322		dev->mtd._sync = block2mtd_sync;
   323		dev->mtd._read = block2mtd_read;
   324		dev->mtd.priv = dev;
   325		dev->mtd.owner = THIS_MODULE;
   326	
   327		/*
   328		 * Check if we are using root blockdev.
   329		 * If it's the case, connect the MTD of_node to the ddev parent
   330		 * to support providing partition in DT node.
   331		 */
 > 332		ddev = disk_to_dev(dev->blkdev->bd_disk);
   333		if (ddev == &dev->blkdev->bd_device)
   334			dev->mtd.dev.of_node = of_node_get(ddev->parent->of_node);
   335	
   336		if (mtd_device_register(&dev->mtd, NULL, 0)) {
   337			/* Device didn't get added, so free the entry */
   338			goto err_destroy_mutex;
   339		}
   340	
   341		list_add(&dev->list, &blkmtd_device_list);
   342		pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
   343			dev->mtd.index,
   344			label ? label : dev->mtd.name + strlen("block2mtd: "),
   345			dev->mtd.erasesize >> 10, dev->mtd.erasesize);
   346		return dev;
   347	
   348	err_destroy_mutex:
   349		of_node_put(dev->mtd.dev.of_node);
   350		mutex_destroy(&dev->write_mutex);
   351	err_free_block2mtd:
   352		block2mtd_free_device(dev);
   353		return NULL;
   354	}
   355	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



More information about the linux-mtd mailing list